20.09.2016, 16:22
Hello, I have made an option to edit the open and closed position of the gate with the new samp editor.
But when I use this option it duplicate the gate in an object. When I restart the server everything works fine the 2 objects are gone see screen shot:
http://i.imgur.com/4uXoFDa.png
http://i.imgur.com/qYHLTjU.png
It is duplicating when I use the option closed
here is the code:
But when I use this option it duplicate the gate in an object. When I restart the server everything works fine the 2 objects are gone see screen shot:
http://i.imgur.com/4uXoFDa.png
http://i.imgur.com/qYHLTjU.png
It is duplicating when I use the option closed
here is the code:
PHP код:
public OnPlayerEditDynamicObject(playerid, objectid, response, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz)
{
if(response == EDIT_RESPONSE_FINAL)
{
new string[128];
if(GetPVarInt(playerid, "gEdit") == 1)
{
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][gPosX] = x;
GateInfo[gateid][gPosY] = y;
GateInfo[gateid][gPosZ] = z;
GateInfo[gateid][gRotX] = rx;
GateInfo[gateid][gRotY] = ry;
GateInfo[gateid][gRotZ] = rz;
CreateGate(gateid);
SaveGates();
format(string, sizeof(string), "You have finished editing the open position of Gate ID: %d", gateid);
SendClientMessage(playerid, COLOR_WHITE, string);
DeletePVar(playerid, "gEdit");
DeletePVar(playerid, "EditingGateID");
}
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");
}
}
if(response == EDIT_RESPONSE_CANCEL)
{
if(GetPVarType(playerid, "gEdit") == 1)
{
CreateGate(GetPVarInt(playerid, "EditingGateID"));
DeletePVar(playerid, "gEdit");
DeletePVar(playerid, "EditingGateID");
SendClientMessage(playerid, COLOR_WHITE, "You have stopped yourself from editing the gate.");
}
}
return 1;
}
PHP код:
else if(strcmp(x_job, "open", 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", 1);
SetPVarInt(playerid, "EditingGateID", gateid);
SetDynamicObjectPos(GateInfo[gateid][gGATE], GateInfo[gateid][gPosX], GateInfo[gateid][gPosY], GateInfo[gateid][gPosZ]);
SetDynamicObjectRot(GateInfo[gateid][gGATE], GateInfo[gateid][gRotX], GateInfo[gateid][gRotY], GateInfo[gateid][gRotZ]);
EditDynamicObject(playerid, GateInfo[gateid][gGATE]);
format(string, sizeof(string), "You are now editing the open 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");
}
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");
}
}