get random vehicle id - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: get random vehicle id (
/showthread.php?tid=161420)
get random vehicle id -
aNdReSk - 19.07.2010
how would u get a random car id fromt he whole list of vehicles spawned :P
Re: get random vehicle id -
simstosh - 19.07.2010
Try this
new randomcars = random(MAX_VEHICLES);
I don't think if this works but try...
Re: get random vehicle id -
michael2572 - 19.07.2010
pawn Код:
new vehicleids[MAX_VEHICLES];
new size = 0;
for (new i=0; i < MAX_VEHICLES; i++)
{
if (valid_vehicle(i))
{
vehicleids[size] = i;
size++;
}
}
new random_veh_id = vehicleids[ random(size) ];
You'll need to write a "valid_vehicle" function. Should be pretty easy, I'd recommend testing a GetVehicleModel in that function and if it's within the valid model range, it's an active, spawned vehicle.