ajunong1 Posted September 16, 2015 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?
t3wz Posted September 16, 2015 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.
ajunong1 Posted September 16, 2015 Author 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.
Dealman Posted September 16, 2015 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. If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.
ajunong1 Posted September 16, 2015 Author 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.
JR10 Posted September 16, 2015 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) Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
Mr_Moose Posted September 17, 2015 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. MTA Community | GitHub | 99Stack Forum
Dealman Posted September 17, 2015 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. If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.
Al3grab Posted September 17, 2015 Posted September 17, 2015 What's wrong with black? you're a racist or something ? ING : [xXx]~Al3grab
Dealman Posted September 17, 2015 Posted September 17, 2015 What's wrong with black? you're a racist or something ? If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.
Mr_Moose Posted September 18, 2015 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. MTA Community | GitHub | 99Stack Forum
Dealman Posted September 18, 2015 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! If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.
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