lunar Posted November 23, 2018 Report Posted November 23, 2018 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"); } });} Quote
Dr. McKay Posted November 25, 2018 Report Posted November 25, 2018 I believe the only way to do that is to use the WebAPI. lunar 1 Quote
lunar Posted November 25, 2018 Author Report Posted November 25, 2018 thanks, i'll have a look into it through that. Quote
lunar Posted November 25, 2018 Author Report Posted November 25, 2018 (edited) 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 November 25, 2018 by lunar Quote
Aeossa Posted November 25, 2018 Report Posted November 25, 2018 If you somehow implement it in the code, could you send here how please? Quote
lunar Posted November 25, 2018 Author Report Posted November 25, 2018 (edited) 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 valueand I get a internal server error edit: Ended up using seishun's node-steam-web-api for it as it worked first try. Edited November 25, 2018 by lunar 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.