[Solved] error 033: array must be indexed
#1

hELLO!

I'm new with pawn and trying to make an array function but i only get this stupid message (206) : error 033: array must be indexed.
Код:
cars[3][] =
	{

		{404},
		{451},
		{541}
};
Line 206: if(GetVehicleModel(carid2) == cars)
Reply
#2

You have to use it in a loop, e.g.
pawn Код:
for(new i; i < sizeof(cars); i++)
{
  if(GetVehicleModel(carid2) == cars[i])
  {
    // :D
  }
}
Reply
#3

That means?

Edit: like foreach?
Reply
#4

Check my last post
Reply
#5

Thanks. I will try
Reply
#6

Still the same error..

This is the cars that is for sale ordered in an array
pawn Код:
cars[3][] =
    {

        {404},
        {451},
        {541}
};
Here its gonna check if the car is id 404, 451 or 541..
pawn Код:
for(new i; i < sizeof(cars); i++)
            {

                if(GetVehicleModel(carid2) == cars[i]) // The error line
                {
                    SendClientMessage(playerid, COLOR_YELLOW, "This car costs $10000, type /buycarconfirm to buy it.");
                    car = 1;
                }

            }
Reply
#7

Anyone?
Reply
#8

pawn Код:
#define CARS 404, 451, 541

switch (GetVehicleModel(carid2))
{
  case CARS :
  {
    SendClientMessage(playerid, COLOR_YELLOW, "This car costs $10000, type /buycarconfirm to buy it.");
    car = 1;
  }
}
No loop, no array, faster, and it is same result

Reply
#9

Thanks so much! It worked!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)