How to spawn a vehicle with specific colors

Greetings guys,

I’ve tried to spawn a vehicle with speicific colors serval times using the "setvehiclecolors"function, the car spawned alright, but the colors are still random always, could anyone please tell me what am I doing wrong? Thx!

VEHICLE::SET_VEHICLE_CUSTOM_PRIMARY_COLOUR
Hashes: 0x7141766F91D15BEA 0x8DF9F9BC

Snippet

 vehicle = CreateVehicle(....)
 SetVehicleCustomPrimaryColour(vehicle, 255, 0, 0)

1 Like

Big Big Thx man!

Btw, could you please tell me how do I get the colour of the current vehicle?
Is it by using
"GET_VEHICLE_CUSTOM_PRIMARY_COLOUR(Vehicle vehicle, int *r, int *g, int *b) "
or
`"GET_IS_VEHICLE_PRIMARY_COLOUR_CUSTOM(Vehicle vehicle) "`` ?

If so, how do I get the returned parameters? Thx again!

I hope this works but didn’t test it, so can you please verify and let us know if it works for you?
This way other people can also find the solution here in the future :wink:

local color = GetIsVehiclePrimaryColourCustom(vehicle)
color['x'], color['y'], color['z']
2 Likes

Sure thing! Thx man! I’ll test it out once I return home from work, and I’ll let everyone know if it works! Thank you! :smiley:

local r, g, b = GetVehicleCustomPrimaryColour(vehicle)
4 Likes

Hi, I’ve tried the codes, it both works perfectly! Thx to @Streetcorps and @boron!!

Btw, don’t forget to set the “r,g,b” to integer by using “tonumber()”, for example: tonumber®.

Once again, thank you guys so much!!

hi

how to do it so that the vehicle addons spawn always in the same color example black.setting in the vehicle files "carcol, handling, ect ect or in the scripts?because for some of my gangs I want to give them a unique color. For example, mercedes G65 in white for cartel. I have succeeded because I modify the template of the vehicle.

excellent post … it helped me a lot

1 Like

Hey, I am trying to make an ems vehicle red when spawned in. It has a livery but to see the whole livery needs to be a white. Where do I change this which file if you know?

1 Like

Can someone explain that, where it should be putted in?

Example my Grovestreet with green cars, how do i set them up when they spawn there gang vehicle it will spawn in green?

2 Likes

Where put this line in my script

1 Like

where do i have to put it?