Warning: for(new i = 0; i <MAX_PLAYERS; i++) - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Warning: for(new i = 0; i <MAX_PLAYERS; i++) (
/showthread.php?tid=249632)
Warning: for(new i = 0; i <MAX_PLAYERS; i++) -
MrND - 19.04.2011
PHP код:
warning 219: local variable "i" shadows a variable at a preceding level
LINE = 18874:
PHP код:
}
[this is the line 18874]:for(new i = 0; i <MAX_PLAYERS; i++)
{
if(IsPlayerNPC(i)) return 1;
}
if (IsABus(vehicleid) && GetPlayerState(i) == 2 && PlayerInfo[i][pJob] != 14)
{
RemovePlayerFromVehicle(i);
}
How can I fix this?
Re: Warning: for(new i = 0; i <MAX_PLAYERS; i++) -
admantis - 19.04.2011
You are performing a loop under another loop with the same variables.
pawn Код:
// WRONG:
for(new i = 0; i < MAX_PLAYERS; i++)
{
for(new i = 0; i < MAX_PLAYERS; i++)
// RIGHT:
for(new i = 0; i < MAX_PLAYERS; i++)
{
for(new i2 = 0; i2 < MAX_PLAYERS; i2++)
Re: Warning: for(new i = 0; i <MAX_PLAYERS; i++) -
MrND - 19.04.2011
Oh mah god, you saved my time, thank you a lot!