Small help
#1

Okay so im loading some objects from the SQL and storing them into HouseInfo[houseid][TempObject]. Well in other words im making funiture system.

Now my issue is simple, HouseInfo[houseid][TempObject] will store only 1 object into it, not all house objects, how can I store like 10 or such?

pawn Код:
for(new x = 0; x < MAX_HOUSES;x++) {
                if(HouseInfo[x][HID] == FurnitureInfo[i][FrMasterID]) {
                    HouseInfo[x][HouseObject] = CreateDynamicObject(FurnitureInfo[i][FrModelID],FurnitureInfo[i][FrPos][0],FurnitureInfo[i][FrPos][1],FurnitureInfo[i][FrPos][2],FurnitureInfo[i][FrRot][1],FurnitureInfo[i][FrRot][2],FurnitureInfo[i][FrRot][2],FurnitureInfo[i][FrWorld],FurnitureInfo[i][FrInterior]);
                }
            }

Basically my problem is
pawn Код:
HouseInfo[x][HouseObject] = CreateDynamicObject(FurnitureInfo[i][FrModelID],FurnitureInfo[i][FrPos][0],FurnitureInfo[i][FrPos][1],FurnitureInfo[i][FrPos][2],FurnitureInfo[i][FrRot][1],FurnitureInfo[i][FrRot][2],FurnitureInfo[i][FrRot][2],FurnitureInfo[i][FrWorld],FurnitureInfo[i][FrInterior]);
will store only 1 object into it, not all of them.

I know the problem but I dont know how to resolve it

Basically what im trying to achieve is
pawn Код:
HouseInfo[x][HouseObject][0]
HouseInfo[x][HouseObject][1]
HouseInfo[x][HouseObject][2]
And make it store all of the objects inside them. Well in this case it should store 3 objects in HouseInfo[x][HouseObject]



Manualy it would be something like
pawn Код:
HouseInfo[houseid][HouseObject][0] = CreateDynamicObject...
HouseInfo[houseid][HouseObject][1] = CreateDynamicObject...
HouseInfo[houseid][HouseObject][2] = CreateDynamicObject...
But I want to have it automaticly store it all inside that loop
Reply
#2

You need to change your enum.
pawn Код:
#define MAX_HOUSE_OBJECTS 100

