/veh destroyall doesn't work
#2

You're turning even when the loop runs once, so it's only destroying one car then closing the function.

Remove the return 1;

PHP код:
CMD:veh(playeridparams[]) 

    new 
idFloat:pos[4], col[2]; 
       if(!
IsPlayerLoggedIn(playerid) || PlayerInfo[playerid][pAsshole] == 1) return SendClientMessage(playeridCOLOR_GREY"You are not allowed to use this command."); 
    if(
PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playeridCOLOR_GREY"You are not authorized to use this command."); 
    if(!
strcmp(params"destroy")) 
    { 
        if(
GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playeridCOLOR_GREY"You must be inside a vehicle to destroy it."); 
        for(new 
i=0i<MAX_CUSTOM_VEHICLESi++) 
        { 
            if(
GetPlayerVehicleID(playerid) == cVeh[i]) 
            { 
                
//format(string, sizeof(string), "AdmWarn: %s has destroyed a vehicle model %d.", RPN(playerid), GetVehicleModel(i)); 
                //SendAdminMessage(COLOR_DARKRED, 1, string); 
                
DestroyVehicle(cVeh[i]); 
                
MAX_CUSTOM_VEHICLES
                return 
1
            } 
        } 
        
SendClientMessage(playeridCOLOR_GREY"You can't destroy this vehicle."); 
        return 
1
    } 
    if(!
strcmp(params"destroyall")) 
    { 
        for(new 
i=0i<MAX_CUSTOM_VEHICLESi++) 
        { 
            
DestroyVehicle(cVeh[i]); 
            
cVeh[i] = 0
        } 
        return 
1
    } 
    if(
sscanf(params"iii"idcol[0], col[1])) return SendClientMessage(playeridCOLOR_WHITE"USAGE: /veh [vehicleid/destroy] [color1] [color2]"); 
    if(
id 400 || id 611) return SendClientMessage(playeridCOLOR_GREY"Vehicles are between 400 and 611."); 
    
GetPlayerPos(playeridpos[0], pos[1], pos[2]); 
    
GetPlayerFacingAngle(playeridpos[3]); 
    for(new 
i=0i<MAX_CUSTOM_VEHICLESi++) 
    { 
        if(!
cVeh[i]) 
        { 
            
cVeh[i] = CreateVehicle(idpos[0], pos[1], pos[2], pos[3], col[0], col[1], 1200); 
            
MAX_CUSTOM_VEHICLES
        } 
    } 
    new 
string[128]; 
    
format(stringsizeof(string), "AdmWarn: %s has spawned a vehicle model %d."RPN(playerid), id); 
    
SendAdminMessage(COLOR_DARKRED1string); 
    return 
1

I recommend doing debugging next time since that would've figured it out, for instance, if you did printf("Looping (i: %i)", i); in the loop you would've found it only looped once.
Reply


Messages In This Thread
/veh destroyall doesn't work - by NeXoR - 29.03.2016, 21:33
Re: /veh destroyall doesn't work - by Golden96 - 29.03.2016, 21:41
Re: /veh destroyall doesn't work - by NeXoR - 29.03.2016, 22:25

Forum Jump:


Users browsing this thread: 1 Guest(s)