javad_iran Posted September 8, 2018 Share Posted September 8, 2018 Hi. i am create vehicles by map editor and import to folder Maps ragemp server : all cars black color !!?? How to randomize colors Cars (vehicle) auto? sorry for bad english Link to comment Share on other sites More sharing options...
MrPancakers Posted September 9, 2018 Share Posted September 9, 2018 Well here's the vehicle function (Read more here: https://wiki.rage.mp/index.php?title=Vehicle::Vehicle) mp.vehicles.new(model, position, { heading: heading, numberPlate: numberPlate, alpha: alpha, color: color, locked: locked, engine: engine, dimension: dimension }); And this is how you generate random numbers between 1 and 10 Math.floor((Math.random() * 10) + 1); All you have to do is put that together so it picks a random number and you're done. Link to comment Share on other sites More sharing options...
javad_iran Posted September 11, 2018 Author Share Posted September 11, 2018 On 9/9/2018 at 12:35 PM, MrPancakers said: Well here's the vehicle function (Read more here: https://wiki.rage.mp/index.php?title=Vehicle::Vehicle) mp.vehicles.new(model, position, { heading: heading, numberPlate: numberPlate, alpha: alpha, color: color, locked: locked, engine: engine, dimension: dimension }); And this is how you generate random numbers between 1 and 10 Math.floor((Math.random() * 10) + 1); All you have to do is put that together so it picks a random number and you're done. please send example code for vehicle random color? Link to comment Share on other sites More sharing options...
hexisgod Posted September 13, 2018 Share Posted September 13, 2018 function Randomize(Minimal, Maximum) { // functinon randomizer =D let randomized = Math.floor((Math.random() * Maximum) + Minimal); return randomized; } mp.vehicles.new(model, position, // structure create vehicle... { color: [[Randomize(1, 255), Randomize(1, 255), Randomize(1, 255)][Randomize(1, 255), Randomize(1, 255), Randomize(1, 255)]] }); // if vehicle created you can use it... let vehicleRandomized = mp.vehicles.new(mp.joaat('elegy'), new mp.Vector3(0.0, 0.0, 75.0)); // create vehicle (model, position) vehicleRandomized.setColorRGB(Randomize(1, 255), Randomize(1, 255), Randomize(1, 255), Randomize(1, 255), Randomize(1, 255), Randomize(1, 255)); This is example for you!! 1 Link to comment Share on other sites More sharing options...
javad_iran Posted September 14, 2018 Author Share Posted September 14, 2018 (edited) thanks ! Edited September 14, 2018 by javad_iran Link to comment Share on other sites More sharing options...
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