ID:834603
 
(See the best response by Murrawhip.)
Code:
var/players=list()
mob
Login()
players += usr.ckey
winset(world, null, "default.label2.text='[length(players)]'")


Problem description:
The game is supposed to calculate the length of the players on a player's login and winset a certain label's text to such. I am pretty sure that the window ID and the label ID are right.
Yet it remains the same.

var/players=list()
mob
Login()
players += usr.ckey
winset(src, "default.label2", "text=[length(players)]")


Try this. Also, you'll need to set everyone else in the world as an update. Check the skin reference if you get confused.
Hmm, yeah, that worked.
Thanks.
You can't use winset() for the whole word at the same time. You have to do it by client. You'll need to call a proc to update everyone else in the world at the time of a new player logging in or another player logging out. Something like:

proc/updatePlayerLabel()
set background = TRUE
for(var/client/C in world)
winset(C, "default.label2", "text=[length(players)]")


I'm pretty sure you can set it with the use of client here, but again, I haven't tested it.
In response to Yusuke13
Yusuke13 wrote:
    for(var/client/C in world)


You'll need to remove that 'in world'.

In response to Murrawhip
Ah alright thanks.
In response to Yusuke13
Alright, so I did almost the same, but I still get a runtime error. It works though, but I want to clear this error.
{
runtime error: bad client
proc name: Update (/mob/proc/Update)
usr: TheGreatNinja (/mob)
src: OrenTheKing (/mob)
call stack:
OrenTheKing (/mob): Update()
TheGreatNinja (/mob): Logout()
}

This is the logout where the Update() is present.
    Logout()
players -= usr.ckey
for(var/mob/G in world)
if(G != usr)
G.Update()


mob
proc
Update()
winset(src, "default.label2", "text=[length(players)]")

This is the update proc and...
    Login()
players += usr.ckey
for(var/mob/M in world)
M.Update()

This is the login where also Update() is called.
The runtime error occurs but not much, rare. So reproducing it is kind of difficult.

client/Del calls mob/Logout().
So by the time you're calling Update() on the mob that is in the process of logging out, it's already lost its client.
Yeah, I thought of that, so I need to put the Update() proc into the Del() of a client to prevent this error?
Best response
I imagine you could probably prevent the error by checking if the mob has a client in Update().
I am going to go with that. Thanks.