Jump to content
McKay Development

Client.users after the bot fully connected?


Silentz0r

Recommended Posts

Hi, quick question.

 

i'm trying to display my current online friends with persona_state >= 1 in the console for debugging at the moment to do some stuffs with it. If i check for them in:

client.on('user', function(steamID, user) {
    console.log(_.size(client.users));
});

with this code i get the size of the array that is my number of "friends" i can filter only online friends with persona_state cool. But the thing is i get in the console repeated messages displaying the users count. I understand this event is updated when something changes according to the documentation.

 

 

 

user
  • sid - A SteamID object for the user whose data we just received
  • user - An object containing the user's persona data

v1.9.0 or later is required to use this event

This is an ID event.

Emitted when Steam sends us persona information about a user. The users property isn't yet updated when this is emitted, so you can compare to see what changed.

 

That's why my code is emitting this value as this gets updated and doing something like this:

 

 

1

2

3

....

n

 

My question is, how can i check this when my bot fully updated the friends states not duplicating the message? i did it outside the event and my bot yells "0" when is launching. i'm fairly new at coding and picked this as a project for fun. 

 

Thank you. Sorry for my english, not my native language. 

Link to comment
Share on other sites

I know this isn't javascript support but just out of courisity u changed this:

self.getPersonas(friends, function() {
 +			process.nextTick(function() {
 +				self.emit('friendPersonasLoaded');
 +			});
 +		});

what process.nexttick does in this function? If i have to guess, calls another function at the end of the getPersonas and outputs FriendPersonasLoaded, correct?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...