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
#2

Anyone ?
Reply
#3

Can you show me the function 'CreateGate(gateid);'
Reply
#4

Quote:
Originally Posted by oMa37
Посмотреть сообщение
Can you show me the function 'CreateGate(gateid);'


PHP код:
CreateGate(gateid)
{
    switch(
GateInfo[gateid][gRenderHQ])
    {
        case 
1:
        {
            
GateInfo[gateid][gGATE] = CreateDynamicObject(GateInfo[gateid][gModel], GateInfo[gateid][gPosX], GateInfo[gateid][gPosY], GateInfo[gateid][gPosZ], GateInfo[gateid][gRotX], GateInfo[gateid][gRotY], GateInfo[gateid][gRotZ], GateInfo[gateid][gVW], GateInfo[gateid][gInt], -1100.0);
        }
        case 
2:
        {
            
GateInfo[gateid][gGATE] = CreateDynamicObject(GateInfo[gateid][gModel], GateInfo[gateid][gPosX], GateInfo[gateid][gPosY], GateInfo[gateid][gPosZ], GateInfo[gateid][gRotX], GateInfo[gateid][gRotY], GateInfo[gateid][gRotZ], GateInfo[gateid][gVW], GateInfo[gateid][gInt], -1200.0);
        }
        case 
3:
        {
            
GateInfo[gateid][gGATE] = CreateDynamicObject(GateInfo[gateid][gModel], GateInfo[gateid][gPosX], GateInfo[gateid][gPosY], GateInfo[gateid][gPosZ], GateInfo[gateid][gRotX], GateInfo[gateid][gRotY], GateInfo[gateid][gRotZ], GateInfo[gateid][gVW], GateInfo[gateid][gInt], -1300.0);
        }
        default:
        {
            
GateInfo[gateid][gGATE] = CreateDynamicObject(GateInfo[gateid][gModel], GateInfo[gateid][gPosX], GateInfo[gateid][gPosY], GateInfo[gateid][gPosZ], GateInfo[gateid][gRotX], GateInfo[gateid][gRotY], GateInfo[gateid][gRotZ], GateInfo[gateid][gVW], GateInfo[gateid][gInt], -175.0);
        }
    }

Reply
#5

As you SaveGates, you must have a func LoadGates ongamemodeinit otherwise they can't be saved/loaded, but also show us SaveGates
Reply
#6

Quote:
Originally Posted by Shinja
Посмотреть сообщение
As you SaveGates, you must have a func LoadGates ongamemodeinit otherwise they can't be saved/loaded, but also show us SaveGates
You don't understand.. My gates are saving and loading, only when I use the option "closed"

the gate duplicates..
Reply
#7

PHP код:
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");
        } 
Here you are setting the gEdit pVar to 2.

PHP код:
        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");
        } 
And here you are checking if the pVar == 2, And re-creating the Gate + saving it.

You may understand now why it duplicate.
Reply
#8

Quote:
Originally Posted by oMa37
Посмотреть сообщение
PHP код:
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");
        } 
Here you are setting the gEdit pVar to 2.

PHP код:
        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");
        } 
And here you are checking if the pVar == 2, And re-creating the Gate + saving it.

You may understand now why it duplicate.
So what do I need to do to fix this ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)