Having Trouble with Removing Furniture
#1

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:
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;
}
Code for SelectObject:
Код:
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;
}
Delete Furniture Dialog:
Код:
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);
		}
	}
Edit furniture save:
Код:
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;
	}
}
Reply
#2

This is how the objects are being saved:
Код:
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;
Here's the object file:
Код:
1723 180.0 180.0 -180.0 
1704 180.0 180.0 -180.0 
1705 180.0 180.0 -180.0 
1708 180.0 180.0 -180.0 
1368
1594
1663
1671
1711
1714
1715
1720
1735
1811
1825
2096
2120
2124
2310
2639
11665
1726
2566
1745
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
2090
2298
2299
2300
2301
2302
2563
2575
1771
2251
948
949
638
950
2243
2244
2245
2001
2010
2241
2242
3802
3806
3810
3811
1429
1518
1747
1748
1749
1750
1751
1752
1786
2091
2224
2296
2297
2311
2313
2314
2315
2319
1743
2078
2321
2204
2329
19172
19173
19174
19175
2047
2048
2049
2050
2051
1828
2815
2817
2818
2833
2834
2835
2836
2841
2842
2847
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2149
2514
2515
2516
2517
2518
2519
2520
2522
2528
2527
2526
2404
2405
2406
1372
1409
2819
2843
2844
2845
2846
1486
1543
1544
1950
1951
1734
1893
2069
1742
2894
2454.091064 -1701.317871 1013.507812 0.000000 0.000000 0.000000 1 2 1708
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)