[Help]Car Spawning
#1

Hello everybody, i need help with car spawning.

i have the coords for where i want my cars but, i want the cars to be random so that whenever i start my server or the car gets destroyed it will be different.

What would i have to edit from this?

AddStaticVehicle(451,1765.4220,210.0302,25.6966,31 5.0654,125,125); //

Pls help, i have seen this on some servers.
Reply
#2

i think your looking for OnVehicleSpawn
it will get called when the vehicle respawns so all you have to do is save the vehicleid and then check it under OnVehicleSpawn
Reply
#3

For it to have a random vehicle model (is what assume you mean), you'll just need to get a random number inbetween (and including) 400 and 611.

You will need the following function (or a variation of it):
pawn Код:
stock RandomBetween(min, max)
{
     return random(max - min) + min;
}
Then when you want to add a randomly chosen vehicle model, replace the "model" parameter of AddStaticVehicle (or CreateVehicle, CreateVehicleEx, AddStaticVehicleEx) with:
pawn Код:
RandomBetween(400, 611)
400 is the lowest possible vehicle model, and 611 is the highest.
Reply
#4

Quote:
Originally Posted by park4bmx
Посмотреть сообщение
i think your looking for OnVehicleSpawn
it will get called when the vehicle respawns so all you have to do is save the vehicleid and then check it under OnVehicleSpawn
Is this how u would put it in ur script?

public OnVehicleSpawn(vehicleid)
{
AddStaticVehicle(1765.4220,210.0302,25.6966,315.06 54,125,125); //
return 1;
}


Im new at pawno
Reply
#5

Quote:
Originally Posted by DrSega69
Посмотреть сообщение
Is this how u would put it in ur script?

public OnVehicleSpawn(vehicleid)
{
AddStaticVehicle(1765.4220,210.0302,25.6966,315.06 54,125,125); //
return 1;
}


Im new at pawno
Using that script would just end up duplicating a vehicle everytime one respawns, which isn't good.

Do you want the vehicle models to be random? I mean do you want the models (vehicles) to change? If so, read my original post (above yours).
Reply
#6

Quote:
Originally Posted by funky1234
Посмотреть сообщение
Using that script would just end up duplicating a vehicle everytime one respawns, which isn't good.

Do you want the vehicle models to be random? I mean do you want the models (vehicles) to change? If so, read my original post (above yours).
Well, i want the car that spawn say the 1st time its a turismo then when server restarts or the vehicle is destroyed maybe a bullet or a random car.
Reply
#7

Quote:
Originally Posted by DrSega69
Посмотреть сообщение
Well, i want the car that spawn say the 1st time its a turismo then when server restarts or the vehicle is destroyed maybe a bullet or a random car.
yes in that case you will need to get the random id like funky showed you but you will have to destroy your current vehicle (if you wish)
Reply
#8

Ok THANK YOU SO MUCH FUNKY, when i 1st read ur 1st reply that u sent i was confused.
i tested it and it worked! THANK YOU SO MUCH!

How do i give rep or what is it called?
Reply
#9

Found it! +1
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)