16.05.2017, 18:40
So, I've made a working furniture system. It saves properly and everything when I plant the object. When I edit the object, it doesn't rewrite it. It saves it there but when I exit and reenter the house, it is back to where I originally placed it. Also, when I delete it, it deletes temporarily but when I exit and reenter the house, it's back. How can I make it remove from the file it's saved?
Code for Edit & Delete furniture:
Code for SelectObject:
Delete Furniture Dialog:
Edit furniture save:
Code for Edit & Delete furniture:
pawn Код:
CMD:deletefurn(playerid, params[])
{
new holder[1000];
new hworld = GetPlayerVirtualWorld(playerid);
new house = PlayerInfo[playerid][HouseID];
if(house == 0) return SCM(playerid, COLOR_LIGHTRED, "You don't own a house.");
for(new h = 1; h < sizeof(HouseInfo); h++)
{
if(hworld == HouseInfo[h][hInsideWorld])
{
if(house == HouseInfo[h][hInsideWorld])
{
SelectObject(playerid);
DeletingFurn[playerid] = 1;
}
}
}
return 1;
}
CMD:editfurn(playerid, params[])
{
new holder[1000];
new hworld = GetPlayerVirtualWorld(playerid);
new house = PlayerInfo[playerid][HouseID];
if(house == 0) return SCM(playerid, COLOR_LIGHTRED, "You don't own a house.");
for(new h = 1; h < sizeof(HouseInfo); h++)
{
if(hworld == HouseInfo[h][hInsideWorld])
{
if(house == HouseInfo[h][hInsideWorld])
{
SelectObject(playerid);
EditingFurn[playerid] = 1;
}
}
}
return 1;
}
Код:
public OnPlayerSelectDynamicObject(playerid, objectid, modelid, Float:x, Float:y, Float:z) { new holder[1000]; new hworld = GetPlayerVirtualWorld(playerid); new house = PlayerInfo[playerid][HouseID]; if(house == 0) return SCM(playerid, COLOR_LIGHTRED, "You don't own a house."); for(new h = 1; h < sizeof(HouseInfo); h++) { if(hworld == HouseInfo[h][hInsideWorld]) { if(house == HouseInfo[h][hInsideWorld]) { if(DeletingFurn[playerid] == 1) { EDIT_OBJECT[playerid] = objectid; ShowPlayerDialog(playerid, DIALOG_DELETE_FURNITURE, DIALOG_STYLE_MSGBOX, "{FFFFFF}Furniture Deletion", "{FFFFFF}You are about to delete a furniture object, are you sure you want to?", "Yes", "No"); } if(EditingFurn[playerid] == 1) { EditDynamicObject(playerid, objectid); } } } } return 1; }
Код:
if(dialogid == DIALOG_DELETE_FURNITURE) { if(!response) { SendClientMessage(playerid, COLOR_LIGHTRED, "You cancelled deleting the furniture!"); DeletingFurn[playerid] = 0; Streamer_Update(playerid, 0); return 1; } if(response) { DestroyDynamicObject(EDIT_OBJECT[playerid]); DestroyObject(EDIT_OBJECT[playerid]); DeletingFurn[playerid] = 0; Streamer_Update(playerid, 0); } }
Код:
public OnPlayerEditDynamicObject(playerid, objectid, response, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz) { new Float:oldX, Float:oldY, Float:oldZ, Float:oldRotX, Float:oldRotY, Float:oldRotZ; GetDynamicObjectPos(Object, oldX, oldY, oldZ); GetDynamicObjectRot(Object, oldRotX, oldRotY, oldRotZ); new Float:OX, Float:OY, Float:OZ, Float:ORX, Float:ORY, Float:ORZ, OVW, OINT; if(response == EDIT_RESPONSE_FINAL) { new string[254]; OVW = GetPlayerVirtualWorld(playerid); OINT = GetPlayerInterior(playerid); GetDynamicObjectPos(objectid, OX, OY, OZ); GetDynamicObjectRot(objectid, ORX, ORY, ORZ); format(string, sizeof(string), "User: %s", GetName(playerid)); AddObjectToFile(OBJECT_FILE_NAME, OX, OY, OZ, ORX, ORY, ORZ, OVW, OINT, string); SendClientMessage(playerid, COLOR_LIGHTRED, "Object placed."); format(string, sizeof(string), "Object model %i spawned at %f, %f, %f, with rotation %f, %f, %f,", oModel, OX, OY, OZ, ORX, ORY, ORZ); SendClientMessage(playerid, 0xD8D8D8FF, string); format(string, sizeof(string), "Object world %i interior id %i", OVW, OINT); SendClientMessage(playerid, 0xD8D8D8FF, string); CreateDynamicObject(oModel, Float:OX, Float:OY, Float:OZ, Float:ORX, Float:ORY, Float:ORZ, OVW, OINT); DestroyDynamicObject(Object); Streamer_Update(playerid, 0); EditingFurn[playerid] = 0; } if(response == EDIT_RESPONSE_CANCEL) { SetDynamicObjectPos(objectid, oldX, oldY, oldZ); SetDynamicObjectRot(objectid, oldRotX, oldRotY, oldRotZ); Streamer_Update(playerid, 0); EditingFurn[playerid] = 0; } }