Same car model spawning
#1

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?
Reply
#2

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....
Reply
#3

Removed.
Reply
#4

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.
Reply
#5

Removed.
Reply
#6

Well done Viper, thanks a lot. +rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)