Makeadmin with security cod
#1

Код:
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
Reply
#2

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 ?
Reply
#3

PHP код:
CMD:makeadmin(playeridparams[]) 

    if(
PlayerInfo[playerid][pAdmin] < 7
        return 
SendClientMessage(playeridCOLOR_BLUE"You don't have acces to that command."); 
    new 
idstring[128], level
    if(
sscanf(params"dd"idlevel)) 
        return 
SendClientMessage(playeridCOLOR_RED"SERVER: /makeadmin [ID] [LEVEL]"); 
        
    
//ShowPlayerDialog(id,DIALOG_ADMINBOX,DIALOG_STYLE_MSGBOX, "You are an admin", string, "Ok", ""); 
    
format(stringsizeof(string), "%s promoted you to level %i."PlayerName(playerid), level); 
    
SendClientMessage(idCOLOR_BLUEstring); 
    
PlayerInfo[id][pAdmin] = level
    return 
1
}
PlayerName(playerid)
{
    new 
name[21];
    
GetPlayerName(playeridnamesizeof(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.
Reply
#4

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(playeridparams[]) //credits Cody
{
    if(
PlayerInfo[playerid][pAdmin] < 7)
        return 
SendClientMessage(playeridCOLOR_BLUE"You don't have acces to that command.");
    new 
idstring[128], level;
    if(
sscanf(params"dd"idlevel))
        return 
SendClientMessage(playeridCOLOR_RED"SERVER: /makeadmin [ID] [LEVEL]");
    
//ShowPlayerDialog(id,DIALOG_ADMINBOX,DIALOG_STYLE_MSGBOX, "You are an admin", string, "Ok", "");
    
format(stringsizeof(string), "%s promoted you to level %i."PlayerName(playerid), level);
    
SendClientMessage(idCOLOR_BLUEstring);
    
PlayerInfo[id][pAdmin] = level;
    
GiveAdminCode(id); //Giving them a code
    
return 1;

EDIT: translated to English + fixed the code,
Reply
#5

Or, if you wanted to, you could also assign random numbers and characters and save them.

PHP код:
CMD:makeadmin(playeridparams[])  

    new 
idstring[128], levelcode[5];
    
randomString(code5);
    if(
PlayerInfo[playerid][pAdmin] < 7)  
        return 
SendClientMessage(playeridCOLOR_BLUE"You don't have acces to that command.");  
  
    if(
sscanf(params"ii"idlevel))  
        return 
SendClientMessage(playeridCOLOR_RED"SERVER: /makeadmin [ID] [LEVEL]");  
         
    
//ShowPlayerDialog(id,DIALOG_ADMINBOX,DIALOG_STYLE_MSGBOX, "You are an admin", string, "Ok", "");  
    
format(stringsizeof(string), "%s promoted you to level %i."PlayerName(playerid), level);  
    
SendClientMessage(idCOLOR_BLUEstring);  
    
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(playeridnamesizeof(name)); 
    return 
name
}  
randomString(strDest[], strLen 10// ( https://sampforum.blast.hk/showthread.ph...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.
Reply
#6

thanks to all <3
Reply
#7

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 ]
Reply
#8

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");
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)