ID:1717047
 
(See the best response by Nadrew.)
I want to make an Admin Help like in SS13 where when, i message a player my name is highlighted like some kind of URL and when clicked it pops up a input box where it sends a message directly to me and the other admins.

I know this uses Topic() but Topic() is a little too advance for me, mind helping anyone?

var/Admins = list("SP4C3_N0V4")
mob
verb
AdminHelp(t as text)
for(var/mob/Player/M in world)
if(M.key in Admins)
M << "<a href='?src=\ref[src];AdminHelp=Respond'>[src.key]</a>/[client.computer_id]: [t]"
mob/Topic(href,href_list[])
switch(href_list["AdminHelp"])
if("Help")
var/AdminH = input("Admin Help","Help Admin") as null|text
if(!AdminH)
world << "FUFSF"
return
else
for(var/mob/Player/M in world)
if(M.key in Admins)
M << "[src.key]/[client.computer_id]/[client.address]: [AdminH]"
world << "SENT"
if("Respond")
var/AdminH = input("Admin Help","Help Admin") as null|text
if(AdminH == null)
return
else
for(var/mob/Player/M in world)
if(M == href)
M << "ADMIN HELP: <a href='?src=\ref[src.key];AdminH=Help'>[src.key]</a>: [AdminH]"
else
world << "?"
return


This is all i got but doesn't seem to work as much.
Best response
There's quite a lot wrong with that, I'm not even sure where to start. You have unnecessary loops, checking the wrong variables for the wrong values. It was a good try though, you're on the right track.

var/list/admins_online = list()
// You should add/remove admins from this as they enter/leave, actual references to their mobs, not keys.
// Saves having to loop over every mob in the game to output to one group.

mob/verb/AdminHelp(T as text)
if(!T) return
if(!admins_online.len)
src << "There are no admins online, bummer."
return
admins_online << "<a href='byond://?src=\ref[src]&AdminHelp=Respond'>[src.key]</a>/[src.client.computer_id]: [html_encode(t)]"

mob/Topic(href,href_list[])
// This is one of those cases where the difference between src and usr becomes apparent, and useful.
// src is the owner of the proc, usr is the caller.
// In this case, usr is the person clicking src's link.
if(href_list && href_list["AdminHelp"])
switch(href_list["AdminHelp"])
if("Respond")
var/response = input(usr,"What is your response to [src.key]?","Response")as null|text
if(!response) return
src << "Admin Response from [usr.key]: [response]"


I wrote this off the top of my head so it may not be compile-perfect but it should definitely get you on a better path.

See how much less loop-heavy it is? That's a trick that lists have with the << operation, if the list contains things that can receive output, they'll receive it. It still loops internally, but the pool it's looping over is much, much smaller and more efficient.
Thanks Nadrew! I'm sorry as I told you i don't know how to use Topic() it was my first try using it. I enjoy the advice and the suggestions you left on the code :). I'll be sure to try your method.