29.03.2016, 21:41
You're turning even when the loop runs once, so it's only destroying one car then closing the function.
Remove the 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.
Remove the return 1;
PHP код:
CMD:veh(playerid, params[])
{
new id, Float:pos[4], col[2];
if(!IsPlayerLoggedIn(playerid) || PlayerInfo[playerid][pAsshole] == 1) return SendClientMessage(playerid, COLOR_GREY, "You are not allowed to use this command.");
if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
if(!strcmp(params, "destroy"))
{
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_GREY, "You must be inside a vehicle to destroy it.");
for(new i=0; i<MAX_CUSTOM_VEHICLES; i++)
{
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]);
i = MAX_CUSTOM_VEHICLES;
return 1;
}
}
SendClientMessage(playerid, COLOR_GREY, "You can't destroy this vehicle.");
return 1;
}
if(!strcmp(params, "destroyall"))
{
for(new i=0; i<MAX_CUSTOM_VEHICLES; i++)
{
DestroyVehicle(cVeh[i]);
cVeh[i] = 0;
}
return 1;
}
if(sscanf(params, "iii", id, col[0], col[1])) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /veh [vehicleid/destroy] [color1] [color2]");
if(id < 400 || id > 611) return SendClientMessage(playerid, COLOR_GREY, "Vehicles are between 400 and 611.");
GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
GetPlayerFacingAngle(playerid, pos[3]);
for(new i=0; i<MAX_CUSTOM_VEHICLES; i++)
{
if(!cVeh[i])
{
cVeh[i] = CreateVehicle(id, pos[0], pos[1], pos[2], pos[3], col[0], col[1], 1200);
i = MAX_CUSTOM_VEHICLES;
}
}
new string[128];
format(string, sizeof(string), "AdmWarn: %s has spawned a vehicle model %d.", RPN(playerid), id);
SendAdminMessage(COLOR_DARKRED, 1, string);
return 1;
}