if statements with arrays - 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: if statements with arrays (
/showthread.php?tid=500078)
if statements with arrays -
Lidor124 - 11.03.2014
I have this variable with arrays of 17 cells, i want to put it as statement:
Instead of if(TollGate[0] || TollGate[1] || TollGate[2] || TollGate[3] etc till 16....)
How to make it shorter, in one word / array and to check all the arrays in one time...
new TollGate[16];
Thanks.
Re: if statements with arrays -
Vince - 11.03.2014
pawn Код:
for(new i; i < sizeof(TollGate); i++)
{
if(/*something*/ == TollGate[i])
{
// Do stuff
break;
}
}
Re: if statements with arrays -
Richie© - 11.03.2014
pawn Код:
for(new i = 0; i < 16; i++) if(TollGate[i]) // do your stuff and break;
edit: vince won.