Jump to content
RAGE Multiplayer Community

Recommended Posts

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!

Link to post
Share on other sites

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);

 

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...