Jump to content
McKay Development

How to get xp of user?


lunar

Recommended Posts

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");
    }
    
  });
}

 

Link to comment
Share on other sites

it's the segment after the badges array https://api.steampowered.com/IPlayerService/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
Link to comment
Share on other sites

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