Destroy All Cars
#1

Where i can find a function "Destroyallcars", but this function don't destroy a occupied vehicle.

I have search in the forum but i dont have find any commands.

Sorry for bad eng.
Reply
#2

pawn Код:
for(new i=1;i<=MAX_VEHICLES;i++)
{
    DestroyVehicle(i);
}
Reply
#3

Quote:
Originally Posted by varthshenon
Посмотреть сообщение
pawn Код:
for(new i=1;i<=MAX_VEHICLES;i++)
{
    DestroyVehicle(i);
}
Thanks, but this destroy all vehicle, i don't want to destroy a occupied vehicle.
Reply
#4

pawn Код:
for(new i=1;i<=MAX_VEHICLES;i++)
{
    new count = 0;
    for(new a=0;a<MAX_PLAYERS;a++)
    {
        if(IsPlayerConnected(a) && IsPlayerInAnyVehicle(a))
        {
            if(GetPlayerVehicleID(a) == i) count++;
        }
    }
    if(count > 0)
    {
        DestroyVehicle(i);
    }
}
Reply
#5

Quote:
Originally Posted by varthshenon
Посмотреть сообщение
pawn Код:
for(new i=1;i<=MAX_VEHICLES;i++)
{
    new count = 0;
    for(new a=0;a<MAX_PLAYERS;a++)
    {
        if(IsPlayerConnected(a) && IsPlayerInAnyVehicle(a))
        {
            if(GetPlayerVehicleID(a) == i) count++;
        }
    }
    if(count > 0)
    {
        DestroyVehicle(i);
    }
}
This destory only a occupied vehicle, i don't want to destroy a occupied vehicle and to destroy unoccupied vehicle.
Reply
#6

pawn Код:
for(new i=1;i<=MAX_VEHICLES;i++)
{
    new count = 0;
    for(new a=0;a<MAX_PLAYERS;a++)
    {
        if(IsPlayerConnected(a) && IsPlayerInAnyVehicle(a))
        {
            if(GetPlayerVehicleID(a) == i) count++;
        }
    }
    if(count == 0)
    {
        DestroyVehicle(i);
    }
}
Reply
#7

I would use foreach to do this if I were you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)