SA-MP Forums Archive
Help me fix this. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help me fix this. (/showthread.php?tid=535063)



Help me fix this. - k2rl - 01.09.2014

I updates some plugins and the gate system doesn't work.. i do /creategate [ID] after that /gedit close - save the position- after that /gedit open -save- and the gate goes back to its old place where i did /creategate and doesn't work anymore.
PHP код:
CMD:gedit(playerid, params[])
{
    new 
string[128], idx;
    if(!
IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(
PlayerInfo[playerid][pAdmin] < 6) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
     if(
sscanf(params, "s[128]", params))
    {
        
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /gedit [option] [gateid]");
        
SendClientMessage(playerid, COLOR_GREY, "OPTIONS: object | close | open | speed | password");
        return 
1;
    }
    if(!
strcmp(params, "object", true, 5))
    {
        new 
object;
        if(
sscanf(params, "s[128]ii", params, idx, object)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /gedit object [gateid] [objectid]");
        if(!
GateInfo[idx][gModel]) return SendClientMessage(playerid, COLOR_GREY, "Invalid gate id.");
        if(
object == 0)
        {
            
format(string, sizeof(string), "%d", object);
            
cmd_deletegate(playerid, string);
            return 
1;
        }
        
GateInfo[idx][gModel] = object;
        
DestroyDynamicObject(GateInfo[idx][gGate]);
        
GateInfo[idx][gGate] = CreateDynamicObject(GateInfo[idx][gModel], GateInfo[idx][gCX], GateInfo[idx][gCY], GateInfo[idx][gCZ], GateInfo[idx][gCRX], GateInfo[idx][gCRY], GateInfo[idx][gCRZ]);
        
format(string, sizeof(string), " You have set gate ID %d's object ID to %d.", idx, object);
        
SendClientMessage(playerid, COLOR_WHITE, string);
    }
    else if(!
strcmp(params, "close", true, 5))
    {
        if(
sscanf(params, "s[128]i", params, idx)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /gedit position [gateid]");
        if(!
GateInfo[idx][gModel]) return SendClientMessage(playerid, COLOR_GREY, "Invalid gate id.");
        
gEdit[playerid] = 1;
        
gEditID[playerid] = idx;
        
GetDynamicObjectPos(GateInfo[idx][gGate], gPos[playerid][0], gPos[playerid][1], gPos[playerid][2]);
        
GetDynamicObjectRot(GateInfo[idx][gGate], gRot[playerid][0], gRot[playerid][1], gRot[playerid][2]);
        
EditDynamicObject(playerid, GateInfo[idx][gGate]);
        
format(string, sizeof(string), " You are now editing gate ID %d's closing position.", idx);
        
SendClientMessage(playerid, COLOR_WHITE, string);
    }
    else if(!
strcmp(params, "open", true, 4))
    {
        if(
sscanf(params, "s[128]i", params, idx)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /gedit open [gateid]");
        if(!
GateInfo[idx][gModel]) return SendClientMessage(playerid, COLOR_GREY, "Invalid gate id.");
        
gEdit[playerid] = 2;
        
gEditID[playerid] = idx;
        
GetDynamicObjectPos(GateInfo[idx][gGate], gPos[playerid][0], gPos[playerid][1], gPos[playerid][2]);
        
GetDynamicObjectRot(GateInfo[idx][gGate], gRot[playerid][0], gRot[playerid][1], gRot[playerid][2]);
        
EditDynamicObject(playerid, GateInfo[idx][gGate]);
        
format(string, sizeof(string), " You are now editing gate ID %d's opening position.", idx);
        
SendClientMessage(playerid, COLOR_WHITE, string);
    }
    else if(!
strcmp(params, "speed", true, 5))
    {
        new 
Float:speed;
        if(
sscanf(params, "s[128]if", params, idx, speed)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /gedit open [gateid] [speed]");
        if(!
GateInfo[idx][gModel]) return SendClientMessage(playerid, COLOR_GREY, "Invalid gate id.");
        
GateInfo[idx][gSpeed] = speed;
        
format(string, sizeof(string), " You have set gate ID %d's moving speed to %f.", idx, speed);
        
SendClientMessage(playerid, COLOR_WHITE, string);
    }
    else if(!
strcmp(params, "password", true, 8))
    {
        new 
password[256];
        if(
sscanf(params, "s[128]is[256]", params, idx, password)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /gedit open [gateid] [password]");
        if(!
GateInfo[idx][gModel]) return SendClientMessage(playerid, COLOR_GREY, "Invalid gate id.");
        
format(GateInfo[idx][gPassword], 256, "%s", password);
        
format(string, sizeof(string), " You have set gate ID %d's password to {FF6347}%s", idx, password);
        
SendClientMessage(playerid, COLOR_WHITE, string);
    }
    return 
1;
}