10.02.2013, 18:37
Because it's hard to change the code to that can compile to my GM.
Here is code from LC:RP
Here is code from LC:RP
PHP код:
CMD:creategate(playerid, params[])
{
new string[128], object;
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(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on admin duty.");
if(sscanf(params, "i", object)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /creategate [objectid]");
for(new idx=1; idx<MAX_GATES; idx++)
{
if(!GateInfo[idx][gModel])
{
GetPlayerPos(playerid, GateInfo[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(playerid, GateInfo[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(string, sizeof(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(string, COLOR_WHITE, GateInfo[idx][gCX], GateInfo[idx][gCY], GateInfo[idx][gCZ], 10);
// Text
format(string, sizeof(string), "AdmWarn: %s has created gate ID %d. (Object: %d)", RPN(playerid), idx, object);
SendAdminMessage(COLOR_DARKRED, 1, string);
Log("logs/gates.log", string);
idx = MAX_GATES;
}
}
return 1;
}
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(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on admin duty.");
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;
}