13.11.2015, 11:20
Hi guys,
So I'm working on a furniture system but for the life of me I can't find a way to detect what object is actually being edited currently by the player.
I've attempted to do a loop through all furniture and do an if statement to say if the objectid is equal to that furniture object currently selected in the loop, however that didn't work, I'm just completely out of ideas and I can't exactly show any code because all the code I have doesn't seem to be correct. However, this is what I have.
Currently the if(FurnitureObj[FurnLoop]) statement only selects the FIRST object in the loop, I can't find a way to say if that isn't the selected object, then continue the loop; This is literally impossible to explain
So I'm working on a furniture system but for the life of me I can't find a way to detect what object is actually being edited currently by the player.
I've attempted to do a loop through all furniture and do an if statement to say if the objectid is equal to that furniture object currently selected in the loop, however that didn't work, I'm just completely out of ideas and I can't exactly show any code because all the code I have doesn't seem to be correct. However, this is what I have.
pawn Код:
if(response == EDIT_RESPONSE_FINAL)
{
if(IsMovingFurniture[playerid] == true)
{
for(new FurnLoop = 0; FurnLoop < MAX_FURNITURE; FurnLoop++)
{
if(FurnitureObj[FurnLoop])
{
new query[500];
SetDynamicObjectPos(FurnitureObj[ FurnLoop ], fX, fY, fZ);
SetDynamicObjectRot(FurnitureObj[ FurnLoop ], fRotX, fRotY, fRotZ);
HouseFurni[ FurnLoop ] [FurnitureX] = fX;
HouseFurni[ FurnLoop ] [FurnitureY] = fY;
HouseFurni[ FurnLoop ] [FurnitureZ] = fZ;
HouseFurni[ FurnLoop ] [FurnitureRX] = fRotX;
HouseFurni[ FurnLoop ] [FurnitureRY] = fRotY;
HouseFurni[ FurnLoop ] [FurnitureRZ] = fRotZ;
format(query, sizeof(query), "UPDATE `furniture` SET FurnitureX='%f', FurnitureY='%f', FurnitureZ='%f', FurnitureRX='%f',\
FurnitureRY='%f', FurnitureRZ='%f' WHERE FurnitureID='%d'", fX, fY, fZ, fRotX, fRotY, fRotZ, HouseFurni[FurnLoop][FurnitureID]);
mysql_function_query(dbHandle, query, false, "", "");
IsMovingFurniture[playerid] = false;
MovingFurnitureID[playerid] = -1;
SendClientMessageF(playerid, COLOR_OOC, "Furniture ID: %d", HouseFurni[ FurnLoop ][FurnitureID]);
break;
}
}
}