Silentz0r Posted September 20, 2017 Report Posted September 20, 2017 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. usersid - A SteamID object for the user whose data we just receiveduser - An object containing the user's persona datav1.9.0 or later is required to use this eventThis 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: 123....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. Quote
Dr. McKay Posted September 20, 2017 Report Posted September 20, 2017 This is probably a pretty common case that should be supported natively in the module. Update steam-user to v3.22.0 then use the friendPersonasLoaded event. Quote
Silentz0r Posted September 20, 2017 Author Report Posted September 20, 2017 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? Quote
Dr. McKay Posted September 20, 2017 Report Posted September 20, 2017 Notice in the documentation that the users property isn't updated until after the user event finishes? The process.nextTick call waits until the next tick of the Node.js event loop, after the users property has been updated. Silentz0r 1 Quote
Silentz0r Posted September 20, 2017 Author Report Posted September 20, 2017 Oh i see, thank you Doc! Quote
Recommended Posts
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.