break - 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: break (
/showthread.php?tid=481924)
break -
speed258 - 18.12.2013
hello guys i have question, is possible to use "break" for returning values from loop and breaking down a loop?
Example:
Код:
stock GetVehicleIDFromSQL(sqlid)
{
for(new i = 1; i <= MAX_VEHICLES; i++)
{
if(IsValidVehicle(i))
{
if(sqlid == AVDB[i][CSQLID])
{
//return i;
break i;
}
}
}
return INVALID_VEHICLE_ID;
}
Re: break -
Threshold - 18.12.2013
break is simply the function that terminates a loop. If you want the loop to stop and return a value, you must use 'return'.
break - Stops a loop completely.
return - Stops a loop completely, but the function overall will return the given value.
https://sampwiki.blast.hk/wiki/Control_Structures#break
https://sampwiki.blast.hk/wiki/Control_Structures#return