Jump to content

set Vehiclecolor to White only.


ajunong1

Recommended Posts

Hi, I'm making a race map in gamemode race only.

I have created a custom paintjob which replaces one file in the sultan.txd.

When I try my map, the paintjob appears, however, there's an overlay of the game's random coloring, it's a random color each time it's spawned.

What I want to do is make it so that all players see the same white color, so that the paintjob is properly displayed.

I can't figure out what to do.

I've tried this, but it still doesn't work...

 addEventHandler ("onClientPlayerVehicleEnter", 
    function ( ) 
        setVehicleColor ( source, 255, 255, 255 ) 
    end 
) 

Any vets able to help?

Link to comment

It doesn't works because the source of the onClientPlayerVehicleEnter is "the player that entered the vehicle", To set the color of the vehicle you'll need something like this:

addEventHandler ("onClientPlayerVehicleEnter", 
    function ( vehicle ) 
        setVehicleColor ( vehicle, 255, 255, 255 ) 
    end 
) 

more info at the wiki.

Link to comment
Just tried your script.

That didn't work either.

My spawns are still giving random colors.

btw, I'm putting the code in a separate .lua

then having it executed in the race map's meta.xml in the same dir.

if it helps troubleshooting.

That event is triggered when a player enters the vehicle, not when it spawns. Try using onClientResourceStart instead and loop through all the spawned vehicles. You'll need to use this getElementsByType.

Link to comment

You can use the "onMapStarting" event to loop through the vehicles.

addEvent('onMapStarting') 
addEventHandler('onMapStarting', root, function() 
 for index, vehicle in pairs(getElementsByType('vehicle')) do 
  setVehicleColor(vehicle, 255, 255, 255) 
 end 
end) 

Link to comment
The most efficient way would be to find the createVehicle function within the race resource and add the white color as parameters to that, (or set the color directly after it's created). Try an editor like Atom from Github which let's you search through multiple files at once.

The difference would be a matter of few milliseconds, so the difference is barely worth mentioning. Whichever is more convenient.

Link to comment
The difference would be a matter of few milliseconds, so the difference is barely worth mentioning. Whichever is more convenient.

That's true, although you would also get all the relative stuff in one place which is an advantage as well.

Aye. Though I would argue unless you're able to understand the Race resource - you would be better off creating it externally in your own resource. :) Either way works!

Link to comment

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...