Jump to content


Photo
Question

How to get your own name in console (and other users (optional))

node.js node-steam-user

  • Please log in to reply
3 replies to this topic

#1 MrKirby

MrKirby

    Newbie

  • Member
  • Pip
  • 4 posts

Posted 16 January 2017 - 01:51 PM

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!



#2 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 1,997 posts

Posted 16 January 2017 - 02:45 PM

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.



#3 MrKirby

MrKirby

    Newbie

  • Member
  • Pip
  • 4 posts

Posted 18 January 2017 - 03:38 PM

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...  :mellow:  :mellow:

 

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 by MrKirby, 18 January 2017 - 03:41 PM.

  • Dr. McKay likes this

#4 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 1,997 posts

Posted 18 January 2017 - 03:55 PM

After actually turning my brain on..

 

Far more people need to do this...







Also tagged with one or more of these keywords: Question, node.js, node-steam-user

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users