[MYSQL] Savegate
#1

i was trying to create an gate system but now the problem is that the gates wont be saving,when i create the gate , it saves okay with the coords but when i edit it , it wont update the coords and reloading it sends back to the old coords at the status where it was created.

Gated edit and Save gates
Код:
stock SaveGate(gateid)
{
	new iQuery[750], iFormat[212];
	strcat(iQuery, "UPDATE `GateInfo` SET ");
	mysql_format(MySQLPipeline, iFormat, sizeof(iFormat), "`ID` = '%d', ", gateid); strcat(iQuery, iFormat);
	mysql_format(MySQLPipeline, iFormat, sizeof(iFormat), "`X` = '%f', ", GateInfo[gateid][gateX]); strcat(iQuery, iFormat);
	mysql_format(MySQLPipeline, iFormat, sizeof(iFormat), "`Y` = '%f', ", GateInfo[gateid][gateY]); strcat(iQuery, iFormat);
	mysql_format(MySQLPipeline, iFormat, sizeof(iFormat), "`Z` = '%f', ", GateInfo[gateid][gateZ]); strcat(iQuery, iFormat);
	mysql_format(MySQLPipeline, iFormat, sizeof(iFormat), "`rotX` = '%f', ", GateInfo[gateid][gaterotX]); strcat(iQuery, iFormat);
	mysql_format(MySQLPipeline, iFormat, sizeof(iFormat), "`rotY` = '%f', ", GateInfo[gateid][gaterotY]); strcat(iQuery, iFormat);
	mysql_format(MySQLPipeline, iFormat, sizeof(iFormat), "`rotZ` = '%f', ", GateInfo[gateid][gaterotZ]); strcat(iQuery, iFormat);
	mysql_format(MySQLPipeline, iFormat, sizeof(iFormat), "`Interior` = %d, `VirtualWorld` = %d, ", GateInfo[gateid][gateInterior], GateInfo[gateid][gateVirtualWorld]); strcat(iQuery, iFormat);
    mysql_format(MySQLPipeline, iFormat, sizeof(iFormat), "`Model` = '%f', ", GateInfo[gateid][gateModel]); strcat(iQuery, iFormat);
	mysql_tquery(MySQLPipeline, iQuery);
	return 1;
}

else if(!strcmp(tmp, "edit", true, 4))
	{
		new atmid = GetClosestGate(playerid);
		if(atmid == -1) return SendClientError(playerid, "No Gate found!");
		if(GetPlayerDistanceToPointEx(playerid, GateInfo[atmid][gateX], GateInfo[atmid][gateY], GateInfo[atmid][gateZ]) < 8)
		{
		    EditDynamicObject(playerid, GateInfo[atmid][gateObject]);
		    gateedit[playerid] = 1;
		}
		else return SendClientError(playerid, "You are not close enough to an Gate right now!");
	}
also reloading command auto saves the gate

EditDyanmicObject
Код:
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;
					GateInfo[atmid][oldx] = x;
					GateInfo[atmid][oldy] = y;
					GateInfo[atmid][oldz] = z;
					return 1;
				}
			}
		}
Reply
#2

check if you didn't create the gate with createobject and you use maybe getdynamicobjectpos or else
Reply
#3

PHP код:
public OnPlayerEditDynamicObject(playeridobjectidresponseFloat:xFloat:yFloat:zFloat:rxFloat:ryFloat:rz)
{
    switch(
response)
    {
        case 
EDIT_RESPONSE_UPDATE:
        {
            if(
gateedit[playerid] == 1)
            {
                new 
atmid GetClosestGate(playerid);
                if(
GetPlayerDistanceToPointEx(playeridGateInfo[atmid][gateX], GateInfo[atmid][gateY], GateInfo[atmid][gateZ]) < 8)
                {
                    if(
GateInfo[atmid][gateObject] == objectid)
                    {
                        
GateInfo[atmid][oldx] = x;
                        
GateInfo[atmid][oldy] = y;
                        
GateInfo[atmid][oldz] = z;
                    }
                }
            }
        }
        case 
EDIT_RESPONSE_FINAL:
        {
            if(
gateedit[playerid] == 1)
            {
                new 
atmid GetClosestGate(playerid);
                if(
GetPlayerDistanceToPointEx(playeridGateInfo[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;
                    }
                }
            }
        }
    }
    return 
0;

or this improved one;

PHP код:
public OnPlayerEditDynamicObject(playeridobjectidresponseFloat:xFloat:yFloat:zFloat:rxFloat:ryFloat:rz)
{
    if(
gateedit[playerid] == 1)
    {
        new 
atmid GetClosestGate(playerid);
        if(
GetPlayerDistanceToPointEx(playeridGateInfo[atmid][gateX], GateInfo[atmid][gateY], GateInfo[atmid][gateZ]) < 8)
        {
            if(
GateInfo[atmid][gateObject] == objectid)
            {
                switch(
response)
                {
                    case 
EDIT_RESPONSE_UPDATE:
                    {
                        
GateInfo[atmid][oldx] = x;
                        
GateInfo[atmid][oldy] = y;
                        
GateInfo[atmid][oldz] = z;
                    }
                    case 
EDIT_RESPONSE_FINAL:
                    {
                        
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 
0;

Reply
#4

none of them worked still same thing, when gate reloads it goes back to created coords
Reply
#5

Because you are not saving it correctly.
Reply
#6

What you mean lol , if you check what i wrote at frist post the problem was " gate not saving the position" lol
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)