Random vehicle selling price -
Face9000 - 04.02.2014
I just setup a custom vehicle selling system, but since i listed all the vehicles, i wanna randomize the selling price too, so i did in this way:
(I'll not post all the vehicles list, just a small part so you can understand what im asking):
pawn Код:
new RandomVehiclePrice = random(35000-7500+1200+500+6000-1300+25000-12000);
new ListVehicles[212][VehiclesInfo] =
{
{"Landstalker",RandomVehiclePrice},
{"Bravura",RandomVehiclePrice},
{"Buffalo",RandomVehiclePrice},
{"Linerunner",RandomVehiclePrice},
{"Perrenial",RandomVehiclePrice},
{"Sentinel",RandomVehiclePrice},
{"Dumper",RandomVehiclePrice},
{"Firetruck",RandomVehiclePrice},
{"Trashmaster",RandomVehiclePrice},
{"Stretch",RandomVehiclePrice},
{"Manana",RandomVehiclePrice},
{"Infernus",RandomVehiclePrice}
};
But when i compile it, pawno crashes. What's wrong?
Re: Random vehicle selling price -
Konstantinos - 04.02.2014
Wouldn't be easier to just use:
pawn Код:
new ListVehicles[212][VehiclesInfo] =
{
{"Landstalker", RandomEx(500, 35000)},
{"Bravura", RandomEx(600, 30000)},
// rest..
};
pawn Код:
stock RandomEx(min, max)
{
return random(max - min) + min;
}
Re: Random vehicle selling price -
Face9000 - 04.02.2014
I have 212 vehicles listed, it will be a pain in the ass editing them all with a different random number. I was thinking to make all vehicles with "RandomEx(600, 30000)". It will print a different random number for every vehicle, right?
EDIT: Tried that code, crashes too.
Re: Random vehicle selling price -
Vince - 04.02.2014
You can only initialize arrays with constants. Neither a variable, nor the return value of a function would be a valid initialer.
Re: Random vehicle selling price -
Face9000 - 04.02.2014
So i suppose i can't add a random number in that array.
Re: Random vehicle selling price -
Borg - 04.02.2014
You can, but u have to do it manually. Or you can just get a random number whenever you need the car price.