1
2
ID:174078
Oct 4 2003, 5:16 am
|
|
How do I make a statpanel that has list of those online?
|
In response to Loduwijk
|
|
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. |
In response to Blueseed15
|
|
statpanel("Online")
for(var/mob/M in world) if(M.client) stat(M) make sure its tab instead of spaces before it |
In response to ZDarkGoku
|
|
I think it might work now, no more errors... but I can't check until I get a couple things fixed for sheet creation...
|
In response to Blueseed15
|
|
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.
|
In response to Goku72
|
|
lag I don't think will be too much of a problem as this is going to be a text game
|
In response to Blueseed15
|
|
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
|
In response to FranquiBoy
|
|
FranquiBoy wrote:
Instead of in other words, remove the if() part. |
In response to ZDarkGoku
|
|
ZDarkGoku wrote:
in other words, remove the if() part. Not quite. In other words, loop through clients instead of mobs and remove the if(). |
In response to Blueseed15
|
|
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. =) |
In response to Crispy
|
|
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!!!
|
In response to FranquiBoy
|
|
I was talking to DarkGoku, I assume you were too. =)
|
In response to Crispy
|
|
for(var/client/C in world)
Stat(C) that shows the NPC's in the online list too. |
In response to Crispy
|
|
Please demonstrate when you get a chance to.
|
In response to ZDarkGoku
|
|
It shouldn't. That goes through only clients, and NPCs don't have clients. Which means only PCs would be shown in the panel.
|
In response to Blueseed15
|
|
Umm... Crispy or someone else, please demonstrate the code.
|
In response to Blueseed15
|
|
Hello? someone please explain how to do what Crispy was talking about
|
1
2
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.