Gates not saving in edited position
#1

Hellow.
I was creating a dynamic gate system but now the problem is when i edit a gate after created it wont save at edited location.When i respawn it , it moved to the old position , to the one that was created.


Editdynamicobject.
Код:
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(objectid, oldX, oldY, oldZ);
	GetDynamicObjectRot(objectid, oldRotX, oldRotY, oldRotZ);
	if(response == EDIT_RESPONSE_FINAL)
	{
		new houseid = PlayerTemp[playerid][tmphouse];
		if(houseid != -1)
		{
			FurnitureLoop(f)
			{
				if(FurnitureInfo[houseid][f][furActive] != true) continue;
				if(FurnitureInfo[houseid][f][furObject] == objectid)
				{
					DestroyDynamicObject(FurnitureInfo[houseid][f][furObject]);
					FurnitureInfo[houseid][f][furX] = x;
					FurnitureInfo[houseid][f][furY] = y;
					FurnitureInfo[houseid][f][furZ] = z;
					FurnitureInfo[houseid][f][furrX] = rx;
					FurnitureInfo[houseid][f][furrY] = ry;
					FurnitureInfo[houseid][f][furrZ] = rz;
					ReloadFurniture(houseid, true, f);
					return 1;
				}
			}
		}
	 }
 if(gateedit[playerid] == 1)
                {
			new atmid = GetClosestGate(playerid);
		if(GetPlayerDistanceToPointEx(playerid, GateInfo[atmid][gateX], GateInfo[atmid][gateY], GateInfo[atmid][gateZ]) < 8)
			{
				if(GateInfo[atmid][gateObject] == objectid)
                 {
                 SetDynamicObjectPos(objectid, x, y, z);
		         SetDynamicObjectRot(objectid, rx, ry, rz);
    GateInfo[atmid][gateX] = x;
    GateInfo[atmid][gateY] = y;
    GateInfo[atmid][gateZ] = z;
    
					return 1;
				}
			}
	}
	if(response == EDIT_RESPONSE_CANCEL)
	{
		SetDynamicObjectPos(objectid, oldX, oldY, oldZ);
		SetDynamicObjectRot(objectid, oldRotX, oldRotY, oldRotZ);
	}
	return 1;
}
Saving Gates
Код:
stock SaveGate(atmid)
{
	new iQuery[500], iFormat[212];
 strcat(iQuery, "UPDATE `GateInfo` SET ");
	mysql_format(MySQLPipeline, iFormat, sizeof(iFormat), "`X` = '%f', ", GateInfo[atmid][gateX]);
	strcat(iQuery, iFormat);
	mysql_format(MySQLPipeline, iFormat, sizeof(iFormat), "`Y` = '%f', ", GateInfo[atmid][gateY]);
	strcat(iQuery, iFormat);
	mysql_format(MySQLPipeline, iFormat, sizeof(iFormat), "`Z` = '%f', ", GateInfo[atmid][gateZ]);
	strcat(iQuery, iFormat);
	mysql_format(MySQLPipeline, iFormat, sizeof(iFormat), "`rotX` = '%f', ", GateInfo[atmid][gaterotX]);
	strcat(iQuery, iFormat);
	mysql_format(MySQLPipeline, iFormat, sizeof(iFormat), "`rotY` = '%f', ", GateInfo[atmid][gaterotY]);
	strcat(iQuery, iFormat);
	mysql_format(MySQLPipeline, iFormat, sizeof(iFormat), "`rotZ` = '%f', ", GateInfo[atmid][gaterotZ]);
	strcat(iQuery, iFormat);
	mysql_format(MySQLPipeline, iFormat, sizeof(iFormat), "`Interior` = %d, ", GateInfo[atmid][gateInterior]);
	strcat(iQuery, iFormat);
	mysql_format(MySQLPipeline, iFormat, sizeof(iFormat), "`VirtualWorld` = %d WHERE `ID` = %d", GateInfo[atmid][gateVirtualWorld], atmid);
	strcat(iQuery, iFormat);
	mysql_format(MySQLPipeline, iFormat, sizeof(iFormat), "`Model` = %d, ", GateInfo[atmid][gateModel]);
	strcat(iQuery, iFormat);
	mysql_tquery(MySQLPipeline, iQuery);
	return 1;
}
Reply
#2

