Random Vehicle Colors
#1

Hey guys. I wanted to change the Static Vehicles colors, instead of having the same old boring one all the time.
I made this, code but they're all the same random color. Can anybody modify this piece of code?
pawn Код:
// Top
new RandomColor;

// OnGameModeInit
     RandomColor = random(126);
     CreateVehicle(600, 2443.4988, -1638.6720, 13.1500, 0.5251, RandomColor, RandomColor, 60000); //Picador
    CreateVehicle(576, 2384.3350, -1642.6705, 13.1262, 179.1543,RandomColor, RandomColor, 60000); //Tornado
    CreateVehicle(509, 2381.9219, -1668.1119, 13.0579, 87.1576, RandomColor, RandomColor, 60000); //Bike
    CreateVehicle(566, 2516.3840, -1672.1924, 13.6729, 244.9107, RandomColor, RandomColor, 60000); //Tahoma
    CreateVehicle(483, 2505.2524, -1649.3340, 13.6677, 69.6383, RandomColor, RandomColor, 60000); //Camper
    CreateVehicle(481, 2432.4109, -1680.4995, 13.3084, 83.9300, RandomColor, RandomColor, 60000); //BMX
    CreateVehicle(479, 2319.3923, -1717.0272, 13.3445, 179.0517, RandomColor, RandomColor, 60000); //Regina
    CreateVehicle(475, 2271.4751, -1640.2313, 15.1523, 0.5867, RandomColor, RandomColor, 60000); //Sabre
    CreateVehicle(468, 2063.4644, -1738.7705, 13.2160, 268.8122, RandomColor, RandomColor, 60000); //Sanchez
    CreateVehicle(474, 2059.7380, -1694.5408, 13.3119, 88.5829, RandomColor, RandomColor, 60000); //Hermes
    CreateVehicle(466, 2017.2903, -1648.5475, 13.2926, 88.8572, RandomColor, RandomColor, 60000); //Glendale
    CreateVehicle(461, 1979.2878, -1728.6727, 15.5527, 271.5863, RandomColor, RandomColor, 60000); //PCJ-600
    CreateVehicle(451, 1859.1541, -1871.9354, 13.2131, 180.1491, RandomColor, RandomColor, 60000); //Turismo
    CreateVehicle(439, 1836.6116, -1854.5393, 13.2853, 178.2784, RandomColor, RandomColor, 60000); //Stallion
    CreateVehicle(438, 1740.5513, -1859.9113, 13.4997, 269.0887, RandomColor, RandomColor, 60000); //Cabbie
    CreateVehicle(575, 1981.2981, -1985.5325, 13.1471, 0.2444, RandomColor, RandomColor, 60000); //Broadway
    CreateVehicle(567, 1991.4419, -2061.4873, 13.2414, 267.4559, RandomColor, RandomColor, 60000); //Savanna
    CreateVehicle(596, 1931.7240, -2024.5859, 13.2684, 2.3798, -1, -1, 60000); //Police Car (LSPD)
    CreateVehicle(609, 1931.5863, -2011.4011, 13.6135, 359.4266, -1, -1, 60000); //Boxburg
    CreateVehicle(603, 2055.9722, -1904.1256, 13.3854, 0.1171, RandomColor, RandomColor, 60000); //Phoenix
    CreateVehicle(514, 2008.5691, -1940.1031, 13.9261, 92.2044,RandomColor, RandomColor, 60000); //Petrol Tanker
    CreateVehicle(416, 2007.6348, -1411.3663, 17.1415, 267.9719, 1, 3, 60000); //Ambulance
    CreateVehicle(416, 2036.2529, -1440.7045, 17.5111, 358.6993, 1, 3, 60000); //Ambulance
Reply
#2

That's because you make the variable hold that ONE number (random of 126). It's only returning that one number. Try something like this:
pawn Код:
//top
forward RandomColor();
{
  new color = random(126);
  return color;
}
Remember to delete the RandomColor variable that you already have, aswell as the math in OnGameModeInit you already have.
Reply
#3

Set vehicle colors to -1, they vehicles get their default colors (not always the same, except police cars, hospital...)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)