enum (your enum's name)
{
    HouseObjects[MAX_HOUSE_OBJECTS]
}

new HouseInfo[MAX_HOUSES][(your enum'
s name)];
Now you can use the enum like HouseInfo[houseid][HouseObjects][1]
Reply
#3

Hmmmm, thats actually smart, thanks
Reply
#4

So how do I combine it all together?
pawn Код:
for(new x = 0; x < MAX_HOUSES;x++) {
                if(HouseInfo[x][HID] == FurnitureInfo[i][FrMasterID]) {
                    for(new p = 0; p < MAX_HOUSE_OBJECTS;p++) {
                        HouseObj[x][HouseObjects][p] = CreateDynamicObject(FurnitureInfo[i][FrModelID],FurnitureInfo[i][FrPos][0],FurnitureInfo[i][FrPos][1],FurnitureInfo[i][FrPos][2],FurnitureInfo[i][FrRot][1],FurnitureInfo[i][FrRot][2],FurnitureInfo[i][FrRot][2],FurnitureInfo[i][FrWorld],FurnitureInfo[i][FrInterior]);
                    }
                }
            }
Something like that or?
Reply
#5

Yeah
Reply
#6

Its either that part doesnt work or I fucked something else up.

There are 2 problems that im having at the moment
pawn Код:
enum FrObj
{
    HouseObjects[MAX_HOUSE_OBJECTS]
}

new FrntObjects[MAX_HOUSES][FrObj];



Loading furniture
pawn Код:
for(new x = 0; x < MAX_HOUSES;x++) {
                if(HouseInfo[x][HID] == FurnitureInfo[i][FrMasterID]) {
                    for(new p = 0; p < MAX_HOUSE_OBJECTS;p++) {
                        FrntObjects[x][HouseObjects][p] = CreateDynamicObject(FurnitureInfo[i][FrModelID],FurnitureInfo[i][FrPos][0],FurnitureInfo[i][FrPos][1],FurnitureInfo[i][FrPos][2],FurnitureInfo[i][FrRot][1],FurnitureInfo[i][FrRot][2],FurnitureInfo[i][FrRot][2],FurnitureInfo[i][FrWorld],FurnitureInfo[i][FrInterior]);
                    }
                }
            }


And the command Im using to edit it (Important part of the code)
pawn Код:
if(HouseInfo[x][HID] == FurnitureInfo[furnitureid][FrMasterID]){
                    for(new p = 0; p < MAX_HOUSE_OBJECTS;p++){
                            GetDynamicObjectPos(FrntObjects[x][HouseObjects][p],xPos[0],xPos[1],xPos[2]);
                            if(IsPlayerInRangeOfPoint(playerid,10,xPos[0],xPos[1],xPos[2])) {
                                    Streamer_UpdateEx(playerid,mPos[0],mPos[1],mPos[2],GetPlayerVirtualWorld(playerid),GetPlayerInterior(playerid));
                                    EditDynamicObject(playerid,FrntObjects[x][HouseObjects][p]);
                                    EditingFurniture[playerid] = 2;
                        }
                    }
                }


Now what actually happends is:
1. It creates objects but when Im editing it there are 2 objects. Aka if I make object ID: 2820 and edit I start to move it, there will be 1 more object at the same coords where I started editing it. Aka 2 created objects on the same place. When I reload the server (gmx) it will re-create those objects at new position but still there will be 2 of them
2. It allows me to edit only 1 object. If I create object ID: 2820 and then create object ID: 1760, it will allow me only to edit last created object.


Just to break confusion, this code only checks if the Furnitures Master ID is same as House ID (works)
pawn Код:
if(HouseInfo[x][HID] == FurnitureInfo[furnitureid][FrMasterID])






NOTE EDIT: I forgot to add, this is the way how I loop thru SQL for the furniture
pawn Код:
for(new i = 0; i < rows && i < MAX_FURNITURE; i++)


Full command
pawn Код:
dcmd_editfurniture(playerid,params[]) {
    #pragma unused params
    new Float:xPos[3],Float:mPos[3];
    GetPlayerPos(playerid,mPos[0],mPos[1],mPos[2]);
    for(new x = 0; x < MAX_HOUSES;x++) { //Loop thru all houses
        if(IsPlayerInRangeOfPoint(playerid,100,HouseInfo[x][ExitX],HouseInfo[x][ExitY],HouseInfo[x][ExitZ])) { //Is player in range of house exits
            if(HouseInfo[x][HID] == AccInfo[playerid][HouseOwner]) { //if the house id is the same as players House key
                if(HouseInfo[x][HID] == FurnitureInfo[furnitureid][FrMasterID]){ //if the house ids and furniture Master ID is the same. If the Furniture belongs to house
                    for(new p = 0; p < MAX_HOUSE_OBJECTS;p++){ //Loop thru all house created objects
                            GetDynamicObjectPos(FrntObjects[x][HouseObjects][p],xPos[0],xPos[1],xPos[2]); //getting object position
                            if(IsPlayerInRangeOfPoint(playerid,3,xPos[0],xPos[1],xPos[2])) { //if the player is in range of the object that I got the position
                                    Streamer_UpdateEx(playerid,mPos[0],mPos[1],mPos[2],GetPlayerVirtualWorld(playerid),GetPlayerInterior(playerid));
                                    EditDynamicObject(playerid,FrntObjects[x][HouseObjects][p]);
                                    EditingFurniture[playerid] = 2;
                        }
                    }
                }
            }
        }
    }
    return true;
}
Reply
#7

Ive done a bit of debugging and looks like the problem is that when the objects are created, they are all stored in the same FrntObjects[x][HouseObjects][p]
Meaning that all of them are saved inside for example
pawn Код:
FrntObjects[x][HouseObjects][0]
so the last object created will be edited only.

Can anyone help?
Reply
#8

Bump
Reply
#9

You must assign the furniture to the houseid
Reply
#10

I am
FrntObjects[x][HouseObjects][p]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)