problem with an array inside an aray...
#1

hey all,

i was busy with my own house system, when i got stuck on this problem:

Код:
D:\Program Files\StreetRod\StreetRod 0.3e R2\filterscripts\HouseSystem.pwn(500) : error 001: expected token: "]", but found "-identifier-"
D:\Program Files\StreetRod\StreetRod 0.3e R2\filterscripts\HouseSystem.pwn(500) : error 029: invalid expression, assumed zero
D:\Program Files\StreetRod\StreetRod 0.3e R2\filterscripts\HouseSystem.pwn(500) : error 029: invalid expression, assumed zero
D:\Program Files\StreetRod\StreetRod 0.3e R2\filterscripts\HouseSystem.pwn(500) : fatal error 107: too many error messages on one line

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


4 Errors.
the code

pawn Код:
case 0: // red door
                    {
                        for(new i = 0; i < MAX_HOUSES;i++)//Loop threw all houses.
                        {
                            for(new f = 0; f < sizeof(HInfo[i][Furniture[]]); f++) // error line
                            {
                                if(HInfo[i][Furniture[f]] != -1)
                                {
                                    new Float:x, Float:y, Float:z, Float:zz;
                                    GetPlayerPos(playerid, x, y, z);
                                    zz = z-0.6;
                                    GetPosInFrontOfPlayer(playerid, x, y, 4);
                                    HInfo[i][Furniture[f]] = CreateDynamicObject(1504, x, y, zz, 0, 0, 0, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid), -1, 200.0);
                                    Streamer_UpdateEx(playerid, x, y, zz, GetPlayerVirtualWorld(playerid),GetPlayerInterior(playerid));
                                    EditDynamicObject(playerid, Furniture[playerid][f]);
                                    SendClientMessage(playerid, COLOR_YELLOW, "[FURNITURE]{FFFFFF}: you succesfully bought a red door for {7D7D7D}$175");
                                    SendClientMessage(playerid, COLOR_YELLOW, "[FURNITURE]{FFFFFF}: you can now edit your furniture object.");
                                    break;
                                }
                            }
                        }
                    }
and my array:

pawn Код:
enum HouseInfo//Naming the enum
{
    Owner[24],//This will be where it will store the house owner name, in a 24 bit size array.
    Owned,//To store if the house is owned or not.
    Price,//How much the house will cost.
    Float:XPos,//Float X position of the checkpoint
    Float:YPos,//Self explanatory.
    Float:ZPos,//Self explanatory.
    VirtualWorld,//The checkpoints virtual world.
    Text3D:HouseLabel,//That label where it says "Owned Price..."
    Furniture[20]
}
new HInfo[MAX_HOUSES][HouseInfo];//This is the var where we will read the house info.
isn't it possible to place an array INSIDE an array or something? or am i doing something wrong here?

greets
Reply
#2

pawn Код:
sizeof(HInfo[i][Furniture[]])
It doesn't work like that. You can do
pawn Код:
for(new f = 0; f != 20; f++)
or
pawn Код:
for(new f = 0; f != _:HouseInfo - _:Furniture; f++)
The second option will work only if the Furniture is last element of enumerator.
Reply
#3

alright ill use the last version , thanks
Reply
#4

eehm, now i got a new error.

it doesnt matter which one i use, both times it gives this error:

Код:
D:\Program Files\StreetRod\StreetRod 0.3e R2\filterscripts\HouseSystem.pwn(502) : error 028: invalid subscript (not an array or too many subscripts): "Furniture"
D:\Program Files\StreetRod\StreetRod 0.3e R2\filterscripts\HouseSystem.pwn(502) : warning 215: expression has no effect
D:\Program Files\StreetRod\StreetRod 0.3e R2\filterscripts\HouseSystem.pwn(502) : error 001: expected token: ";", but found "]"
D:\Program Files\StreetRod\StreetRod 0.3e R2\filterscripts\HouseSystem.pwn(502) : error 029: invalid expression, assumed zero
D:\Program Files\StreetRod\StreetRod 0.3e R2\filterscripts\HouseSystem.pwn(502) : fatal error 107: too many error messages on one line

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


4 Errors.
code:

pawn Код:
for(new i = 0; i < MAX_HOUSES;i++)//Loop threw all houses.
                        {
                            for(new f = 0; f != _:HouseInfo - _:Furniture; f++)
                            {
                                if(HInfo[i][Furniture[f]] != -1) // error line
                                {
                                    new Float:x, Float:y, Float:z, Float:zz;
                                    GetPlayerPos(playerid, x, y, z);
                                    zz = z-0.6;
                                    GetPosInFrontOfPlayer(playerid, x, y, 4);
                                    HInfo[i][Furniture[f]] = CreateDynamicObject(1504, x, y, zz, 0, 0, 0, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid), -1, 200.0);
                                    Streamer_UpdateEx(playerid, x, y, zz, GetPlayerVirtualWorld(playerid),GetPlayerInterior(playerid));
                                    EditDynamicObject(playerid, Furniture[playerid][f]);
                                    SendClientMessage(playerid, COLOR_YELLOW, "[FURNITURE]{FFFFFF}: you succesfully bought a red door for {7D7D7D}$175");
                                    SendClientMessage(playerid, COLOR_YELLOW, "[FURNITURE]{FFFFFF}: you can now edit your furniture object.");
                                    break;
                                }
                            }
                        }
Reply
#5

pawn Код:
HInfo[i][Furniture[f]] != -1
//to
HInfo[i][Furniture][f] != -1
Reply
#6

aw, thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)