command to delete all cars in the server
#4

Quote:
Originally Posted by Zh3r0
View Post
You forgot about INVALID_VEHICLE_ID to check if it's a valid id.
I wasn't sure if I have to put INVALID_VEHICLE_ID in a MAX_VEHICLES loop :\ . It's not like
pawn Code:
if( 0 != INVALID_VEHICLE_ID )
{
    DestroyVehicle( 0 );
}
if( 1 != INVALID_VEHICLE_ID )
{
    DestroyVehicle( 1 );
}
// etc
if( 1999 != INVALID_VEHICLE_ID )
{
    DestroyVehicle( 1999 );
}
?

0 ... 1999 are valid vehicle ID's, but we are not sure if respective vehicle has been created, GetVehiclePos would be good:

Code:
if( strcmp( cmdtext, "/deleteallcars", true ) == 0 )
{
    new Float:X, Float:Y, Float:Z;
    for( new veh; veh < MAX_VEHICLES; veh ++ )
    {
        GetVehiclePos( veh, X, Y, Z );
        if( X == 0.00 && Y == 0.00 && Z == 00 )
            continue;

        DestroyVehicle( veh );
    }
    return 1;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)