Makeadmin with security cod [ solved] -
Deny1 - 26.01.2016
Код:
CMD:makeadmin(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 7)
{
new id, string[128], level;
if(sscanf(params, "dd", id, level)) return SendClientMessage(playerid, COLOR_RED, "SERVER: /makeadmin [ID] [LEVEL]");
format(string, sizeof(string), "You promoted to %d admin level.", level);
ShowPlayerDialog(id,DIALOG_ADMINBOX,DIALOG_STYLE_MSGBOX,"You are an admin",string,"Ok","");
//SendClientMessage(id, COLOR_BLUE, string);
PlayerInfo[id][pAdmin] = level;
}
else return SendClientMessage(playerid, COLOR_BLUE, "You don't have acces to that command.");
return 1;
}
This is my CMD make admin..but i want to make in
Код:
format(string, sizeof(string), "You promoted to %d admin level.", level);
who set admin to player...and also i want to if is posible to give him secure cod and everytime he log in to must writte in some box that security code to play
Re: Makeadmin with security cod -
Mikeydoo - 26.01.2016
Well, not sure of what you want ..
You want to tell by exemple
''you promoted %d to %d(amdin level like 5) admin level'', level, Playername); ??
So it says the player name and its admin level ?
Re: Makeadmin with security cod -
itsCody - 26.01.2016
PHP код:
CMD:makeadmin(playerid, params[])
{
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;
return 1;
}
PlayerName(playerid)
{
new name[21];
GetPlayerName(playerid, name, sizeof(name));
return name;
}
As for the "Security code" it's best off to generate a random code (bout 5 characters max), and save it to their file/database and have them use it in a command in order to use any admin commands.
Re: Makeadmin with security cod -
TwinkiDaBoss - 27.01.2016
Here you go, combined with Codys command
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;
}
EDIT: translated to English + fixed the code,
Re: Makeadmin with security cod -
itsCody - 27.01.2016
Or, if you wanted to, you could also assign random numbers and characters and save them.
PHP код:
CMD:makeadmin(playerid, params[])
{
new id, string[128], level, code[5];
randomString(code, 5);
if(PlayerInfo[playerid][pAdmin] < 7)
return SendClientMessage(playerid, COLOR_BLUE, "You don't have acces to that command.");
if(sscanf(params, "ii", 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;
PlayerInfo[id][pCode] = code; // Assigns the random 5 character code to the player variable
return 1;
}
PlayerName(playerid)
{
new name[21];
GetPlayerName(playerid, name, sizeof(name));
return name;
}
randomString(strDest[], strLen = 10) // ( https://sampforum.blast.hk/showthread.php?pid=1349155#pid1349155 )
{
while(strLen--)
strDest[strLen] = random(2) ? (random(26) + (random(2) ? 'a' : 'A')) : (random(10) + '0');
}
/*
And inside of admin commands you can do shit like
if(!PlayerInfo[playerid][pUsedCode]) return Errormessage..
*/
Add pCode, and pUsedCode (or whatever) inside of your PlayerInfo enum, and add it to saving it, and loading it. as a string. All you have to do is work out the login command and/or dialog.
You can do it however you like, but that's similar how I would do it.
Re: Makeadmin with security cod -
Deny1 - 27.01.2016
thanks to all <3
Re: Makeadmin with security cod -
Deny1 - 27.01.2016
It's working but how can i make.When i give somebody admin to send him dialog like Cong.%S Promoted you to level admin %i.Your security code is example nvm 43213 and when he login into the server to show him dialog and if he want to play to writte in dialog security code? [ it is not necesery ]
Re: Makeadmin with security cod -
Deny1 - 27.01.2016
here is problem..when i give somebody admin and he go relog and try to use cmd /login cod he get error SendClientMessage(playerid,COLOR_RED,"Wrong admin code");