25.07.2016, 22:09
Hey guys, i've been trying to create a few admin commands to learn understanding pawn better,
but i keep running into issues, now i have another one hehehe i wanted to create 2 commands,
One that reloads all the vehicles in the game, and one that reloads all the unoccupied vehicles in the game, however how will i do this, can i create a loop that searches all the vehicle id's and respawns them, and a loop that checks if there occupied or not?
I came up with the following code to respawn all unoccupied vehicles however its giving me an error
the stock
local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
At the line ;
foreach(Player, i) if(GetPlayerVehicleID(i) == iVehicleID && GetPlayerVehicleSeat(i)== iSeatID) return 1;
but i keep running into issues, now i have another one hehehe i wanted to create 2 commands,
One that reloads all the vehicles in the game, and one that reloads all the unoccupied vehicles in the game, however how will i do this, can i create a loop that searches all the vehicle id's and respawns them, and a loop that checks if there occupied or not?
I came up with the following code to respawn all unoccupied vehicles however its giving me an error
Код:
CMD:respawnalluv(playerid,params[]) { if(pData[playerid][Admin] < 5) return SendClientMessage(playerid, COLOR_RED, "[Error]:{ffffff} You are not authorized to use this command."); else { for(new i = 1; i < MAX_VEHICLES; i++) if(!IsVehicleOccupied(i)) SetVehicleToRespawn(i); } return 1; }
Код:
stock IsVehicleOccupied(iVehicleID, iSeatID = 0) { foreach(Player, i) if(GetPlayerVehicleID(i) == iVehicleID && GetPlayerVehicleSeat(i)== iSeatID) return 1; return 0; }
At the line ;
foreach(Player, i) if(GetPlayerVehicleID(i) == iVehicleID && GetPlayerVehicleSeat(i)== iSeatID) return 1;