MrKirby Posted January 16, 2017 Report Posted January 16, 2017 Hey, I started using Node.js and javascript a short time ago. I was trying to display my own username in console after logon. And if that worked, I'd try for others.I was hoping if you could help me. This is my code: client.on('loggedOn', function() { console.log("[Steam-BOT] Logged in as " + client.steamID); var botSteamID = [client.steamID]; var clientName = client.getPersonas(botSteamID); }); So I thought this was the way to go but, clientName stays unidentified. I do not know what I am doing wrong Thanks in advance! Quote
Dr. McKay Posted January 16, 2017 Report Posted January 16, 2017 Please read about asynchronous JavaScript and callbacks. getPersonas does not return anything useful, you need to provide a callback and wait for the response there. Quote
MrKirby Posted January 18, 2017 Author Report Posted January 18, 2017 (edited) After some time having trouble with it (as I am new), I got it to work! Thanks so much dude! for everyone else wondering.. I used this: client.on('friendMessage', function(steamID, message) { friendID = [steamID]; client.getPersonas(friendID, function(getName) { var x = getName[friendID]; var friendName = x.player_name; console.log("[FriendlyMessage] " + friendName + ": " + message); } }); Brackets could be wrong because my code didn't stop there and I am correcting it within the text editor I do have another question and I don't know if I should ask it here?But, what are the numbers for friendrelationships??I know 2 is friend request send to me. But where can I find it.. because I am having trouble finding everything... EDIT: After actually turning my brain on.. I checked within the files of your node and found a file with the numbers.... Shit I'm stupid... Thanks anyway!! GREAT SHIT DUDE!!! Edited January 18, 2017 by MrKirby Dr. McKay 1 Quote
Dr. McKay Posted January 18, 2017 Report Posted January 18, 2017 After actually turning my brain on.. Far more people need to do this... 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.