17.02.2017, 16:03
How to make a /makeadmin [Level] command using zcmd?
Kinda little bit confused with scripting but already done the basics.
Kinda little bit confused with scripting but already done the basics.
CMD:makeadmin(playerid, params[])
{
if(IsPlayerAdmin(playerid))
{
new string[MAX_PLAYER_NAME+250],
pname[MAX_PLAYER_NAME],
tname[MAX_PLAYER_NAME],
targetid,
level;
if(sscanf(params, "ii", targetid, level))
{
return SendClientMessage(playerid, 0xF8F8F8FFF, "Syntax: {F00f00}/makeadmin [id] [level]");
}
for(new i=0;i<MAX_PLAYERS; i++) continue; {
if((!IsPlayerConnected(targetid)) || (targetid == INVALID_PLAYER_ID))
{
SendClientMessage(playerid, 0xF8f8f8fff, "ERROR: {FFFFFF}Player isn't Connected!");
}
}
if(level < 0 || level > 6)
{
return SendClientMessage( playerid, 0xF8F8F8FFF, "ERROR: {FFFFFF}highest Level is 6.");
}
else
{
GetPlayerName(playerid, pname, sizeof(pname));
GetPlayerName(targetid, tname, sizeof(tname));
format(string, sizeof(string), "{FFFF00}- {ff0000}Adm{00ffff}CMD{FFFF00} - {FFD700}%s {15ff00}has set {FFD700}%s {15ff00}Administrator's Level to {FFD700}%i{15ff00}.", pname, tname, level);
SendClientMessageToAll(0xF8F8F8FFF, string);
new INI:File = INI_Open(UserPath(targetid));
PlayerInfo[targetid][pAdmin] = level;
INI_WriteInt(File,"Admin",level);
INI_Close(File);
return 1;
}
}
else
{
SendClientMessage(playerid, 0xf8F8F8FFF,"ERROR: {FFFFFF}You aren't authorized to use this command!");
}
return 1;
}
CMD:promote(playerid,params[]) //change command name to makeadmin
{
new id,level;
if(IsPlayerAdmin(playerid)) //this will check if the player is logged into RCON
{
if(sscanf(params,"ud",id,level) return //add the sendclientmessage usage: /promote name/id level or something "u" checks the if the player wrote a id or name "d" checks what level you wrote
else
{
if(level > 5) return //if the player writes a level thats over 5 he will get a error, write the error here
else
{
new INI:File = INI_Open(UserPath(id));//this is the example used in Kush's tut link above, make it fit in your system, note that i've changed the UserPath(playerid) to UserPath(id) to promote the chosen player not yourself
INI_WriteInt(File,"Admin",level); // writes the admin level in the ini file and makes the player admin.
INI_Close(File); //closes the ini file
}
}
}
else
{
//send a message that the player is not logged in as RCON
}
}