ID:145351
 
Code:
mob/verb
Who()
usr << "Players online:"
for(var/mob/M in world)
if(M.key==null||M.client==null||M.key in Admins||M.ckey in Admins||\
M.key in MGMs||M.ckey in MGMs)
return 0
usr << "[M.name] (Key: [M.key])"
usr << "Admins online:"
for(var/mob/M in world)
if(M.key==null||M.client==null||M.key in MGMs||M.ckey in MGMs||\
!Admins.Find("[usr.key]")||!Admins.Find("[usr.ckey]"))
return 0
usr << "[M.name] (Key: [M.key])"
usr << "MGMs online:"
for(var/mob/M in world)
if(M.key==null||M.client==null||M.key in Admins||M.ckey in Admins||\
!MGMs.Find("[usr.ckey]")||!MGMs.Find("[usr.ckey]"))
return 0
usr << "[M.name] (Key: [M.key])"


Problem description:

Is there a reason why this isn't working? It's supposed to only show players/Admins/MGMs in their respective places, but it shows every mob in the world in all three places.
Instead of return 0, use continue.
Nope...Still doesn't work.
mob/verb/who()
usr<<"players online:"
for(var/mob/m in world)
if(m.client&&!m.key in Admins&&!m.key in MGMs))
usr<<"[m.name] - [m.key]"
usr<<"Admins online:"
for(var/mob/m in world)
if(m.client&&m.key in Admins&&!m.key in MGMs))
usr<<"[m.name] - [m.key]"
usr<<"MGMs online:"
for(var/mob/m in world)
if(m.client&&!m.key in Admins&&m.key in MGMs))
usr<<"[m.name] - [m.key]"


Try that. Should work.
In response to Crzylme
Better, loop through clients.

var/list/players=list()
var/list/gms=list()
var/list/mgms=list()
for(var/client/c)
if(c.IsGm()) gms+=c.mob
else if(c.IsMgm()) mgms+=c.mob
else players+=c.mob
usr << "Players:"
for(var/mob/m in players) usr << m
usr << "GMs"
for(var/mob/m in gms) usr << m
usr << "MGMs"
for(var/mob/m in mgms) usr << m


Alter to fit your tastes.
In response to Jp
I tryed this:
mob/verb
Who()
usr << "Players online:"
for(var/client/M in world)
if(M.key!=null && !M.key in Admins && !M.ckey in Admins && \
!M.key in MGMs && !M.ckey in MGMs)
usr << "[M.mob.name] (Key: [M.key])"
usr << "Admins online:"
for(var/client/M in world)
if(M.key!=null && !M.key in MGMs && !M.ckey in MGMs && \
M.key in Admins && M.ckey in Admins)
usr << "[M.mob.name] (Key: [M.key])"
usr << "MGMs online:"
for(var/client/M in world)
if(M.key!=null && !M.key in Admins && !M.ckey in Admins && \
M.key in MGMs && M.ckey in MGMs)
usr << "[M.mob.name] (Key: [M.key])"


But it didn't work. Now it doesn't show anyone. Also, this:

mob/verb
Who()
var/list/Players = list(null)
var/list/MGMS = list(null)
var/list/AGMs = list(null)
for(var/client/M in world)
if(M.key in Admins || M.ckey in Admins)
AGMs += M.mob
if(M.key in MGMs || M.ckey in MGMs)
MGMS += M.mob
Players += M.mob
usr << "Players online:"
for(var/mob/M in Players)
usr << "[M.name] (Key: [M.key])"
usr << "Admins online:"
for(var/mob/M in AGMs)
usr << "[M.name] (Key: [M.key])"
usr << "MGMs online:"
for(var/mob/M in MGMS)
usr << "[M.name] (Key: [M.key])"


Gave me the same result. it doesn't show anyone.
In response to KirbyRules
'in' is low in the order of operations. Basically, it is looking for null in those lists. Try this:

            if(M.key!=null && !(M.key in Admins) && !(M.ckey in Admins) && \
!(M.key in MGMs) && !(M.ckey in MGM)


And just fix it for the rest of them.
In response to Justin B
    Who()
usr << "Players online:"
for(var/client/M in world)
if(M.key!=null)
usr << "[M.mob.name] (Key: [M.key])"
usr << "Admins online:"
for(var/client/M in world)
if(M.key!=null && !(M.key in MGMs) && !(M.ckey in MGMs) && \
M.key in Admins && M.ckey in Admins)
usr << "[M.mob.name] (Key: [M.key])"
usr << "MGMs online:"
for(var/client/M in world)
if(M.key!=null && !(M.key in Admins) && !(M.ckey in Admins) && \
M.key in MGMs && M.ckey in MGMs)
usr << "[M.mob.name] (Key: [M.key])"


It's still doing the same thing. Am I doing this the wrong way?
In response to KirbyRules
instead of M.key!=null just chekc for M.key. Also, if there is a client, there will be a key, so that is pointless.
In response to Justin B
mob/verb
Who()
usr << "Players online:"
for(var/client/M in world)
usr << "[M.mob.name] (Key: [M.key])"
usr << "Admins online:"
for(var/client/M in world)
if(!(M.key in MGMs) && !(M.ckey in MGMs) && M.key in Admins && M.ckey in Admins)
usr << "[M.mob.name] (Key: [M.key])"
usr << "MGMs online:"
for(var/client/M in world)
if(!(M.key in Admins) && !(M.ckey in Admins) && M.key in MGMs && M.ckey in MGMs)
usr << "[M.mob.name] (Key: [M.key])"


Still doesn't work. I'm really getting PO that I can't find the error.
In response to KirbyRules
mob/verb
Who()
usr << "Players online:"
for(var/mob/player/M in world)
usr << "[M.name] (Key: [M.key])"
usr << "Admins online:"
for(var/mob/player/M in world)
if(!(M.key in MGMs) && !(M.ckey in MGMs) && M.key in Admins && M.ckey in Admins)
usr << "[M.name] (Key: [M.key])"
usr << "MGMs online:"
for(var/mob/player/M in world)
if(!(M.key in Admins) && !(M.ckey in Admins) && M.key in MGMs && M.ckey in MGMs)
usr << "[M.name] (Key: [M.key])"


Replace /mob/player with your sub-type player class.