SA-MP Forums Archive
array must be indexed - 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: array must be indexed (/showthread.php?tid=108418)



array must be indexed - •Ajax• - 14.11.2009

http://pastebin.com/d2dd602a6
I've really hit a brick wall here guys, any help appreciated.
Код:
C:\Users\XXXX\Desktop\0.3a SAMP Server\filterscripts\a_fuel.pwn(93) : error 033: array must be indexed (variable "invalidvehs")
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
pawn Код:
new invalidvehs[0][0] =
{
    {441}, {464}, {465}, {481}, {501},
    {509}, {510}, {564}, {572}, {594}
};

public IsVehicleValid(vehicleid)
{
    if (GetVehicleModel(vehicleid) == invalidvehs[0]) return false; // Line 93
    else return true;
}



Re: array must be indexed - Hiitch - 14.11.2009

Hmm, on line 93, try to take out the second ' = ' and see what happens.


Re: array must be indexed - •Ajax• - 14.11.2009

Quote:
Originally Posted by [NaB
Hiitch - No srsly, Im a NaB ! ]
Hmm, on line 93, try to take out the second ' = ' and see what happens.
Код:
C:\Users\XXXX\Desktop\0.3a SAMP Server\filterscripts\a_fuel.pwn(93) : warning 211: possibly unintended assignment
C:\Users\XXXX\Desktop\0.3a SAMP Server\filterscripts\a_fuel.pwn(93) : error 022: must be lvalue (non-constant)
C:\Users\XXXX\Desktop\0.3a SAMP Server\filterscripts\a_fuel.pwn(93) : warning 215: expression has no effect
C:\Users\XXXX\Desktop\0.3a SAMP Server\filterscripts\a_fuel.pwn(93) : error 001: expected token: ";", but found ")"
C:\Users\XXXX\Desktop\0.3a SAMP Server\filterscripts\a_fuel.pwn(93) : error 029: invalid expression, assumed zero
C:\Users\XXXX\Desktop\0.3a SAMP Server\filterscripts\a_fuel.pwn(93) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
I need to check if the vehicle is equal to one of the invalid vehicles.


Re: array must be indexed - Hiitch - 14.11.2009

Ohh, I saw the first error, put the other = back in, it must be something to do with the other statement.


Re: array must be indexed - •Ajax• - 14.11.2009

I just don't get it.
I've made things like this before (error/warning-less), & i can't see anything that is really changed except for the name & use.


Re: array must be indexed - CracK - 14.11.2009

pawn Код:
new invalidvehs[] =
{
   441, 464, 465, 481, 501, 509, 510, 564, 572, 594
};

public IsVehicleValid(vehicleid)
{
   new k = sizeof(invalidvehs);
   for(new i;i<k;i++)
     if(GetVehicleModel(vehicleid) == invalidvehs[i]) return false; // Line 93
   return true;
}



Re: array must be indexed - yom - 14.11.2009

pawn Код:
IsVehicleValid(vehicleid)
{
  switch(GetVehicleModel(vehicleid))
  {
    case 441, 464, 465, 481, 501, 509, 510, 564, 572, 594 :
      return false;
  }
  return true;
}