ID:264298
 
Code:
var/list/Logging = list()

client/New()
..()
Logging.Add(src)

mob/Player/verb
Who()
for(var/mob/Player/P in Logging)
usr<<"<font size=1>[P] - Logging..." //Does not display the text string. Why?
var/Count = Logging.len
usr<<"<font size=1>[Count] player\s found</font>" //This is displayed alright however. So why won't the one in the for() loop get outputted?


Problem description:
Notated in snippet
Because Logging contains clients and not mobs.
In response to Andre-g1
Doh! >.< Into the mob/Login() proc it goes then >_>
In response to Mizukouken Ketsu
Just make sure you remember to also correspondingly remove the players from the list, this is even more important if you add them in Login(). <_<
This should help with your little problem. You might need to edit it a bit.
In response to Yash 69
mob/verb/Who()
. = list()
world << "Players online:"
for(var/mob/M) if(M.client)
world << M
. += M
world << "[length(.)] [length(.)>1? "players" : "player"] online!"


Mine is totally cooler <.< it shows the players icon :p
In response to Andre-g1
Lol.
In response to Andre-g1
Why abuse the . var like that? Sure, you can use it for whatever, but you should conform to sticking to use it for return values, and not use it arbitrarily (you can't define its value which also limits you), are you so lazy you don't want to declare a new var? :P
Also, you can do a number of things to optimize that. Rather than looping through all mobs (which there are many of) and then check if they have clients, loop through all clients (which there are fewer of), then just display their mob (checking isn't even required because a client should mostly never exist without a mob). Using the len var (by using a proper list-defined var >_>) would also be more efficient than calling length() (multiple times even), but you don't need a list there at all, so I've no idea why you used one in the first place. That's a roundabout method of counting. <_<

Lastly, you'll probably want more information like the key, gender and as such, and it also floods everybody every time a random person runs the verb. >_>
In response to Kaioken
I thought using the . variable was better than defining a new one.

Also, I thought ..len wouldn't work, and if it would, it'd be kind of dumb and annoying to use, that's why I used length().
In response to Andre-g1
Andre-g1 wrote:
I thought using the . variable was better than defining a new one.

I don't see anything wrong with using . as a variable, I do so myself some places. But its not 'better' in the sense that you're never, ever going to notice allocating space for 1 variable less.
In response to Alathon
Ah, so there's nothing wrong or good about using the . variable ?
In response to Andre-g1
Andre-g1 wrote:
Ah, so there's nothing wrong or good about using the . variable ?

There's times where you want to use the . variable for the ability to set the return value of a proc before actually returning.

At some point in a procedure, you might know what value you want to return, but you still have more stuff to do. In a case like that you could use a temporary variable to store the return value, then eventually, return tempvar. Or you could avoid creating a useless variable and just set the value of .
In response to Yash 69
I did not ask how to make a "who" verb >_> I simple asked why MY snippet wasn't working properly. Turned out, it was just a simple client/mob misunderstanding. Thanks anyways, even though I did not need/want it.