27.01.2016, 00:34
Here you go, combined with Codys command
EDIT: translated to English + fixed the code,
PHP код:
new AdminKod[MAX_PLAYERS],
AdminLogovan[MAX_PLAYERS];
GiveAdminCode(playerid) { //When promoting, use
new rr = randomEx(1000,999999);
new string[128];
format(string,sizeof(string),"Your admin code is %i",rr);
SendClientMessage(playerid,COLOR_RED,string);
AdminKod[playerid] = rr;
return true;
}
CMD:login(playerid,params[]) { //how to login as administrator
new nmr;
if(sscanf(params,"i",nmr)) return SendClientMessage(playerid,COLOR_RED,"Usage: /login [admin code]");
if(nmr != AdminKod[playerid]) return SendClientMessage(playerid,COLOR_RED,"Wrong admin code");
AdminLogovan[playerid] = 1; //admin logged in
SendClientMessage(playerid,COLOR_RED,"You have logged in as administrator!");
return true;
}
CMD:makeadmin(playerid, params[]) //credits Cody
{
if(PlayerInfo[playerid][pAdmin] < 7)
return SendClientMessage(playerid, COLOR_BLUE, "You don't have acces to that command.");
new id, string[128], level;
if(sscanf(params, "dd", id, level))
return SendClientMessage(playerid, COLOR_RED, "SERVER: /makeadmin [ID] [LEVEL]");
//ShowPlayerDialog(id,DIALOG_ADMINBOX,DIALOG_STYLE_MSGBOX, "You are an admin", string, "Ok", "");
format(string, sizeof(string), "%s promoted you to level %i.", PlayerName(playerid), level);
SendClientMessage(id, COLOR_BLUE, string);
PlayerInfo[id][pAdmin] = level;
GiveAdminCode(id); //Giving them a code
return 1;
}