Originally Posted by oMa37
PHP код:
else if(strcmp(x_job, "closed", true) == 0)
{
foreach(Player, i)
{
if(GetPVarInt(i, "EditingGateID") == gateid && i != playerid)
{
format(string, sizeof(string), "ERROR: %s (ID: %d) is currently editing this gate.", GetPlayerNameEx(i), i);
return SendClientMessageEx(playerid, COLOR_WHITE, string);
}
}
SetPVarInt(playerid, "gEdit", 2);
SetPVarInt(playerid, "EditingGateID", gateid);
EditDynamicObject(playerid, GateInfo[gateid][gGATE]);
format(string, sizeof(string), "You are now editing the closed position of Gate %d.", gateid);
SendClientMessage(playerid, COLOR_WHITE, string);
SendClientMessage(playerid, 0xFFFFAAAA, "HINT: Hold {8000FF}~k~~PED_SPRINT~ {FFFFAA}to move your camera, press escape to cancel");
}
Here you are setting the gEdit pVar to 2.
PHP код:
if(GetPVarInt(playerid, "gEdit") == 2)
{
if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessageEx(playerid, COLOR_GREY, "You are not authorized to perform this action!");
new gateid = GetPVarInt(playerid, "EditingGateID");
GateInfo[gateid][gPosXM] = x;
GateInfo[gateid][gPosYM] = y;
GateInfo[gateid][gPosZM] = z;
GateInfo[gateid][gRotXM] = rx;
GateInfo[gateid][gRotYM] = ry;
GateInfo[gateid][gRotZM] = rz;
CreateGate(gateid);
SaveGates();
format(string, sizeof(string), "You have finished editing the closed position of Gate ID: %d", gateid);
SendClientMessage(playerid, COLOR_WHITE, string);
DeletePVar(playerid, "gEdit");
DeletePVar(playerid, "EditingGateID");
}
And here you are checking if the pVar == 2, And re-creating the Gate + saving it.
You may understand now why it duplicate.
|