SA-MP Forums Archive
Just a simple question - 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: Just a simple question (/showthread.php?tid=92490)



Just a simple question - Paladin - 20.08.2009

Hey .. I have a small question actually, not even a problem.

I have my var:
Код:
new admincar[15];
now under
OnPlayerEnterVehicle I set this:
Код:
if(vehicleid == admincar[0])
{
return 1;
}
I understand it has no effect but I will implement that later, now is there a way to put all the arrays in one if? instead of doing
Код:
if((vehicleid == admincar[0]) || vehicleid == admincar[1])
etc etc...


Re: Just a simple question - Dark_Kostas - 20.08.2009

pawn Код:
if(vehicleid >= admincar[0] && vehicleid <= admincar[14])
This will NOT work


Re: Just a simple question - Redgie - 20.08.2009

This is just a guess, because I have never done it before, and I hate arrays (xD) but can't you just use if(vehicleid == admincar)?

If not
Код:
for(new x=0; x<15; x++)
{
  if(vehicleid == admincar[x])
  {
    return 1;
  }
}



Re: Just a simple question - Redgie - 20.08.2009

Quote:
Originally Posted by Dark_Kostas
pawn Код:
if(vehicleid >= admincar[0] && vehicleid <= admincar[14])
This should work
That would only work if admincar[0-15] had consequtively incrementing values


Re: Just a simple question - Paladin - 20.08.2009

Quote:
Originally Posted by Redgie
This is just a guess, because I have never done it before, and I hate arrays (xD) but can't you just use if(vehicleid == admincar)?

If not
Код:
for(new x=0; x<14; x++)
{
  if(vehicleid == admincar[x])
  {
    return 1;
  }
}
Thank you Redgie.
Quote:
Originally Posted by Dark_Kostas
pawn Код:
if(vehicleid >= admincar[0] && vehicleid <= admincar[14])
Thanks for trying.


Re: Just a simple question - Dark_Kostas - 20.08.2009

Quote:
Originally Posted by Redgie
Quote:
Originally Posted by Dark_Kostas
pawn Код:
if(vehicleid >= admincar[0] && vehicleid <= admincar[14])
This should work
That would only work if admincar[0-15] had consequtively incrementing values
Yeah my fault, i didnt think about it xD


Re: Just a simple question - Redgie - 20.08.2009

Haha done that plenty of times, including now

OP: I originally put <14, but meant to put <15, I have updated my post. Good luck!