Random vehicle
#1

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);
Reply
#2

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);
Reply
#3

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

I wasn't sure about that.

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

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

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

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).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)