SA-MP Forums Archive
checking 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: checking arrays (/showthread.php?tid=140109)



checking arrays - oggylt - 07.04.2010

i want to know if there is any way to check all same variables within arrays, dont know how to tell but there is code part:
Код:
if(pickupid==ArmourPickup[0]||ArmourPickup[1]||ArmourPickup[2]||ArmourPickup[3]||ArmourPickup[4]||ArmourPickup[5]||ArmourPickup[6]||ArmourPickup[7])
so is there any shorter to check if this is ANY ArmourPickup


Re: checking arrays - ZeRo_HUN - 07.04.2010

Try it with a loop:

pawn Код:
for( new x = 0; x < sizeof ArmourPickup; ++x ) {
  if( pickupid == ArmourPickup[ x ] ) {
    //Other codes...
  }
}



Re: checking arrays - oggylt - 07.04.2010

thanks very much