ID:174078
![]() Oct 4 2003, 5:16 am
|
|
How do I make a statpanel that has list of those online?
|
statpanel("Online")
for(var/mob/M in world) if(M.client) stat(M) Variables.dm:22:error:M.client:undefined var Variables.dm:23:error:M:undefined var Variables.dm:22:if :warning: if statement has no effect statpanel("Online") for(var/mob/M in world) if(M.client) stat(M) Variables.dm:22: Inconsistent indentation. Variables.dm:23: Inconsistent indentation. |
statpanel("Online")
for(var/mob/M in world) if(M.client) stat(M) make sure its tab instead of spaces before it |
I think it might work now, no more errors... but I can't check until I get a couple things fixed for sheet creation...
|
Probably not a good thing to use a for() in a stat panel. It'd cause some lag. I'd suggest making a list and add and remove players from it when they login/logout.
|
Instead of
for(var/mob/M in world) if(M.client) Stat(M) could one use for(var/client/C in world) Stat(C) |
<code>mob/Stat() statpanel("Who") for(var/mob/M in world) if(M.client) stat(M)</code>
That's the lagerrific way. |
OK, question that kind of goes along with this... how would I make the who list thing be a drop-down menu in the stat bar, meaning I click an icon, and it shows the people, and click in again, they disappear... I searched for this, but could only find subscription demos
|
FranquiBoy wrote:
Instead of in other words, remove the if() part. |
ZDarkGoku wrote:
in other words, remove the if() part. Not quite. In other words, loop through clients instead of mobs and remove the if(). |
If you want an obj in a statpanel that does this, you can just create the obj and place it at null (don't do this in Stat(), or your game will become lag-eriffic). Then use stat(theobjvar) to display the obj. In the obj's Click() proc, toggle a var belonging to usr. In Stat(), only display the statpanel if that var is toggled to true.
I would demonstrate, but I'm in a hurry. =) |
Theres that... But I use client instead of mob because there far fewer clients then mobs. Fewers loops, fewer operations. Few operations, less CPU usage. Less CPU usage, less lag!!!
|
It shouldn't. That goes through only clients, and NPCs don't have clients. Which means only PCs would be shown in the panel.
|
Stat is just like any other procedure in the sense that you can have code blocks doing this, that or the other. Just make a statpanel with the line: statpanel("Players"), then run a loop through all the mobs in the world and check to see if they have a client attached. The only difference from your average who verb is that instead of outputting the findings directly to the player, you put it into the statpanel with the stat proc.
example:
There could be a problem with that, though, if you have any code that happens when mobs are clicked. If you do, players will be able to click them from anywhere else in the world. (This becomes a problem if you do something such as clicking on something to shoot it.) To fix that, just use stat(M.name) instead of the above line.