Fixed my derp in cmd_admin_pm where the input popup was being displayed to usr rather than src (usr is the mob src is the client)

AdminHelps are now client verbs rather than mob verbs. Which means adminhelp can be called from cmd_admin_pm when an admin disconnects or something. This will stop non-admins getting the message "Client not found" (read as: license to grieffe) when an admin disconnects for whatever reason.

Moved AdminPM stuff to adminpm.dm

Fixed some run-times in posters and fixed posters eternally having the laying poster icon_state(whatever it was called) when something went awry.

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@3456 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
elly1989@rocketmail.com
2012-04-14 14:24:46 +00:00
parent 4863c83dd0
commit 1b0661c26b
7 changed files with 166 additions and 204 deletions

View File

@@ -85,111 +85,6 @@
log_admin("DirectNarrate: [key_name(usr)] to ([M.name]/[M.key]): [msg]")
message_admins("\blue \bold DirectNarrate: [key_name(usr)] to ([M.name]/[M.key]): [msg]<BR>", 1)
//allows right clicking mobs to send an admin PM to their client, forwards the selected mob's client to cmd_admin_pm
/client/proc/cmd_admin_pm_context(mob/M as mob in world)
set category = null
set name = "Admin PM Mob"
if(!holder)
src << "\red Error: Admin-PM-Context: Only administrators may use this command."
return
if( !ismob(M) || !M.client ) return
cmd_admin_pm(M.client)
//shows a list of clients we could send PMs to, then forwards our choice to cmd_admin_pm
/client/proc/cmd_admin_pm_panel()
set category = "Admin"
set name = "Admin PM"
if(!holder)
src << "\red Error: Admin-PM-Panel: Only administrators may use this command."
return
var/list/client/targets[0]
for(var/client/T)
if(T.mob)
if(istype(T.mob, /mob/new_player))
targets["(New Player) - [T]"] = T
else if(istype(T.mob, /mob/dead/observer))
targets["[T.mob.name](Ghost) - [T]"] = T
else
targets["[T.mob.real_name](as [T.mob.name]) - [T]"] = T
else
targets["(No Mob) - [T]"] = T
var/list/sorted = sortList(targets)
var/target = input(usr,"To whom shall we send a message?","Admin PM",null) in sorted|null
cmd_admin_pm(targets[target])
//takes input from cmd_admin_pm_context, cmd_admin_pm_panel or /client/Topic and sends them a PM after fetching a message to send.
/client/proc/cmd_admin_pm(var/client/C = null, var/t = null)
if( !C || !istype(C,/client) )
src << "\red Error: Admin-PM: Client not found."
return
if(src.muted_complete)
src << "\red Error: Admin-PM: You are muted."
return
//get message text, limit it's length.and clean/escape html
if(!t)
t = input("Message:", "Private message to [C.key]") as text|null
if(!t) return
if(!C)
src << "\red Error: Admin PM: Client not found."
return
//clean the message if it's not sent by a GA or GM
if( !holder || !(holder.rank in list("Game Admin", "Game Master")) )
t = sanitize(copytext(t,1,500))
if(!t) return
if(C.holder)
if(holder) //both are admins
C << "<font color='red'>Admin PM from-<b>[key_name(src, C, 1)]</b>: [t]</font>"
src << "<font color='blue'>Admin PM to-<b>[key_name(C, src, 1)]</b>: [t]</font>"
else //recipient is an admin but sender is not
C << "<font color='red'>Reply PM from-<b>[key_name(src, C, 1)]</b>: [t]</font>"
src << "<font color='blue'>Reply PM to-<b>[key_name(C, src, 0)]</b>: [t]</font>"
//play the recieving admin the adminhelp sound (if they have them enabled)
if(C.sound_adminhelp)
C << 'adminhelp.ogg'
else
if(holder) //sender is an admin but recipient is not. Do BIG RED TEXT
C << "<font color='red' size='4'><b>-- Administrator private message --</b></font>"
C << "<font color='red'>Admin PM from-<b>[key_name(src, C, 0)]</b>: [t]</font>"
C << "<font color='red'><i>Click on the administrator's name to reply.</i></font>"
src << "<font color='blue'>Admin PM to-<b>[key_name(C, src, 1)]</b>: [t]</font>"
//always play non-admin recipients the adminhelp sound
C << 'adminhelp.ogg'
//AdminPM popup for ApocStation and anybody else who wants to use it. Set it with POPUP_ADMIN_PM in config.txt ~Carn
if(config.popup_admin_pm)
spawn() //so we don't hold the caller proc up
var/sender = src
var/sendername = key
var/reply = input(C, t,"Admin PM from-[sendername]", "") as text|null //show message and await a reply
if(C && reply)
if(sender)
C.cmd_admin_pm(sender,reply) //sender is still about, let's reply to them
else
for(var/client/X) //sender has left! find another admin to pm
if(X.holder)
return C.cmd_admin_pm(X,reply)
C << "<font class='red'>Error: Admin PM: Client not found.</font>" //couldn't find one
return
else //neither are admins
src << "<font class='red'>Error: Admin PM: Non-admin to non-admin PM communication is forbidden.</font>"
return
log_admin("PM: [key_name(src)]->[key_name(C)]: [t]")
//we don't use message_admins here because the sender/receiver might get it too
for(var/client/X) //there are fewer clients than mobs
if(X.holder && X.key!=key && X.key!=C.key) //check client/X is an admin and isn't the sender or recipient
X << "<B><font color='blue'>PM: [key_name(src, X, 0)]-&gt;[key_name(C, X, 0)]:</B> \blue [t]</font>" //inform X
/client/proc/cmd_admin_godmode(mob/M as mob in world)
set category = "Special Verbs"
set name = "Godmode"