Moveable Gates
#5

Because it's hard to change the code to that can compile to my GM.

Here is code from LC:RP
PHP код:
CMD:creategate(playeridparams[])
{
    new 
string[128], object;
       if(!
IsPlayerLoggedIn(playerid)) return SendClientMessage(playeridCOLOR_GREY"You need to login first before using any command.");
    if(
PlayerInfo[playerid][pAdmin] < 6) return SendClientMessage(playeridCOLOR_GREY"You are not authorized to use this command.");
    if(!
aDuty[playerid]) return SendClientMessage(playeridCOLOR_GREY"You are not on admin duty.");
    if(
sscanf(params"i"object)) return SendClientMessage(playeridCOLOR_WHITE"USAGE: /creategate [objectid]");
    for(new 
idx=1idx<MAX_GATESidx++)
    {
        if(!
GateInfo[idx][gModel])
        {
            
GetPlayerPos(playeridGateInfo[idx][gCX], GateInfo[idx][gCY], GateInfo[idx][gCZ]);
              
GateInfo[idx][gModel] = object;
            
GateInfo[idx][gCX] = GateInfo[idx][gCX] + 2;
            
GateInfo[idx][gCY] = GateInfo[idx][gCY] + 2;
            
GateInfo[idx][gCRX] = 0;
            
GateInfo[idx][gCRY] = 0;
            
GateInfo[idx][gCRZ] = 0;
            
GetPlayerPos(playeridGateInfo[idx][gOX], GateInfo[idx][gOY], GateInfo[idx][gOZ]);
            
GateInfo[idx][gOX] = GateInfo[idx][gOX] + 2;
            
GateInfo[idx][gOY] = GateInfo[idx][gOY] + 2;
            
GateInfo[idx][gORX] = 0;
            
GateInfo[idx][gORY] = 0;
            
GateInfo[idx][gORZ] = 0;
            
GateInfo[idx][gStatus] = 0;
            
format(GateInfo[idx][gPassword], 256"");
            
GateInfo[idx][gSpeed] = 2;
            
// Creating
            
format(stringsizeof(string), "Gate ID: %d"idx);
            
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]);
            
GateInfo[idx][gText] = CreateDynamic3DTextLabel(stringCOLOR_WHITEGateInfo[idx][gCX], GateInfo[idx][gCY], GateInfo[idx][gCZ], 10);
            
// Text
            
format(stringsizeof(string), "AdmWarn: %s has created gate ID %d. (Object: %d)"RPN(playerid), idxobject);
            
SendAdminMessage(COLOR_DARKRED1string);
            
Log("logs/gates.log"string);
            
idx MAX_GATES;
        }
    }
    return 
1;

PHP код:
CMD:gedit(playeridparams[])
{
    new 
string[128], idx;
    if(!
IsPlayerLoggedIn(playerid)) return SendClientMessage(playeridCOLOR_GREY"You need to login first before using any command.");
    if(
PlayerInfo[playerid][pAdmin] < 6) return SendClientMessage(playeridCOLOR_GREY"You are not authorized to use this command.");
    if(!
aDuty[playerid]) return SendClientMessage(playeridCOLOR_GREY"You are not on admin duty.");
     if(
sscanf(params"s[128]"params))
    {
        
SendClientMessage(playeridCOLOR_WHITE"USAGE: /gedit [option] [gateid]");
        
SendClientMessage(playeridCOLOR_GREY"OPTIONS: object | close | open | speed | password");
        return 
1;
    }
    if(!
strcmp(params"object"true5))
    {
        new 
object;
        if(
sscanf(params"s[128]ii"paramsidxobject)) return SendClientMessage(playeridCOLOR_WHITE"USAGE: /gedit object [gateid] [objectid]");
        if(!
GateInfo[idx][gModel]) return SendClientMessage(playeridCOLOR_GREY"Invalid gate id.");
        if(
object == 0)
        {
            
format(stringsizeof(string), "%d"object);
            
cmd_deletegate(playeridstring);
            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(stringsizeof(string), " You have set gate ID %d's object ID to %d."idxobject);
        
SendClientMessage(playeridCOLOR_WHITEstring);
    }
    else if(!
strcmp(params"close"true5))
    {
        if(
sscanf(params"s[128]i"paramsidx)) return SendClientMessage(playeridCOLOR_WHITE"USAGE: /gedit position [gateid]");
        if(!
GateInfo[idx][gModel]) return SendClientMessage(playeridCOLOR_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(playeridGateInfo[idx][gGate]);
        
format(stringsizeof(string), " You are now editing gate ID %d's closing position."idx);
        
SendClientMessage(playeridCOLOR_WHITEstring);
    }
    else if(!
strcmp(params"open"true4))
    {
        if(
sscanf(params"s[128]i"paramsidx)) return SendClientMessage(playeridCOLOR_WHITE"USAGE: /gedit open [gateid]");
        if(!
GateInfo[idx][gModel]) return SendClientMessage(playeridCOLOR_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(playeridGateInfo[idx][gGate]);
        
format(stringsizeof(string), " You are now editing gate ID %d's opening position."idx);
        
SendClientMessage(playeridCOLOR_WHITEstring);
    }
    else if(!
strcmp(params"speed"true5))
    {
        new 
Float:speed;
        if(
sscanf(params"s[128]if"paramsidxspeed)) return SendClientMessage(playeridCOLOR_WHITE"USAGE: /gedit open [gateid] [speed]");
        if(!
GateInfo[idx][gModel]) return SendClientMessage(playeridCOLOR_GREY"Invalid gate id.");
        
GateInfo[idx][gSpeed] = speed;
        
format(stringsizeof(string), " You have set gate ID %d's moving speed to %f."idxspeed);
        
SendClientMessage(playeridCOLOR_WHITEstring);
    }
    else if(!
strcmp(params"password"true8))
    {
        new 
password[256];
        if(
sscanf(params"s[128]is[256]"paramsidxpassword)) return SendClientMessage(playeridCOLOR_WHITE"USAGE: /gedit open [gateid] [password]");
        if(!
GateInfo[idx][gModel]) return SendClientMessage(playeridCOLOR_GREY"Invalid gate id.");
        
format(GateInfo[idx][gPassword], 256"%s"password);
        
format(stringsizeof(string), " You have set gate ID %d's password to {FF6347}%s"idxpassword);
        
SendClientMessage(playeridCOLOR_WHITEstring);
    }
    return 
1;

Reply


Messages In This Thread
Moveable Gates - by FaZeRs - 10.02.2013, 16:51
Re: Moveable Gates - by batonsa - 10.02.2013, 16:53
Re: Moveable Gates - by FaZeRs - 10.02.2013, 16:56
Re: Moveable Gates - by batonsa - 10.02.2013, 17:47
Re: Moveable Gates - by FaZeRs - 10.02.2013, 18:37

Forum Jump:


Users browsing this thread: 2 Guest(s)