[Solved] error 033: 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: [Solved] error 033: array must be indexed (
/showthread.php?tid=72795)
[Solved] error 033: array must be indexed -
hanzen - 11.04.2009
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)
Re: error 033: array must be indexed -
ICECOLDKILLAK8 - 11.04.2009
You have to use it in a loop, e.g.
pawn Код:
for(new i; i < sizeof(cars); i++)
{
if(GetVehicleModel(carid2) == cars[i])
{
// :D
}
}
Re: error 033: array must be indexed -
hanzen - 11.04.2009
That means?
Edit: like foreach?
Re: error 033: array must be indexed -
ICECOLDKILLAK8 - 11.04.2009
Check my last post
Re: error 033: array must be indexed -
hanzen - 11.04.2009
Thanks. I will try
Re: error 033: array must be indexed -
hanzen - 11.04.2009
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;
}
}
Re: error 033: array must be indexed -
hanzen - 11.04.2009
Anyone?
Re: error 033: array must be indexed -
Nubotron - 11.04.2009
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
Re: error 033: array must be indexed -
hanzen - 11.04.2009
Thanks so much! It worked!