get random vehicle id
#1

how would u get a random car id fromt he whole list of vehicles spawned :P
Reply
#2

Try this

new randomcars = random(MAX_VEHICLES);

I don't think if this works but try...
Reply
#3

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


Forum Jump:


Users browsing this thread: 2 Guest(s)