SA-MP Forums Archive
Same car model spawning - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Same car model spawning (/showthread.php?tid=584022)



Same car model spawning - (_AcE_) - 01.08.2015

Trying to get random car models to spawn in specified locations.

pawn Код:
new arrayModels[] =
{
    400,401,405,410,492,492,412,413,415,414,419,522,492,522,421,491,491,426,424,
    414,439,458,463,467,603,600,587,581,516,517,517,491,491,492,492,522,522,474
};
Under OnGameModeInit()

pawn Код:
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?


Re: Same car model spawning - xVIP3Rx - 01.08.2015

Yeah, because you get a random model and spawn them all with it. try this
pawn Код:
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....



Re: Same car model spawning - Variable™ - 01.08.2015

Removed.


Re: Same car model spawning - xVIP3Rx - 01.08.2015

Quote:
Originally Posted by 1Deagle1
Посмотреть сообщение
I will fix it :3
Your code (Which you probably edited before I posted this) is completely wrong and will give errors.


Re: Same car model spawning - Variable™ - 01.08.2015

Removed.


Re: Same car model spawning - (_AcE_) - 01.08.2015

Well done Viper, thanks a lot. +rep