PDA

View Full Version : Same car model spawning


(_AcE_)
01/08/2015, 08:52 PM
Trying to get random car models to spawn in specified locations.


new arrayModels[] =
{
400,401,405,410,492,492,412,413,415,414,419,522,49 2,522,421,491,491,426,424,
414,439,458,463,467,603,600,587,581,516,517,517,49 1,491,492,492,522,522,474
};


Under OnGameModeInit()


new randomModel = random(sizeof(arrayModels));
AddStaticVehicle(arrayModels[randomModel],2630.1519,-1098.2321,69.1573,264.0556,-1,-1); //
AddStaticVehicle(arrayModels[randomModel],2704.4961,-1274.4724,57.4593,319.3490,-1,-1); //
AddStaticVehicle(arrayModels[randomModel],2750.7312,-1177.2827,69.1416,269.7911,-1,-1); //
AddStaticVehicle(arrayModels[randomModel],2705.6379,-1178.8975,69.1017,90.4642,-1,-1); //
AddStaticVehicle(arrayModels[randomModel],2718.1362,-1115.5847,69.2649,0.9826,-1,-1); //
e.t.c....


I went in to test it and only the same car model is spawning for every single car...

Any way to fix this?

xVIP3Rx
01/08/2015, 08:55 PM
Yeah, because you get a random model and spawn them all with it. try this

new max = sizeof(arrayModels);
AddStaticVehicle(arrayModels[random(max)],2630.1519,-1098.2321,69.1573,264.0556,-1,-1); //
AddStaticVehicle(arrayModels[random(max)],2704.4961,-1274.4724,57.4593,319.3490,-1,-1); //
AddStaticVehicle(arrayModels[random(max)],2750.7312,-1177.2827,69.1416,269.7911,-1,-1); //
AddStaticVehicle(arrayModels[random(max)],2705.6379,-1178.8975,69.1017,90.4642,-1,-1); //
AddStaticVehicle(arrayModels[random(max)],2718.1362,-1115.5847,69.2649,0.9826,-1,-1); //
e.t.c....

Variable™
01/08/2015, 08:57 PM
Removed.

xVIP3Rx
01/08/2015, 09:01 PM
I will fix it :3

Your code (Which you probably edited before I posted this) is completely wrong and will give errors.

Variable™
01/08/2015, 09:02 PM
Removed.

(_AcE_)
01/08/2015, 11:26 PM
Well done Viper, thanks a lot. +rep