Sirmittens Posted May 17, 2020 Posted May 17, 2020 hey, i am fairly new to this and was wondering how do i change a car. This is what i have so far mp.events.addCommand("vehcol", (player, fullText, colorpick1, colorpick2) => { if (colorpick1 == undefined) { colorpick1 = 111; } else { if (colorpick2 == undefined) { colorpick2 = 88; } else { let playercar = player.vehicle playercar.setColor(colorpick1, colorpick2); } } }); I found this works just fine if i insert the actual numbers into playercar.setColor(111, 88); however i would prefer it to work with the variables. Sorry for the terrible code, still new thanks!
Sirmittens Posted May 17, 2020 Author Posted May 17, 2020 okay after a few hours of messing with it i figured it out. encase anyone has this issue in the future. so when you input the command it is treated as a string not an int. so typically unless you convert it it will not work. I used Number() to do just that. here is the code mp.events.addCommand("vehcol", (player, fullText, colorpick1, colorpick2) => { if (colorpick1 == undefined) colorpick1 = 0 if (colorpick2 == undefined) colorpick2 = 0 let colorselect1 = Number(colorpick1); let colorselect2 = Number(colorpick2); let playervehicle = player.vehicle playervehicle.setColor(colorselect1, colorselect2);
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