Gate duplicate
#1

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:


PHP код:
public OnPlayerEditDynamicObject(playeridobjectidresponseFloat:xFloat:yFloat:zFloat:rxFloat:ryFloat:rz)
{
    if(
response == EDIT_RESPONSE_FINAL)
    {
        new 
string[128];
        
        if(
GetPVarInt(playerid"gEdit") == 1)
        {
            if(
PlayerInfo[playerid][pAdmin] < 4) return SendClientMessageEx(playeridCOLOR_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(stringsizeof(string), "You have finished editing the open position of Gate ID: %d"gateid);
            
SendClientMessage(playeridCOLOR_WHITEstring);
            
DeletePVar(playerid"gEdit");
            
DeletePVar(playerid"EditingGateID");
        }
        if(
GetPVarInt(playerid"gEdit") == 2)
        {
            if(
PlayerInfo[playerid][pAdmin] < 4) return SendClientMessageEx(playeridCOLOR_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(stringsizeof(string), "You have finished editing the closed position of Gate ID: %d"gateid);
            
SendClientMessage(playeridCOLOR_WHITEstring);
            
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(playeridCOLOR_WHITE"You have stopped yourself from editing the gate.");
        }
    }
    return 
1;

PHP код:
else if(strcmp(x_job"open"true) == 0)
        {
            foreach(
Playeri)
            {
                if(
GetPVarInt(i"EditingGateID") == gateid && != playerid)
                {
                    
format(stringsizeof(string), "ERROR: %s (ID: %d) is currently editing this gate."GetPlayerNameEx(i), i);
                    return 
SendClientMessageEx(playeridCOLOR_WHITEstring);
                }
            }
            
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(playeridGateInfo[gateid][gGATE]);
            
format(stringsizeof(string), "You are now editing the open position of Gate %d."gateid);
            
SendClientMessage(playeridCOLOR_WHITEstring);
            
SendClientMessage(playerid0xFFFFAAAA"HINT: Hold {8000FF}~k~~PED_SPRINT~ {FFFFAA}to move your camera, press escape to cancel");
        }
        else if(
strcmp(x_job"closed"true) == 0)
        {
            foreach(
Playeri)
            {
                if(
GetPVarInt(i"EditingGateID") == gateid && != playerid)
                {
                    
format(stringsizeof(string), "ERROR: %s (ID: %d) is currently editing this gate."GetPlayerNameEx(i), i);
                    return 
SendClientMessageEx(playeridCOLOR_WHITEstring);
                }
            }
            
SetPVarInt(playerid"gEdit"2);
            
SetPVarInt(playerid"EditingGateID"gateid);
            
EditDynamicObject(playeridGateInfo[gateid][gGATE]);
            
format(stringsizeof(string), "You are now editing the closed position of Gate %d."gateid);
            
SendClientMessage(playeridCOLOR_WHITEstring);
            
SendClientMessage(playerid0xFFFFAAAA"HINT: Hold {8000FF}~k~~PED_SPRINT~ {FFFFAA}to move your camera, press escape to cancel");
        }
    } 
Reply


Messages In This Thread
Gate duplicate - by IndependentGaming - 20.09.2016, 16:22
Re: Gate duplicate - by IndependentGaming - 20.09.2016, 17:47
Re: Gate duplicate - by oMa37 - 20.09.2016, 17:52
Re: Gate duplicate - by IndependentGaming - 20.09.2016, 17:53
Re: Gate duplicate - by Shinja - 20.09.2016, 21:59
Re: Gate duplicate - by IndependentGaming - 21.09.2016, 15:03
Re: Gate duplicate - by oMa37 - 21.09.2016, 15:11
Re: Gate duplicate - by IndependentGaming - 21.09.2016, 15:31

Forum Jump:


Users browsing this thread: 1 Guest(s)