ID:1027671
 
(See the best response by AJX.)
Code:
client/New()//When a client connects
..()//run the default behavior of client/New()
if(key in GM1) GM1[key]="<font color=lime>Online</font>"//if client's key is in list1, set their status in list1 to "Online"
if(key in GM2) GM2[key]="<font color=lime>Online</font>"//Same for list2
if(key in RPM1) RPM1[key]="<font color=lime>Online</font>"
if(key in RPM2) RPM2[key]="<font color=lime>Online</font>"
if(key in Board) Board[key]="<font color=lime>Online</font>"
client/Del()//Uppon the client disconnecting
if(key in GM1) GM1[key]="<font color=red>Offline</font>"//Check if their key is in list1 and if so, set their status in list1 as "Offline"
if(key in GM2) GM2[key]="<font color=red>Offline</font>"
if(key in RPM1) RPM1[key]="<font color=red>Offline</font>"
if(key in RPM2) RPM2[key]="<font color=red>Offline</font>"
if(key in Board) Board[key]="<font color=red>Offline</font>"
if(key in Partners) Partners[key]="<font color=red>Offline</font>"
..()//run the default behavior of client/Del()

var/list/GM1=list()//Make a list of keys relating to who's status you want to view and set their status to "Offline"
var/list/GM2=list()//Same as before
var/list/RPM1=list()//Same as before
var/list/RPM2=list()//Same as before
var/list/Board=list("Osiris1997"="<font color=red>Offline</font>","Aelita218"="<font color=red>Offline</font>","SC3PTR3"="<font color=red>Offline</font>")//Same as before
var/list/Partners=list("Terrabear"="<font color=red>Offline</font>","The Infamous Gamer"="<font color=red>Offline</font>","Sammmmy"="<font color=red>Offline</font>")//Same

mob/verb/CheckLists()
usr<<"<font color=lime>System Information</font>: Below contains a list of ingame, and incoded staff members.<br><big><b><font color=green>GM Lv.1</b></big></font>:"
for(var/v in GM1)//run for each key defined in list1
usr<<"--><font color=white>[v]([GM1[v]])"//display the key and the key's status
usr<<"<big><b><font color=blue>Admin</b></big></font>:"//same for list2
for(var/v in GM2)
usr<<"--><font color=white>[v]([GM2[v]])"
usr<<"<big><b><font color=yellow>RPM Lv. 1</b></big></font>:"//same for list2
for(var/v in RPM1)
usr<<"--><font color=white>[v]([RPM1[v]])"
usr<<"<big><b><font color=yellow>RPM Lv. 2</b></big></font>:"//same for list2
for(var/v in RPM2)
usr<<"--><font color=white>[v]([RPM2[v]])"
usr<<"<big><b><font color=#ba55d3>Board Executives</b></big></font>:"//same for list2
for(var/v in Board)
usr<<"--><font color=white>[v]([Board[v]])"
usr<<"<big><b><font color=#3BB9FF>Partners</b></big></font>:"//same for list2
for(var/v in Partners)
usr<<"--><font color=white>[v]([Partners[v]])"


Problem description:

Okay, well I posted earlier, and the code works and all, but it doesn't switch from offline to online, even when the key is there.

You didn't actually put the keys in the GM1 (...) lists.
In response to El Wookie
El Wookie wrote:
You didn't actually put the keys in the GM1 (...) lists.

even when the key is there.
In response to A.T.H.K
Excuse me?
Osiris1997 wrote:
Okay, well I posted earlier, and the code works and all, but it doesn't switch from offline to online, even when the key is there.

Please see OP or bold text in the quote above, this will answer the question you posted.
WELL THEN. Sorry for being so ignorant, otherwise I honestly can't see the issue.
Well, part of your problem is you copy and pasted the code I provided before. It wasn't intended as a plug-and-play thing, it requires tweaking.

