ajunong1 Posted September 16, 2015 Share Posted September 16, 2015 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
t3wz Posted September 16, 2015 Share Posted September 16, 2015 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
ajunong1 Posted September 16, 2015 Author Share Posted September 16, 2015 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. Link to comment
Dealman Posted September 16, 2015 Share Posted September 16, 2015 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
ajunong1 Posted September 16, 2015 Author Share Posted September 16, 2015 What does it mean, loop through all the spawned vehicles? My map currently has 10 spawnpoints. I'm really newbie at scripting. I just want a script which makes all race cars white when the map loads. Link to comment
JR10 Posted September 16, 2015 Share Posted September 16, 2015 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
Mr_Moose Posted September 17, 2015 Share Posted September 17, 2015 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. Link to comment
Dealman Posted September 17, 2015 Share Posted September 17, 2015 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
Al3grab Posted September 17, 2015 Share Posted September 17, 2015 What's wrong with black? you're a racist or something ? Link to comment
Dealman Posted September 17, 2015 Share Posted September 17, 2015 What's wrong with black? you're a racist or something ? Link to comment
Mr_Moose Posted September 18, 2015 Share Posted September 18, 2015 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. Link to comment
Dealman Posted September 18, 2015 Share Posted September 18, 2015 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
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