0xNull 0 Posted March 10, 2018 I have such code: var countplayers=0; var launch=0; mp.events.add('playerJoin', (player) => { player.robber = 0; player.ingame = 0; player.hello = 0; }); mp.events.addCommand('chase', (player) => { if (countplayers == 0){ if (player.ingame== 0 && launch == 0){ player.robber = 1; player.ingame = 1; countplayers +=1; setTimeout(startmp, 10000); }} else { if (launch == 0 && player.ingame == 0){ player.hello = 1; player.ingame =1; console.log(player.hello); } } function startmp(){ console.log(player.hello); launch = 1; } }); Befor function "startmp" - variable player.hello = 1. After - for some reason - variable player.hello = 0. Why? Though variable player.robber = 1 Share this post Link to post Share on other sites
mickmelon 0 Posted March 10, 2018 This code is a bit mental, perhaps you could have given more information on what it's supposed to do. What are you trying to achieve here. It doesn't look like the code ever gets to the point where it sets player.hello to 1? In command chase, it checks if countplayers is 0. If it is (it is in this case) then check if player.ingame and launch are both 0. If they are (they are in this case) then set player.robber and player.ingame to 1 and increase the count players by one. THen call startmp function, which displays player.hello (current value would be 0) then sets launch to 1. After this, the code would never get to the part where it sets player.hello to 1 because launch does not equal 0 in this bit: else { if (launch == 0 && player.ingame == 0){ player.hello = 1; player.ingame = 1; console.log(player.hello); } } Not entirely sure how this is supposed to work lol Share this post Link to post Share on other sites
Xabi 143 Posted March 10, 2018 You're defining the function inside the command, not sure how that will work. Share this post Link to post Share on other sites