When I shortend and used the code properly, I got the intended results.
client/New()//When a client connects
..()//run the default behavior of client/New()
if(key in GM1) GM1[key]="<font color=lime>Online</font>"//if client's key is in list1, set their status in list1 to "Online"
client/Del()//Uppon the client disconnecting
if(key in GM1) GM1[key]="<font color=red>Offline</font>"//Check if their key is in list1 and if so, set their status in list1 as "Offline"
..()//run the default behavior of client/Del()
var/list/GM1=list("NNAAAAHH"="Offline")//Make a list of keys relating to who's status you want to view and set their status to "Offline"
var/list/GM2=list("NAAH"="Offline")//Same as before
mob/verb/CheckLists()
usr<<"<font color=lime>System Information</font>: Below contains a list of ingame, and incoded staff members.<br><big><b><font color=green>GM Lv.1</b></big></font>:"
for(var/v in GM1)//run for each key defined in list1
usr<<"--><font color=white>[v]([GM1[v]])"//display the key and the key's status
usr<<"<big><b><font color=blue>Admin</b></big></font>:"//same for list2
for(var/v in GM2)
usr<<"--><font color=white>[v]([GM2[v]])"


In-Project results:
System Information: Below contains a list of ingame, and incoded staff members.
GM Lv.1:
-->NNAAAAHH(Online)
Admin:
-->NAAH(Offline)
In response to El Wookie
El Wookie wrote:
WELL THEN. Sorry for being so ignorant

Quite alright good sir :)
If he's loading his list from a save file, he probably doesn't have the right architecture in his list for your system, this should work just as well and be a lot more plug-n-play.

mob/verb/Who()
var/list/outputWho = new/list()//List to store the players and their status
for(var/mob/M in GM1)//Your list of GMs
outputWho += "[M.key]" //Add them to the list
if(M in world) //If they're in the world currently (might need some tweaking)
outputWho["[M.key]"] = "GM Lv 1 (Online)" //Add them as online
else
outputWho["[M.key]"] = "GM Lv 1 (Offline)" //Otherwise....
for(var/mob/M in GM2)//Your second list of GMs
outputWho += "[M.key]"
if(M in world)
outputWho["[M.key]"] = "GM Lv 2 (Online)"
else
outputWho["[M.key]"] = "GM Lv 2 (Offline)
usr<<"GMs online:"
for(var/v in outputWho)
usr<<"[v] ([outputWho[v]])"
I tried NNAAAAH's, an exact copy/paste, only I replaced his key with my own, and I still came up as Offline. The offline was white, so it was the "Offline" in the list that effected it.
In response to Osiris1997
Check for other traces of client/New() and ensure ..() is being called somewhere in there, that's the only reason I could think of for my example not to work; as I said it worked perfectly for myself. You could put some debugging into the code.

client/New()
..()
world<<"[src].New() as a client has been called. Key connection is [key]."

Having the key variable in there shouldn't be needed, as the name of the cient/mob should by default be the player's key. But just to be safe here, I suggest using it.
In response to El Wookie
Best response
El Wookie wrote:
If he's loading his list from a save file, he probably doesn't have the right architecture in his list for your system, this should work just as well and be a lot more plug-n-play.

Your code is an interesting idea, but it will not work.

//If they're in the world currently (might need some tweaking)

This isn't actually what is happening.
First, you're looping through a list that should contain mobs. Next, you are checking if(M), which is basically saying does M exist.

Doing a check like that is useful at the BEGINNING of the loop, to see if there is a null entry or not. However, it will not work to detect if people are offline.

Once a player logs out, the list entry that formerly contained a /ref to a /mob will now be null, and won't help you at all.


To be able to do the functionality the OP wants, this is what you have to do:

Have one list of online moderators, simple enough, you should be able to handle this yourself. Whenever a moderator logs on, they are added to this list.

Whenever someone in that list logs out, add *THEIR KEY* (or name, if you don't want players to see their key) to a second list, your list of offline moderators. Do NOT try adding their mob, or client, or anything that will disappear when they're offline. (Also, when a moderator logs in, remove them from this list)

When you check who, loop through the online list and show whatever details you want for people who are available.

Then after loop through your offline list and add anyone you want visible as "offline". But your loop at this point will NOT be
for(var/mob/M in LIST), instead it will be for(var/KeyText in LIST), and KeyText will be a string that contains their key (or whatever information you included.)


Of course, it's also possible to just have a list with nothing but their names/keys or whatever, and whether they're online or offline as an associated value (or just a second list with matching indices). But this will restrict your ability to grab information from their mob, in case you had that intention.