ID:1027255
 
(See the best response by NNAAAAHH.)
Problem description:

Well, there are a few forms of staff in this game I work for. The RPM Team(Levels 1 and 2), The GM Team(Levels 1 and 2), The Board Executives, And The Partners.

Currently, the View Online Staff verb works as simple, if a staff member is online, it'll say "Osiris(GM1)" but if they're not on, they won't show up at all. I want a code that straight up lists it all out. Like..

GM Lv. 1

Osiris(Online)
Marko999(Offline)

GM Lv. 2

Kia_2fly(Online)

If you get what I mean?

I think it has something to do with lists, I just have no clue how to even begin.
So you just want it sorted or you're wanting every gm to appear with an online status next to it?

ex:

GM Lv. 1

Osiris (Offline)
Marko999 (Online)
Best response
You're right on that you'll have to use list.

You could do something along the lines of
var/list/list1=list("Key1"="Offline","Key2"="Offline")//Make a list of keys relating to who's status you want to view and set their status to "Offline"
var/list/list2=list("Key3"="Offline")//Same as before
client/New()//When a client connects
..()//run the default behavior of client/New()
if(key in list1) list1[key]="Online"//if client's key is in list1, set their status in list1 to "Online"
if(key in list2) list2[key]="Online"//Same for list2
client/Del()//Uppon the client disconnecting
if(key in list1) list1[key]="Offline"//Check if their key is in list1 and if so, set their status in list1 as "Offline"
if(key in list2) list2[key]="Offline"
..()//run the default behavior of client/Del()
mob/verb/CheckLists()
usr<<"List 1:"
for(var/v in list1)//run for each key defined in list1
usr<<"[v]([list1[v]])"//display the key and the key's status
usr<<"List 2:"//same for list2
for(var/v in list2)
usr<<"[v]([list2[v]])"
How do I add names to that list?? Like, could you add some //'s? I really don't understand it all too well. :(
In response to Osiris1997
I added comments right after posting, I realized that it might not have been easy to read.

To add names to the list, as in more keys while in-game or the names of the mobs attached to the key?
Well keys. Like, I don't want to have to change the code every time there are firings and hiring, because the lower levels(GM/RPM) are not coded in. Instead, there is a Grant GM and Grant RPM Verb that the higher levels have. Like, when someone is hired, I need a code to add them to their respective list, or fired, taken off.
In response to Osiris1997
You could use list operators to get the effect you're asking;
http://www.byond.com/docs/ref/info.html#/list/operators

.Add() and .Remove() or += and -= should do you fine.
Bah. I've looked in the list thing. I thought it'd be something simple. I need like a var/list/list1+=usr.key. I thought that'd work. It didn't XD
In response to Osiris1997
var/list/list1=list("Key1"="Offline")//This is just a re-hash from before
mob/verb/AddKey()//just an example of how to add the key into the list
if(!list1.Find(key)) list1.Add("[key]"="Online")//If the src's key isn't already in the list, add it to the list with the assigned status.
runtime error: illegal use of list2args() or named parameters
proc name: AddKey (/mob/verb/AddKey)
usr: Osiris1997 (/mob)
src: Osiris1997 (/mob)
call stack:
Osiris1997 (/mob): AddKey()
In response to Osiris1997
Yeah, .Add() isn't meant for this, just had high hopes I guess.

mob/verb/AddKey()
if(!list1[key]) list1[key]="Online"
mob/verb/RemoveKey()
if(list1[key]) list1-=key


Not sure how to comment that.
In response to NNAAAAHH
The DM reference clarifies that when you associate a key in the list to something, it is automatically added to the list. Also, you can check if a key's in the list by checking it's associated value, since both "offline" and "online" are true values. If a key's not in the list, you get null.
In response to Kaiochao
My bad, been awhile since I touched on this stuff.
Why not just keep a global list of admins? This prevents creating a new list every time someone wants to see..

var/list/Admins = new/list()

proc/check_admins()
var/FileName = "Admins.sav"
var/savefile/A = new(FileName)
for(var/x in A.dir) // loop through the directories, if you save each admin entry as a new directory
Admins += A.dir[x] // Add the current position to the Admins list, assuming this is their key

mob/verb/Staff_Online()
for(var/x in Admins)
src << Admins[x]


Of course, that doesn't order them by category nor does it detect whether they're online or not, I'll leave that out. All you have to do is save their admin type in the admin file, and then you can handle it in the Admins list.

As far as the online/offline thing goes, simply loop through all the clients and check for the key.

Hope I helped~