why u redifined this --> new FloatldX, FloatldY, FloatldZ, FloatldRotX, FloatldRotY, FloatldRotZ; ??

i think it's declared here
public OnPlayerEditDynamicObject(playerid, objectid, response, Float, Float:y, Float:z, Float:rx, Float:ry, Float:rz)

try to replace it
Reply
#3

Its not defined there lol.
read it.
Reply
#4

I don't see the SaveGate function called any where inside OnPlayerEditDynamicObject, how is it supposed to save?
Reply
#5

Well when gate is reloaded - it is auto saved.
Код:
stock ReloadGate(atmid, bool:tosave = true)
{
	if(tosave == true) SaveGate(atmid);
	SetTimerEx("OnReloadGate", 500, 0, "i", atmid);
}
Reply
#6

someone help please really need this one.
Reply
#7

Try this codes, i've added some codes to save gate positions after you clicked save button.

Код:
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(objectid, oldX, oldY, oldZ);
	GetDynamicObjectRot(objectid, oldRotX, oldRotY, oldRotZ);
	if(response == EDIT_RESPONSE_FINAL)
	{
		new houseid = PlayerTemp[playerid][tmphouse];
		if(houseid != -1)
		{
			FurnitureLoop(f)
			{
				if(FurnitureInfo[houseid][f][furActive] != true) continue;
				if(FurnitureInfo[houseid][f][furObject] == objectid)
				{
					DestroyDynamicObject(FurnitureInfo[houseid][f][furObject]);
					FurnitureInfo[houseid][f][furX] = x;
					FurnitureInfo[houseid][f][furY] = y;
					FurnitureInfo[houseid][f][furZ] = z;
					FurnitureInfo[houseid][f][furrX] = rx;
					FurnitureInfo[houseid][f][furrY] = ry;
					FurnitureInfo[houseid][f][furrZ] = rz;
					ReloadFurniture(houseid, true, f);
					return 1;
				}
			}
		}
		if(gateedit[playerid] == 1)
		{
			new atmid = GetClosestGate(playerid);
			if(GetPlayerDistanceToPointEx(playerid, GateInfo[atmid][gateX], GateInfo[atmid][gateY], GateInfo[atmid][gateZ]) < 8)
			{
				if(GateInfo[atmid][gateObject] == objectid)
				{
					GateInfo[atmid][gateX] = x;
					GateInfo[atmid][gateY] = y;
					GateInfo[atmid][gateZ] = z;    
					GateInfo[atmid][gaterotX] = rx;
					GateInfo[atmid][gaterotY] = ry;
					GateInfo[atmid][gaterotZ] = rz;
					SaveGate(atmid);
					return 1;
				}
			}
		}
	}
	if(gateedit[playerid] == 1)
	{
		new atmid = GetClosestGate(playerid);
		if(GetPlayerDistanceToPointEx(playerid, GateInfo[atmid][gateX], GateInfo[atmid][gateY], GateInfo[atmid][gateZ]) < 8)
		{
			if(GateInfo[atmid][gateObject] == objectid)
			{
				SetDynamicObjectPos(objectid, x, y, z);
				SetDynamicObjectRot(objectid, rx, ry, rz);
				GateInfo[atmid][gateX] = x;
				GateInfo[atmid][gateY] = y;
				GateInfo[atmid][gateZ] = z;
				GateInfo[atmid][gaterotX] = rx;
				GateInfo[atmid][gaterotY] = ry;
				GateInfo[atmid][gaterotZ] = rz;
				return 1;
			}
		}
	}
	if(response == EDIT_RESPONSE_CANCEL)
	{
		SetDynamicObjectPos(objectid, oldX, oldY, oldZ);
		SetDynamicObjectRot(objectid, oldRotX, oldRotY, oldRotZ);
	}
	return 1;
}
Reply
#8

Still same thing someone please help me out of this
Reply
#9

The problem is not at editing but seems like is the "SaveGate" cuz i tested it with a cmd which sets gate to my location and when i reload it , it still gets back to old location
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)