array must be indexed problem
#1

i have an error and i tried all i know to try fix it but no result :\ pls help me

pawn Код:
new model_array[] = {456, 455, 578, 403, 514, 515, 525, 437, 431, 524, 408, 443, 433};
            if(GetPlayerMoney(playerid) >= VehiclesPrice[model_array[listitem]-400])
            {
                new Name[MAX_PLAYER_NAME];
                GetPlayerName(playerid, Name,sizeof(Name));
                new str[128];
                format(str,128,"%s bought a %s",Name,VehiclesName[model_array[listitem]-400]);
                CreateVehicle(model_array[listitem], 60.4640,-257.1053,1.5781, 0.0, 1, 1, -1);
            }
            else
            {
                SendClientMessage(playerid, 0xFF0000FF,"You cannot afford this vehicle.");
            }
error 033: array must be indexed (variable "VehiclesPrice") at the line
pawn Код:
if(GetPlayerMoney(playerid) >= VehiclesPrice[model_array[listitem]-400])
this is an exemple of the VehiclesPrice

pawn Код:
new VehiclesPrice[][] = {
{200000},{90000},{230000},{200000},{0},{125000},{700000},
{3500000},{400000},{400000},{90000},{500000},{130000},{110000},{0}
};
thx
Reply
#2

You need to set an appropriate index for your array.

pawn Код:
new VehiclesPrice[11][] = {
{200000},{90000},{230000},{200000},{0},{125000},{700000},
{3500000},{400000},{400000},{90000},{500000},{130000},{110000},{0}
};
You have 11 items. You can only set an unspecified size for your final dimension.

Alternatively, you're just creating integers, you can just replicate what you've done with model_array:

pawn Код:
new VehiclesPrice[] = {200000,90000,230000,200000,0,125000,700000,3500000,400000,400000,90000,500000,130000,110000,0};
Reply
#3

now i get this error :\

must be a constant expression; assumed zero

i did what you said
pawn Код:
new VehiclesPrice[212][] = {
200000,90000,230000,200000,0,125000,700000,
3500000,400000,400000,90000,500000,130000,110000,0,
280000,1500000,350000,87000,160000,170000,76000,
100000,1300000,1700000,15000000,120000,270000,0,
390000,0,240000,20000000,200000,410000,95000,85000,
260000,150000,190000,120000,0,1000000,450000,4000000,
90000,400000,1500000,100000,0,0,395000,
305000,190000,470000,180000,170000,1000000,100000,0,
400000,110000,55000,85000,0,0,110000,93000,
90000,0,260000,700000,0,0,105000,270000,
0,420000,79000,90000,400000,0,110000,130000,200000,
1000000,0,350000,0,235000,300000,130000,120000,
310000,2500000,1900000,85000,400000,100000,120000,
115000,0,2500000,2500000,2000000,235000,
430000,120000,175000,0,0,300000,0,1000000,
260000,350000,110000,110000,170000,400000,18000000,95000,
99000,150000,175000,120000,90000,97000,800000,
0,0,1000000,5000000,120000,140000,175000,
150000,0,0,2500000,85000,380000,130000,89000,
0,356000,82000,80000,400000,160000,80000,140000,
200000,350000,87000,160000,0,0,88000,130000,
180000,85000,98000,370000,0,114,115000,147000,
2000000,0,0,2000000,1000000,0,0,
117000,100000,25000000,165000,200000,120000,90000,200000,
0,80000,150000,80000,220000,1000000,100000,0,
80000,25000000,280000,0,700000,200000,200000,
200000,230000,86000,1500000,150000,230000,110000,
89000,0,0,10000,100000,0,
500000
};
if(GetPlayerMoney(playerid) >= VehiclesPrice[model_array[listitem]-400])
Reply
#4

i found ^^

thx for helping
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)