Makeadmin cmd
#1

How to make this command to can use only by name Sn4ke ?

PHP код:
CMD:makeadmin(playeridparams[])
{
    if(
gPlayerLogged[playerid] == 0) return SCM(playeridCOLOR_LIGHTRED"Nu esti logat!");
    if(
IsPlayerConnected(playerid))
    {
        if (
PlayerInfo[playerid][pAdmin] >= 6)
        {
            new 
id,adminlevel,sendername[30],giveplayer[30],string[200];
            if(
sscanf(params"ui",id,adminlevel)) return SCM(playerid0xFFFFFFFF"Tasteaza: /makeadmin <Name/Playerid> <Admin Level>");
            if(
IsPlayerConnected(id))
            {
                if(
id != INVALID_PLAYER_ID)
                {
                    if(
adminlevel == 0)
                    {
                        
GetPlayerName(idgiveplayersizeof(giveplayer));
                        
GetPlayerName(playeridsendernamesizeof(sendername));
                        
PlayerInfo[id][pAdmin] = 0;
                        
printf("AdmCmd: %s removed %s admin."sendernamegiveplayer);
                        
format(stringsizeof(string), "** Admin %s te-a scos din functia de admin!"sendername);
                        
SCM(idCOLOR_LIGHTBLUEstring);
                        
format(stringsizeof(string), "L-ai scos din functia de admin pe %s!"giveplayer);
                        
SCM(playeridCOLOR_LIGHTBLUEstring);
                        
format(stringsizeof(string), "{f03337}[AdmInfo]: Admin %s l-a scos din functia de admin pe %s."sendername,giveplayer);
                        
ABroadCast(0xf03337FF,string,4);
                        new 
wakaname[25];
                        
GetPlayerName(id,wakaname,25);
                        new 
str[128];
                        
format(str,128,"UPDATE users SET `Admin`='0' WHERE `name`='%s'",wakaname);
                        
mysql_query(SQL,str);
                    }
                    else
                    {
                        
GetPlayerName(idgiveplayersizeof(giveplayer));
                        
GetPlayerName(playeridsendernamesizeof(sendername));
                        
PlayerInfo[id][pAdmin] = adminlevel;
                        
PlayerInfo[id][pChar] = 217;
                        
SetPlayerSkin(id217);
                        
printf("[AdmInfo]: %s has promoted %s to a level %d admin."sendernamegiveplayeradminlevel);
                        
format(stringsizeof(string), "* Felicitari! Ai fost promovat la gradul de admin level %d de catre %s!"adminlevelsendername);
                        
SCM(idCOLOR_LIGHTBLUEstring);
                        
format(stringsizeof(string), "* L-ai promovat pe %s la gradul de admin level %d!"giveplayer,adminlevel);
                        
SCM(playeridCOLOR_LIGHTBLUEstring);
                        
format(stringsizeof(string), "[AdmInfo]: Admin %s l-a promovat pe %s la gradul de admin level %d"sendername,giveplayer,adminlevel);
                        
ABroadCast(0xf03337FF,string,4);
                         new 
wakaname[25];
                        
GetPlayerName(id,wakaname,25);
                        new 
str[256];
                        
format(str,256,"UPDATE users SET `Admin`='%d',`CChar`='%d' WHERE `name`='%s'",PlayerInfo[id][pAdmin],PlayerInfo[id][pChar],wakaname);
                        
mysql_query(SQL,str);
                    }
                }
            }
            else
            {
                
SCM(playeridCOLOR_WHITE"Jucatorul nu este conectat.");
            }
        }
        else
        {
            
SCM(playeridCOLOR_WHITEAdminOnly);
        }
    }
    return 
1;

what i want to say is like if (name == Sn4ke )
{
This is an example, i know is not like that :P
}
Reply
#2

If you want to compare two strings you have to work with strcmp.
PHP код:
CMD:makeadmin(playeridparams[])
{
    if(
gPlayerLogged[playerid] == 0) return SCM(playeridCOLOR_LIGHTRED"Nu esti logat!");
    if(
IsPlayerConnected(playerid))
    {
        if (
PlayerInfo[playerid][pAdmin] >= 6)
        {
            new 
id,adminlevel,sendername[30],giveplayer[30],string[200];
            
GetPlayerName(playeridsendernamesizeof(sendername));
            if(
strcmp(sendername,"Sn4ke",true))return SendClientMessage(playerid,-1,"Only Sn4ke can use this command!");
            if(
sscanf(params"ui",id,adminlevel)) return SCM(playerid0xFFFFFFFF"Tasteaza: /makeadmin <Name/Playerid> <Admin Level>");
            if(
IsPlayerConnected(id))
            {
                if(
id != INVALID_PLAYER_ID)
                {
                    if(
adminlevel == 0)
                    {
                        
GetPlayerName(idgiveplayersizeof(giveplayer));
                        
PlayerInfo[id][pAdmin] = 0;
                        
printf("AdmCmd: %s removed %s admin."sendernamegiveplayer);
                        
format(stringsizeof(string), "** Admin %s te-a scos din functia de admin!"sendername);
                        
SCM(idCOLOR_LIGHTBLUEstring);
                        
format(stringsizeof(string), "L-ai scos din functia de admin pe %s!"giveplayer);
                        
SCM(playeridCOLOR_LIGHTBLUEstring);
                        
format(stringsizeof(string), "{f03337}[AdmInfo]: Admin %s l-a scos din functia de admin pe %s."sendername,giveplayer);
                        
ABroadCast(0xf03337FF,string,4);
                        new 
wakaname[25];
                        
GetPlayerName(id,wakaname,25);
                        new 
str[128];
                        
format(str,128,"UPDATE users SET `Admin`='0' WHERE `name`='%s'",wakaname);
                        
mysql_query(SQL,str);
                    }
                    else
                    {
                        
GetPlayerName(idgiveplayersizeof(giveplayer));
                        
GetPlayerName(playeridsendernamesizeof(sendername));
                        
PlayerInfo[id][pAdmin] = adminlevel;
                        
PlayerInfo[id][pChar] = 217;
                        
SetPlayerSkin(id217);
                        
printf("[AdmInfo]: %s has promoted %s to a level %d admin."sendernamegiveplayeradminlevel);
                        
format(stringsizeof(string), "* Felicitari! Ai fost promovat la gradul de admin level %d de catre %s!"adminlevelsendername);
                        
SCM(idCOLOR_LIGHTBLUEstring);
                        
format(stringsizeof(string), "* L-ai promovat pe %s la gradul de admin level %d!"giveplayer,adminlevel);
                        
SCM(playeridCOLOR_LIGHTBLUEstring);
                        
format(stringsizeof(string), "[AdmInfo]: Admin %s l-a promovat pe %s la gradul de admin level %d"sendername,giveplayer,adminlevel);
                        
ABroadCast(0xf03337FF,string,4);
                         new 
wakaname[25];
                        
GetPlayerName(id,wakaname,25);
                        new 
str[256];
                        
format(str,256,"UPDATE users SET `Admin`='%d',`CChar`='%d' WHERE `name`='%s'",PlayerInfo[id][pAdmin],PlayerInfo[id][pChar],wakaname);
                        
mysql_query(SQL,str);
                    }
                }
            }
            else
            {
                
SCM(playeridCOLOR_WHITE"Jucatorul nu este conectat.");
            }
        }
        else
        {
            
SCM(playeridCOLOR_WHITEAdminOnly);
        }
    }
    return 
1;

Reply
#3

Thank you, i give you + rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)