javad_iran 0 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 Share this post Link to post Share on other sites
MrPancakers 108 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. Share this post Link to post Share on other sites
javad_iran 0 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? Share this post Link to post Share on other sites
hexisgod 14 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 Share this post Link to post Share on other sites
javad_iran 0 Posted September 14, 2018 (edited) thanks ! Edited September 14, 2018 by javad_iran Share this post Link to post Share on other sites