Jump to content


Photo
Question

How to get xp of user?

node.js node-steam-user

  • Please log in to reply
5 replies to this topic

#1 lunar

lunar

    Member

  • Member
  • PipPip
  • 10 posts

Posted 23 November 2018 - 08:14 AM

i am trying to get the current xp of a user and the xp required to achieve a level but i don't know how to see how much xp they currently have? is there something built into steam-user or should i use another module?

here is my code for the command


function level(steamID, level){
  client.getSteamLevels([steamID], function(results){
    console.log("level: " + results[steamID] + "xp: " + results[steamID].xp); // just gives me undefined for the result for xp
    if(level === undefined){
      level = results[steamID];
    }

    if(level >= results[steamID]){
      client.chatMessage(steamID, "You would need " + /*xp required here*/ + "more xp for level " + level);
    }
    else{
      client.chatMessage(steamID, "Please enter a higher number");
    }
    
  });
}

 



#2 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 1,817 posts

Posted 24 November 2018 - 11:54 PM

I believe the only way to do that is to use the WebAPI.


  • lunar likes this

#3 lunar

lunar

    Member

  • Member
  • PipPip
  • 10 posts

Posted 25 November 2018 - 04:17 AM

thanks, i'll have a look into it through that.



#4 lunar

lunar

    Member

  • Member
  • PipPip
  • 10 posts

Posted 25 November 2018 - 04:27 AM

it's the segment after the badges array https://api.steampow...e/GetBadges/v1/

{"response":{"badges":[{badges go in here}],"player_xp":xp here,"player_level": level,"player_xp_needed_to_level_up":xp needed for next level,"player_xp_needed_current_level":xp needed for current level}

Edited by lunar, 25 November 2018 - 04:28 AM.


#5 Aeossa

Aeossa

    Newbie

  • Member
  • Pip
  • 2 posts

Posted 25 November 2018 - 04:39 AM

If you somehow implement it in the code, could you send here how please?



#6 lunar

lunar

    Member

  • Member
  • PipPip
  • 10 posts

Posted 25 November 2018 - 05:15 AM

I'm having trouble getting the element from the json in the response. 
do I get the element I want via response.elementIWantHere or response[elementIWantHere]?

as I have tried both and neither work.

This is my code so far.

 

api.get("IPlayerService", "GetBadges", 1, steamid=steamID, function(err, response){
                if(err){
                    console.log(err);
                }
                console.log("level: " + results[steamID] + " xp: " + response.player_xp);
                client.chatMessage(steamID, "You have " + response.player_xp + " xp and are level " + level);
            });

Response currently just gives me undefined as the value

and I get a internal server error

 

edit: Ended up using seishun's node-steam-web-api for it as it worked first try.


Edited by lunar, 25 November 2018 - 09:53 AM.






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

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users