/makeadmin Help +REP
#1

Why When I Type /makeadmin It Normally Sets The Player That Has Typed It To Level 0,Without Typing /makeadmin [playerid] [1 - 10] only /makeadmin in these codes:

PHP код:
COMMAND:makeadmin(playeridparams[])
{
        new 
giveplayeridlevelMessage4[128], PNAME[MAX_PLAYER_NAME], PNAME2[MAX_PLAYER_NAME];
        if(
sscanf(params"ud"giveplayeridlevel))
        {
          
SendClientMessage(playerid, -1"USAGE: /makeadmin <playerid> <Admin level 1 - 10>");
          
SendClientMessage(playerid0x008CFFFF"NOTE: Admin Level 1 = Trial Moderator, Admin Level 2 = Moderator, Admin Level 3 = Master Moderator");
          
SendClientMessage(playerid0x008CFFFF"NOTE: Admin Level 4 = Trial Adminstrator, Admin Level 5 = Adminstrator, Admin Level 6 = Master Adminstrator");
          
SendClientMessage(playerid0x008CFFFF"NOTE: Admin Level 7 = Head Adminstrator, Admin Level 8 = Trusted Adminstrator, Admin Level 9 = Co-Owner, Admin Level 10 = Owner");
        }
        if(
PlayerInfo[playerid][pAdmin] < 10) return SendClientMessage(playerid0xFF0000FF"You Are Not The Owner!");
        if(!
IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid0xFF0000FF"Player Is Not Connected!");
        if(
level 10 || level 0) return SendClientMessage(playerid0xFF0000FF"Admin Levels Cannot Be More Than 10 Or Less Than 1!");
        
GetPlayerName(giveplayeridPNAMEMAX_PLAYER_NAME);
        
GetPlayerName(playeridPNAME2MAX_PLAYER_NAME);
        if(
PlayerInfo[giveplayerid][pAdmin] > 0)
        {
          switch(
PlayerInfo[giveplayerid][pAdmin])
          {
          case 
1AdmRank "Trial Moderator";
          case 
2AdmRank "Moderator";
          case 
3AdmRank "Master Moderator";
             case 
4AdmRank "Trial Administrator";
          case 
5AdmRank "Administrator";
          case 
6AdmRank "Master Adminstrator";
          case 
7AdmRank "Head Adminstrator";
          case 
8AdmRank "Trusted Adminstrator";
          case 
9AdmRank "Co-Owner";
          case 
10AdmRank "Owner";
          }
          if(
PlayerInfo[giveplayerid][pAdmin] < level)
          {
            
format(Message4sizeof(Message4), "You Have Been Promoted To Level {00FFFB}%d - %s{FF5900}."PlayerInfo[playerid][pAdmin], AdmRank), SendClientMessage(giveplayerid0xFF5900FFMessage4);
            
format(Message4sizeof(Message4), "%s (%d) Has Been Promoted To Level {00FFFB}%d - %s{00FFFF}."PNAME ,PlayerInfo[playerid][pAdmin], AdmRank), SendClientMessageToAll(0x00FFFFFFMessage4);
            
PlayerInfo[giveplayerid][pAdmin] = level;
            
GameTextForPlayer(giveplayerid"~g~Promoted"50004);
            foreach(
Playeri)
            {
              if(
PlayerInfo[i][pAdmin] > 0)
              {
                
format(Message4sizeof(Message4), "The Owner %s (%d) Has Made %s (%d) An Admin Level {00FFFB}%d - %s{FF5900}.",PNAME2playeridPNAMEgiveplayeridPlayerInfo[playerid][pAdmin], AdmRank), SendClientMessage(i0xFF5900FFMessage4);
              }
            }
          }
          else if(
PlayerInfo[giveplayerid][pAdmin] > level)
          {
            
format(Message4sizeof(Message4), "You Have Been Demoted To Level {00FFFB}%d - %s{FF5900}."PlayerInfo[playerid][pAdmin], AdmRank), SendClientMessage(giveplayerid0xFF5900FFMessage4);
            
format(Message4sizeof(Message4), "%s (%d) Has Been Demoted To Level {00FFFB}%d - %s{00FFFF}."PNAME ,PlayerInfo[playerid][pAdmin], AdmRank), SendClientMessageToAll(0x00FFFFFFMessage4);
            
PlayerInfo[giveplayerid][pAdmin] = level;
            
GameTextForPlayer(giveplayerid"~r~Demoted"50004);
            foreach(
Playeri)
            {
              if(
PlayerInfo[i][pAdmin] > 0)
              {
                
format(Message4sizeof(Message4), "The Owner %s (%d) Has Made %s (%d) An Admin Level {00FFFB}%d - %s{FF5900}.",PNAME2playeridPNAMEgiveplayeridPlayerInfo[playerid][pAdmin], AdmRank), SendClientMessage(i0xFF5900FFMessage4);
              }
            }
          }
        }
        return 
1;

Reply
#2

can u explain more clearly what is problem?
Reply
#3

I don't see any problem there it should work.
Reply
#4

well i see a problem in code
pawn Код:
if(sscanf(params, "ud", giveplayerid, level))
        {
          SendClientMessage(playerid, -1, "USAGE: /makeadmin <playerid> <Admin level 1 - 10>");
          SendClientMessage(playerid, 0x008CFFFF, "NOTE: Admin Level 1 = Trial Moderator, Admin Level 2 = Moderator, Admin Level 3 = Master Moderator");
          SendClientMessage(playerid, 0x008CFFFF, "NOTE: Admin Level 4 = Trial Adminstrator, Admin Level 5 = Adminstrator, Admin Level 6 = Master Adminstrator");
          SendClientMessage(playerid, 0x008CFFFF, "NOTE: Admin Level 7 = Head Adminstrator, Admin Level 8 = Trusted Adminstrator, Admin Level 9 = Co-Owner, Admin Level 10 = Owner");
        }
change this to the following--
pawn Код:
if(sscanf(params, "ud", giveplayerid, level))
        {
          SendClientMessage(playerid, -1, "USAGE: /makeadmin <playerid> <Admin level 1 - 10>");
          SendClientMessage(playerid, 0x008CFFFF, "NOTE: Admin Level 1 = Trial Moderator, Admin Level 2 = Moderator, Admin Level 3 = Master Moderator");
          SendClientMessage(playerid, 0x008CFFFF, "NOTE: Admin Level 4 = Trial Adminstrator, Admin Level 5 = Adminstrator, Admin Level 6 = Master Adminstrator");
          SendClientMessage(playerid, 0x008CFFFF, "NOTE: Admin Level 7 = Head Adminstrator, Admin Level 8 = Trusted Adminstrator, Admin Level 9 = Co-Owner, Admin Level 10 = Owner");
return 1;
        }
u missed a return 1; here
Reply
#5

pawn Код:
COMMAND:makeadmin(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 10) return SendClientMessage(playerid, 0xFF0000FF, "You Are Not The Owner!");
    new giveplayerid, level;
    if(sscanf(params, "ud", giveplayerid, level))
    {
        SendClientMessage(playerid, -1, "USAGE: /makeadmin <playerid> <Admin level 1 - 10>");
        SendClientMessage(playerid, 0x008CFFFF, "NOTE: Admin Level 1 = Trial Moderator, Admin Level 2 = Moderator, Admin Level 3 = Master Moderator");
        SendClientMessage(playerid, 0x008CFFFF, "NOTE: Admin Level 4 = Trial Adminstrator, Admin Level 5 = Adminstrator, Admin Level 6 = Master Adminstrator");
        return SendClientMessage(playerid, 0x008CFFFF, "NOTE: Admin Level 7 = Head Adminstrator, Admin Level 8 = Trusted Adminstrator, Admin Level 9 = Co-Owner, Admin Level 10 = Owner");
    }
    if(!IsPlayerConnected(giveplayerid) || giveplayerid == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000FF, "Player Is Not Connected!");
    if(!(0 < level < 11)) return SendClientMessage(playerid, 0xFF0000FF, "Admin Levels Cannot Be More Than 10 Or Less Than 1!");
    new var = PlayerInfo[giveplayerid][pAdmin];
    if(var == level) return SendClientMessage(playerid, 0xFF0000FF, "Player Is Already At This Admin Level.");
    new astr[128], PNAME[MAX_PLAYER_NAME], ANAME[MAX_PLAYER_NAME], Rank[22];
    GetPlayerName(giveplayerid, PNAME, sizeof(PNAME));
    GetPlayerName(playerid, ANAME, sizeof(ANAME));
    switch(var)
    {
        case 1: Rank = "Trial Moderator";
        case 2: Rank = "Moderator";
        case 3: Rank = "Master Moderator";
        case 4: Rank = "Trial Administrator";
        case 5: Rank = "Administrator";
        case 6: Rank = "Master Administrator";
        case 7: Rank = "Head Administrator";
        case 8: Rank = "Trusted Administrator";
        case 9: Rank = "Co-Owner";
        case 10: Rank = "Owner";
    }
    format(astr, sizeof(astr), (var < level) ? ("You Have Been Promoted To Level {00FFFB}%d - %s{FF5900}.") : ("You Have Been Demoted To Level {00FFFB}%d - %s{FF5900}."), level, Rank);
    SendClientMessage(giveplayerid, 0xFF5900FF, astr);
    format(astr, sizeof(astr), (var < level) ? ("%s (%d) Has Been Promoted To Level {00FFFB}%d - %s{00FFFF}.") : ("%s (%d) Has Been Demoted To Level {00FFFB}%d - %s{00FFFF}."), PNAME, giveplayerid, level, Rank);
    SendClientMessageToAll(0x00FFFFFF, astr);
    GameTextForPlayer(giveplayerid, (var < level) ? ("~g~Promoted") : ("~r~Demoted"), 5000, 4);
    foreach(Player, i)
    {
        if(!PlayerInfo[i][pAdmin]) continue;
        format(astr, sizeof(astr), "The Owner %s (%d) Has Made %s (%d) An Admin Level {00FFFB}%d - %s{FF5900}.", ANAME, playerid, PNAME, giveplayerid, level, Rank);
        SendClientMessage(i, 0xFF5900FF, astr);
    }
    PlayerInfo[giveplayerid][pAdmin] = level;
    return 1;
}
You were using 'PlayerInfo[playerid][pLevel]' when formatting your strings, when you should have been using 'level'.
Reply
#6

thanks Threshold but i have another problem,with your codes,it send me this: after Level 10 -, it doesn't send me the owner,or co-owner or anything
Reply
#7

Because the maximum number of cells that can be sent through SendClientMessage is 128. Alternatively, you can try sending the message on two lines, as it will get cut off if the string is too long.

And yes I did notice this when I was making the script, but your only option is:
pawn Код:
foreach(Player, i)
    {
        if(!PlayerInfo[i][pAdmin]) continue;
        format(astr, sizeof(astr), "The Owner %s (%d) Has Made %s (%d)" ANAME, playerid, PNAME, giveplayerid);
        SendClientMessage(i, 0xFF5900FF, astr);
        format(astr, sizeof(astr), "An Admin Level {00FFFB}%d - %s{FF5900}.", level, Rank);
        SendClientMessage(i, 0xFF5900FF, astr);
    }
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)