I want to be able to give a user a random ID that does not match anyone else's that's on the server.I'm using this for a random ID:function getID() { var number = Math.floor((Math.random() * 10000) + 1); return number; }I need to add a function that will detect that if the ID of a player in: [{id: id, leaderName: username, score: score, defeats: defeats}] (using players.push method to add a new set of variables to the array for each player) this array, but I'm stuck at my for loop:for (var i = 0; i < players.length; i++) { if(players[i].id === ) }I don't know what to put to make it test if the id is equal to any other on the server. What can I put to test all the players[i].id, and fix the id is not defined issues?
Submitted November 25, 2017 at 09:28PM by Akidus
No comments:
Post a Comment