SA-MP Forums Archive
Random vehicle - 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: Random vehicle (/showthread.php?tid=584890)



Random vehicle - cnoopers - 08.08.2015

hi, my vehicle is not spawnin, not any ingame warning about wrong model or something. why?
Код:
	new RandomFreeVeh[] =
	{
		400,
		401,
		404,
		405,
		410,
		412,
		419,
		421,
		422,
		426,
		436,
		439,
		445,
		466,
		467,
		474,
		479,
		491,
		492,
		517,
		518,
		526,
		527,
		533,
		540,
		542,
		549,
		600
	};
Код:
CreateVehicle(RandomFreeVeh[random(29)],1544.7468,-1655.2185,5.5157,263.5304,random(127), random(127), 10*60000);



Re: Random vehicle - Dokins - 08.08.2015

Two things:
Where are you creating the vehicle?
Also, I'm not sure if you can use random like that in the function.

try something like:

pawn Код:
new model, colour1, colour2;
model = random(29);
colour1 = random(127);
colour2 = random(127);

CreateVehicle(RandomFreeVeh[model],1544.7468,-1655.2185,5.5157,263.5304,colour1, colour2, 10*60000);



Re: Random vehicle - Crayder - 08.08.2015

Quote:
Originally Posted by Dokins
Посмотреть сообщение
Two things:
Where are you creating the vehicle?
Also, I'm not sure if you can use random like that in the function.

try something like:

pawn Код:
new model, colour1, colour2;
model = random(29);
colour1 = random(127);
colour2 = random(127);

CreateVehicle(RandomFreeVeh[model],1544.7468,-1655.2185,5.5157,263.5304,colour1, colour2, 10*60000);
Yes, you can use random in functions... Therefore, your code is the exact same as his and there is no point in changing his to yours.

About it not spawning, try debugging it.

pawn Код:
printf("Vehicle ID: %i, %i, %i", CreateVehicle(RandomFreeVeh[random(29)],1544.7468,-1655.2185,5.5157,263.5304,random(127), random(127), 10*60000), CreateVehicle(RandomFreeVeh[random(29)],1544.7468,-1655.2185,5.5157,263.5304,random(127), random(127), 10*60000), CreateVehicle(RandomFreeVeh[random(29)],1544.7468,-1655.2185,5.5157,263.5304,random(127), random(127), 10*60000));
That should create three vehicles, thus printing three different ID's.


Re: Random vehicle - Dokins - 08.08.2015

I wasn't sure about that.

Perhaps what might help is if he shares where the vehicle is being created, perhaps before debugging.


Re: Random vehicle - cnoopers - 08.08.2015

now i see, they are spawnin but not everyone, random ones wont spawn.
everything is ongamemodeinit
log:
Код:
Vehicle ID: 50, 49, 48



Re: Random vehicle - MarvinPWN - 09.08.2015

Write it like this:
PHP код:
new rand random(RandomFreeVeh));
CreateVehicle(RandomFreeVeh[rand],1544.7468,-1655.2185,5.5157,263.5304,random(127), random(127), 10*60000



Re: Random vehicle - Crayder - 09.08.2015

Quote:
Originally Posted by cnoopers
Посмотреть сообщение
now i see, they are spawnin but not everyone, random ones wont spawn.
everything is ongamemodeinit
log:
Код:
Vehicle ID: 50, 49, 48
If that is your exact response, then they are all created and spawned. I'm not sure why you do not see them (unless ofc you are not at their location).