Foreach loop check - 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: Foreach loop check (
/showthread.php?tid=629635)
Foreach loop check -
Penguin1997 - 01.03.2017
The problem is that I want it to loop through all players however it only loops through first 20, at times just 10 or just 5 and at times 25.. what could be the problem?
Код:
public AchievementProcess()
{
foreach(Player,i)
{
if(forbes[i] == 0) continue;
if(pInfo[i][achievement1] == 0)
{
if(pInfo[i][Kills] >= 50)
{
//code
SaveStatus(i);
}
}
if(pInfo[i][achievementno2] == 0)
{
if(pInfo[i][Kills] >= 400)
{
//code
SaveStatus(i);
}
}
if(pInfo[i][achievementno3] == 0)
{
if(pInfo[i][Kills] >= 1600)
{
//code
SaveStatus(i);
}
}
if(pInfo[i][achievementno5] == 0)
{
if(pInfo[i][Kills] >= 7000)
{
//code
SaveStatus(i);
}
}
}
}
public SaveStatus(playerid)
{
// INT saving //
return 1;
}
Re: Foreach loop check -
jlalt - 01.03.2017
Your foreach syntax use is old and probably your include is old too!.
download latest one and use the latest syntax for your foreachs.
https://sampforum.blast.hk/showthread.php?tid=570868
PHP код:
foreach (new i : Player)