SA-MP Forums Archive
Quick question about a loop - 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: Quick question about a loop (/showthread.php?tid=180489)



Quick question about a loop - Celson - 01.10.2010

What effect would there be for placing a return 1 in a loop? Would that stop the loop? Would return 0 have the same effect?


Re: Quick question about a loop - Ash. - 01.10.2010

pawn Код:
return 1;
tells the function / command that it has completed. This is turn, stops the loop (or if after the loops closing bracket, the rest of that specifc function/command)

pawn Код:
return 0;
however, tells the function / command that it failed to complete, and passes it to other scripts.


Re: Quick question about a loop - DeathOnaStick - 01.10.2010

Returning a value stops the whole callback. Example:
pawn Код:
OnPlayerEnterInterior([...])
{
if(Bleh==32)return 1;
print("Won't printed if Bleh=32.");
return 1;
}
pawn Код:
OnPlayerEnterInterior([...])
{
if(Bleh==32)return 1;
else return 0;
print("Won't printed (never).");
return 1;
}