Freamee Posted October 21, 2019 Share Posted October 21, 2019 Hi. I created a trunk with variables. But when im trying to add items in it. Its not overwriting the value, its adds next to the value. like /put 45 --> 45, then /put 35, and the variable is 4535. Any idea? Link to comment Share on other sites More sharing options...
trolovecro Posted October 21, 2019 Share Posted October 21, 2019 in javascript "2" + "2" = 22 and 2 + 2 = 4. try convert it to integer. Link to comment Share on other sites More sharing options...
Freamee Posted October 21, 2019 Author Share Posted October 21, 2019 i can not make it work. Can you help ? if(param2 == "mati" || param2 == "material") { if(!player.hasItemInInventory('Alkatrész')) return player.pushError("Nincs nálad egy darab alkatrész sem!"); parseInt(darab); if(darab == undefined) return player.pushExample("/(k)o(cs)i bepakol mati [darabszám]"); if(darab <= 0 || darab > 100000) return player.pushError("1 és 100.000 között adj meg darabszámot!"); if(darab > p_mennyimati) return player.pushError(`Nincs ennyi alkatrészed. Nálad található: ${p_mennyimati}`); //if(osszeadas > KOCSI_MAX_MATERIAL) return player.pushError(`Nem fér ennyi a kocsiba. Maradék hely: ${KOCSI_MAX_MATERIAL-mennyim}`) player.pushSiker(`Beraktál a kocsiba ${darab}db. alkatrészt.`); ez = mennyim + darab; if(id.getVariable('Material') == 0) id.setVariable("Material", darab); else { id.setVariable('Material', ez); } } Link to comment Share on other sites More sharing options...
trolovecro Posted October 21, 2019 Share Posted October 21, 2019 Best way to handle with your errors is to log everything that dont work just like you want. try log console.log( mennyim + darab ); to see the results. Link to comment Share on other sites More sharing options...
Freamee Posted October 21, 2019 Author Share Posted October 21, 2019 console logs: 05 /put 5 55 /put 5 again 5545 /put 45 nothing Link to comment Share on other sites More sharing options...
Freamee Posted October 21, 2019 Author Share Posted October 21, 2019 I found the error, thanks by the way. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now