Adminhelp refactoring, you can now type adminhelp in command box.

Formatted some code, also added a confirmation for the sender if their adminhelp looks fine.
This commit is contained in:
Amunak
2014-11-28 10:16:56 +01:00
parent 3e6ebe5d4c
commit bf6a8c5aa5

View File

@@ -3,7 +3,7 @@
//This is a list of words which are ignored by the parser when comparing message contents for names. MUST BE IN LOWER CASE!
var/list/adminhelp_ignored_words = list("unknown","the","a","an","of","monkey","alien","as")
/client/verb/adminhelp()
/client/verb/adminhelp(msg as null|text)
set category = "Admin"
set name = "Adminhelp"
@@ -16,7 +16,6 @@ var/list/adminhelp_ignored_words = list("unknown","the","a","an","of","monkey","
src << "<font color='red'>Error: Admin-PM: You cannot send adminhelps (Muted).</font>"
return
adminhelped = 1 //Determines if they get the message to reply by clicking the name.
/**src.verbs -= /client/verb/adminhelp
@@ -25,26 +24,29 @@ var/list/adminhelp_ignored_words = list("unknown","the","a","an","of","monkey","
src.verbs += /client/verb/adminhelp // 2 minute cool-down for adminhelps
src.verbs += /client/verb/adminhelp // 2 minute cool-down for adminhelps//Go to hell
**/
var/msg
var/list/type = list ("Gameplay/Roleplay question", "Rule/Gameplay issue", "Bug report")
var/selected_type = input("Pick a category.", "Admin Help", null, null) as null|anything in type
if(selected_type)
if(!selected_type)
return
if(!msg)
msg = input("Please enter your message:", "Admin Help", null, null) as text
if(!msg || alert("The following message will be sent to staff that administers\n the '[selected_type]' category:\n\n[msg]\n", "Admin Help", "Ok", "Cancel") == "Cancel")
return
var/selected_upper = uppertext(selected_type)
if(src.handle_spam_prevention(msg,MUTE_ADMINHELP))
return
//clean the input msg
if(!msg) return
if(!msg)
return
msg = sanitize(copytext(msg,1,MAX_MESSAGE_LEN))
if(!msg) return
if(!msg)
return
var/original_msg = msg
//explode the input msg into a list
var/list/msglist = text2list(msg, " ")
@@ -98,14 +100,15 @@ var/list/adminhelp_ignored_words = list("unknown","the","a","an","of","monkey","
continue
msg += "[original_word] "
if(!mob) return //this doesn't happen
var/ref_mob = "\ref[mob]"
var/mentor_msg = "\blue <b><font color=red>[selected_upper]: </font>[get_options_bar(mob, 0, 0, 1, 0)][ai_found ? " (<A HREF='?_src_=holder;adminchecklaws=[ref_mob]'>CL</A>)" : ""]:</b> [msg]"
var/dev_msg = "\blue <b><font color=red>[selected_upper]: </font>[get_options_bar(mob, 3, 0, 1, 0)][ai_found ? " (<A HREF='?_src_=holder;adminchecklaws=[ref_mob]'>CL</A>)" : ""]:</b> [msg]"
msg = "\blue <b><font color=red>[selected_upper]: </font>[get_options_bar(mob, 2, 1, 1)][ai_found ? " (<A HREF='?_src_=holder;adminchecklaws=[ref_mob]'>CL</A>)" : ""]:</b> [msg]"
if(!mob) //this doesn't happen
return
var/ai_cl
if(ai_found)
ai_cl = " (<A HREF='?_src_=holder;adminchecklaws=\ref[mob]'>CL</A>)"
var/mentor_msg = "\blue <b><font color=red>[selected_upper]: </font>[get_options_bar(mob, 0, 0, 1, 0)][ai_cl]:</b> [msg]"
var/dev_msg = "\blue <b><font color=red>[selected_upper]: </font>[get_options_bar(mob, 3, 0, 1, 0)][ai_cl]:</b> [msg]"
msg = "\blue <b><font color=red>[selected_upper]: </font>[get_options_bar(mob, 2, 1, 1)][ai_cl]:</b> [msg]"
var/admin_number_afk = 0
@@ -158,10 +161,6 @@ var/list/adminhelp_ignored_words = list("unknown","the","a","an","of","monkey","
X << 'sound/effects/adminhelp.ogg'
X << dev_msg
/*for(var/client/X in admins)
if((R_ADMIN|R_MOD|R_MENTOR) & X.holder.rights)
if(X.is_afk())
@@ -179,10 +178,7 @@ var/list/adminhelp_ignored_words = list("unknown","the","a","an","of","monkey","
var/admin_number_present = admins.len - admin_number_afk
log_admin("HELP: [key_name(src)]: [original_msg] - heard by [admin_number_present] non-AFK admins.")
if(admin_number_present <= 0)
if(!admin_number_afk)
send2adminirc("[selected_upper] from [key_name(src)]: [html_decode(original_msg)] - !!No admins online!!")
else
send2adminirc("[selected_upper] from [key_name(src)]: [html_decode(original_msg)] - !!All admins AFK ([admin_number_afk])!!")
send2adminirc("[selected_upper] from [key_name(src)]: [html_decode(original_msg)] - !![admin_number_afk ? "All admins AFK ([admin_number_afk])" : "No admins online"]!!")
else
send2adminirc("[selected_upper] from [key_name(src)]: [html_decode(original_msg)]")
feedback_add_details("admin_verb","AH") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!