Jump to content
McKay Development

[HELP] Problems with GetPersonas - It gives me "NaN" instead of desired output


TheGoldenPotato

Recommended Posts

Hello, I am trying to make my bot say people's names, and then a welcome message. But currently with the code that I got, it only says "NaN Hello, I am a generous Trading Bot, I would love to trade with you, but I am currently in maintenance mode. Check back later.". I do not know why it says NaN, instead of the user's name. My current code looks like this

 

client.on("friendRelationship", (SENDER, REL) => {
    client.getPersonas([client.steamID], (personas) => {
    if (REL === 2) {
        client.addFriend(SENDER);
    } else if (REL === 3) {
        if (CONFIG.INVITETOGROUPID) {
            client.inviteToGroup(SENDER, CONFIG.INVITETOGROUPID);
        }
        client.chatMessage(SENDER, + personas + CONFIG.MESSAGES.WELCOME);
    }
	});
});

 

 

Edited by TheGoldenPotato
Link to comment
Share on other sites

Because you want to get their data you should do client.getPersonas([sENDER]), client.steamID is your own steamID. The other thing is that  personas  is an object, not just their names because it getPersonas can handle multiple steamIDs. I don't remember how the object is exactly setup.

 

This should help in more detail:

https://dev.doctormckay.com/topic/660-how-to-go-from-steam64-to-steam-username-the-name-currently-used-on-steam/ 

Link to comment
Share on other sites

Because you want to get their data you should do client.getPersonas([sENDER]), client.steamID is your own steamID. The other thing is that  personas  is an object, not just their names because it getPersonas can handle multiple steamIDs. I don't remember how the object is exactly setup.

 

This should help in more detail:

https://dev.doctormckay.com/topic/660-how-to-go-from-steam64-to-steam-username-the-name-currently-used-on-steam/ 

 

But when I tried the solution which was posted in that thread, it still says NaN in the message. My code looks like this now.

 

 

client.on("friendRelationship", (SENDER, REL) => {
	client.getPersonas([SENDER], function(personas) {
	var persona = personas[SENDER.getSteamID64];
	var name = persona ? persona.player_name : ("[" + SENDER.getSteamID64 + "]");
	if (REL === 2) {
        client.addFriend(SENDER);
    } else if (REL === 3) {
        if (CONFIG.INVITETOGROUPID) {
            client.inviteToGroup(SENDER, CONFIG.INVITETOGROUPID);
        }
        client.chatMessage(SENDER, + name + CONFIG.MESSAGES.WELCOME);
    }
	});
});
Edited by TheGoldenPotato
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...