Is my command will work - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Is my command will work (
/showthread.php?tid=516058)
Is my command will work -
xFirex - 29.05.2014
hello, is my command will work ? if any wrong please help me
PHP код:
CMD:removeucar(playerid,params[])
{
if(PlayerInfo[playerid][pAdmin] < 3 && !IsPlayerAdmin(playerid)) return SendClientMessage( playerid, -1, "You Must Be Higher Level To To Use This Command");
{
for(new i = 0; i < MAX_VEHICLE; vv++)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerInVehicle(ii, vv))
{
DestroyVehicle(vv);
}
}
}
}
return 1;
}
Re: Is my command will work -
Konstantinos - 29.05.2014
There are many issues with it. Having "i" twice and increasing "vv" and then using "ii" which are both undefined symbols.
It will also remove (if you fix those I mentioned above) the vehicle if the player with ID 0 is not in that vehicle.
Vehicles starts from 1, not 0 and you should use foreach to reduce the times the loop for the players gets called.
pawn Код:
CMD:removeucar(playerid,params[])
{
if(PlayerInfo[playerid][pAdmin] < 3 && !IsPlayerAdmin(playerid)) return SendClientMessage( playerid, -1, "You Must Be Higher Level To To Use This Command");
for (new v = 1; v < MAX_VEHICLES; v++)
{
if (!GetVehicleModel(v)) continue; // vehicle does not exist, skip the players loop
if (!IsVehicleOccupied(v)) DestroyVehicle(v);
}
return 1;
}
IsVehicleOccupied(vehicleid)
{
foreach(new i : Player)
{
if (IsPlayerInVehicle(i, vehicleid)) return 1;
}
return 0;
}
Re: Is my command will work -
xFirex - 29.05.2014
Thanks