ID:261225
 
I want to display all of the people's names in the game, and their inventory. It works, but when somone logs out, their name and inventory stays in the stat panel. What I need is a way to clear all stat panels of information, so that new (accurate) information can be inserted. If there is no way to do that, I would like to submit it as a feature request.

Thanks.
Try using a list and putting that in a statpanel() (for the people playing), then whern someone logs out, simply remove them from the list. The statpanel() updates itself every tick(1/10th of a second)

Alathon
In response to Alathon
Once again, Alathon, you do not know what you are talking about. The Stat() proc is not run every tick. Get your facts right, or you will end up feeding newbs who don't know better false information.

Good day.
In response to Lord of Water
I never said anything about Stat() being run. I simply stated that the statpanels are updated every tick

Lighten up your tone please, theres no need to be nagging on people like that. Its like laughing at someone for spelling a word wrong.

Alathon
In response to Alathon
As I understand things, statpanel() can only be run within a Stat() proc. The Stat() proc is not run every tick, so there is no way that the statpanel() is updated every tick.

Good day.
In response to Lord of Water
Let me repeat it for you, in one small sentance.

The statpanels are refreshed/updated every tick.

Alathon
In response to Lord of Water
For the record, I never said Stat() isnt called every tick, because it is.

Alathon
In response to Alathon
Stat() is -not- called every tick. Let me say it again: Stat() is -not- called every tick. To be exact, it is called every eight ticks. To prove it to yourself, try this:

mob/Stat()
world << world.time


This will show the following:

0
8
16
24
32
40
48
56
64
72
80
and so on...


I'll say it one last time: get your facts right.
In response to Lord of Water
Hmm, I guess the errors on my side then. I seem to recall Tom or Dan saying it was called every tick, I guess not.

Alathon
In response to Lord of Water
Lord of Water wrote:
Once again, Alathon, you do not know what you are talking about. The Stat() proc is not run every tick. Get your facts right, or you will end up feeding newbs who don't know better false information.

Good day.

Considering he just gave you an absolutely correct method, with a fairly irrelevant, minor incorrect piece of data, your tone is pretty rude. The Stat() proc being called every tick has been mentioned a number of times by various people, though it is actually every 8. To be honest, I thought it was every tick as well. The reference says it is updated 'periodically', and I had to dig up a months old Deadron post to find the 8 ticks. Not that fractional second differences make much of a difference in any of my projects, they could in someones. Thanking someone for taking the time to help, while pointing out their mistake will encourage people to help you. Telling people they don't know what they are talking about when they give you a valid answer will not.
In response to Alathon
I'm sorry for the mean tone of my replies... at the time, I was frusterated with newbies who said that they had been helped by other people before, and told me what those other people had said. Those newbies had some wrong information that they claimed came from other people who had helped them. I will not say any names, but I would just like people to spend more time when dealing with newbs who have little chance of correcting errors in code that you give them.

Apart from that scene, does anyone have an exact answer to my question?

if("yes")
world << "Tell LoW how to clear his statpanels"
if( "no")
dantom << "Please create a way to clear stat panels.
world << "Thank you!"
In response to Lord of Water
What I posted earlier still works, and should be rather simple to implement.


var/list/Current_Players = list()
world/New()
..()
Current_Players = new()

mob/Logout()
Current_Players -= src
..()

mob/Stat()
statpanel("Playing",Current_Players)


Alathon
In response to Alathon
Yes, I could easily do that. However, I need more:

I have a code somewhat like this:

mob/GM/Stat()
for(var/mob/Player/M in world)
stat("[M.name] ([M.key])")
stat(M.contents)
stat(M.location)
// and so on

So, I need more then just a list of players, which is why one simple list won't fit the bill. Thanks for trying to help, though! :) hehe
In response to Lord of Water
If you are doing it like that, I dont see a reason the information would stay. Once the for() loop repeats and is updated it will disappear?

Alathon
In response to Lord of Water
Lord of Water wrote:
Yes, I could easily do that. However, I need more:

I have a code somewhat like this:

mob/GM/Stat()
for(var/mob/Player/M in world)
stat("[M.name] ([M.key])")
stat(M.contents)
stat(M.location)
// and so on

So, I need more then just a list of players, which is why one simple list won't fit the bill. Thanks for trying to help, though! :) hehe

Sure it will.

Expanding a bit on Alathon's code:
var/list/Current_Players = list()
world/New()
..()
Current_Players = new()

mob/Login()
Current_Players += src
..()

mob/Logout()
Current_Players -= src
..()

mob/GM/Stat()
for(var/mob/Player/M in <font color=#ffffa0>Current_Players</font>)
stat("[M.name] ([M.key])")
stat(M.contents)
stat(M.location)
// and so on

In response to Shadowdarke
Or yet another way: I'm assuming you don't delete mobs upon logout, which is why you have a problem with your current code. You only want to stat players who are connected, right? Just check mob.client and only stat those with a client:

mob/GM/Stat()
for(var/mob/Player/M in world)
if (M.client)
stat("[M.name] ([M.key])")
stat(M.contents)
stat(M.location)
// and so on
In response to Air Mapster
Ah, that may be my problem! I don't think I'm deleting my mobs on logout... thanks.