How to make this command available even for rcon admins? -
[UE]Milan - 24.11.2015
I'm kindda newbie to scripting and i was wondering, How to make sure that this CMD executes succesfully if the player is logged in as an rcon admin, PLease reply with the full cmd code since I dont know where to add stuffs.
Код HTML:
CMD:makeadmin(playerid, params[])
{
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(PlayerInfo[playerid][pAdmin] >= 6)
{
new playerb, admin, string[128];
if(sscanf(params, "ui", playerb, admin)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /makeadmin [playerid] [level]");
if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
if(PlayerInfo[playerb][pAdmin] != admin)
{
new log[256];
if(PlayerInfo[playerb][pAdmin] < admin)
{
format(string, sizeof(string), "AdmWarn: %s has {33AA33}promoted {AA3333}%s to level {33AA33}%d {AA3333}admin.", RPN(playerid), RPN(playerb), admin);
format(log, sizeof(log), "AdmWarn: %s (%s) has promoted %s (%s) to level %d admin.", RPN(playerid), RPIP(playerid), RPN(playerb), RPIP(playerb), admin);
}
else if(PlayerInfo[playerb][pAdmin] > admin)
{
format(string, sizeof(string), "AdmWarn: %s has {FF9900}demoted {AA3333}%s to level {FF9900}%d {AA3333}admin.", RPN(playerid), RPN(playerb), admin);
format(log, sizeof(log), "AdmWarn: %s (%s) has demoted %s (%s) to level %d admin.", RPN(playerid), RPIP(playerid), RPN(playerb), RPIP(playerb), admin);
}
Log("logs/makeadmin.log", log);
PlayerInfo[playerb][pAdmin] = admin;
PlayerInfo[playerb][pSafeAdmin] = 1;
SendAdminMessage(COLOR_DARKRED, 1, string);
if(!PlayerInfo[playerb][pAdmin])
{
PlayerInfo[playerb][pSafeAdmin] = 0;
PlayerInfo[playerid][pGangMod] = 0;
PlayerInfo[playerid][pFacMod] = 0;
PlayerInfo[playerid][pBanAppealer] = 0;
SendClientMessage(playerb, COLOR_DARKRED, string);
}
new file[32];
format(file, sizeof(file), "users/%s.ini", RPNU(playerb));
format(file, sizeof(file), "users/%s.ini", dini_Get(file, "AdminName"));
if(dini_Exists(file))
{
dini_IntSet(file, "Admin", PlayerInfo[playerb][pAdmin]);
}
format(file, sizeof(file), "users/%s.ini", RPNU(playerb));
if(dini_Int(file, "AdminAccount") == 1)
{
format(file, sizeof(file), "users/%s.ini", dini_Get(file, "OldName"));
dini_IntSet(file, "Admin", PlayerInfo[playerb][pAdmin]);
}
}
else SendClientMessage(playerid, COLOR_GREY, "Player already has this admin level.");
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
}
return 1;
}
Re: How to make this command available even for rcon admins? -
Yochui - 24.11.2015
pawn Код:
CMD:makeadmin(playerid, params[])
{
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(PlayerInfo[playerid][pAdmin] >= 6 || IsPlayerAdmin(playerid))
{
new playerb, admin, string[128];
if(sscanf(params, "ui", playerb, admin)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /makeadmin [playerid] [level]");
if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
if(PlayerInfo[playerb][pAdmin] != admin)
{
new log[256];
if(PlayerInfo[playerb][pAdmin] < admin)
{
format(string, sizeof(string), "AdmWarn: %s has {33AA33}promoted {AA3333}%s to level {33AA33}%d {AA3333}admin.", RPN(playerid), RPN(playerb), admin);
format(log, sizeof(log), "AdmWarn: %s (%s) has promoted %s (%s) to level %d admin.", RPN(playerid), RPIP(playerid), RPN(playerb), RPIP(playerb), admin);
}
else if(PlayerInfo[playerb][pAdmin] > admin)
{
format(string, sizeof(string), "AdmWarn: %s has {FF9900}demoted {AA3333}%s to level {FF9900}%d {AA3333}admin.", RPN(playerid), RPN(playerb), admin);
format(log, sizeof(log), "AdmWarn: %s (%s) has demoted %s (%s) to level %d admin.", RPN(playerid), RPIP(playerid), RPN(playerb), RPIP(playerb), admin);
}
Log("logs/makeadmin.log", log);
PlayerInfo[playerb][pAdmin] = admin;
PlayerInfo[playerb][pSafeAdmin] = 1;
SendAdminMessage(COLOR_DARKRED, 1, string);
if(!PlayerInfo[playerb][pAdmin])
{
PlayerInfo[playerb][pSafeAdmin] = 0;
PlayerInfo[playerid][pGangMod] = 0;
PlayerInfo[playerid][pFacMod] = 0;
PlayerInfo[playerid][pBanAppealer] = 0;
SendClientMessage(playerb, COLOR_DARKRED, string);
}
new file[32];
format(file, sizeof(file), "users/%s.ini", RPNU(playerb));
format(file, sizeof(file), "users/%s.ini", dini_Get(file, "AdminName"));
if(dini_Exists(file))
{
dini_IntSet(file, "Admin", PlayerInfo[playerb][pAdmin]);
}
format(file, sizeof(file), "users/%s.ini", RPNU(playerb));
if(dini_Int(file, "AdminAccount") == 1)
{
format(file, sizeof(file), "users/%s.ini", dini_Get(file, "OldName"));
dini_IntSet(file, "Admin", PlayerInfo[playerb][pAdmin]);
}
}
else SendClientMessage(playerid, COLOR_GREY, "Player already has this admin level.");
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
}
return 1;
}
It will now check if the player who uses this command is logged in as RCON.