/admins help
#1

Only one admin will appear on the list of admins even if there's more than one online.
Help appreciated!

PHP код:
case 2:
    {
        new 
name[MAX_PLAYER_NAME],string[128],id,admin[20],duty[32];
        
GetPlayerName(id,name,sizeof(name));
        if(
PlayerInfo[playerid][pAdmin]==1) {admin ="Moderator";}
        else if(
PlayerInfo[playerid][pAdmin]==2) {admin="Administrator";}
        else if(
PlayerInfo[playerid][pAdmin]==3) {admin "Head Administrator";}
        if(
PlayerInfo[playerid][pDuty]==0) {duty ="{FF0000}Off duty";}
        else if(
PlayerInfo[playerid][pDuty]==1) {duty ="{007F0E}On duty!";}
        if(
PlayerInfo[id][pAdmin]>0)
        {
            
format(string,sizeof(string),"{FF7FB6}%s {A9C4E4}%s is %s",admin,name,duty);
            
ShowPlayerDialog(playerid,6,DIALOG_STYLE_MSGBOX,"Staff team"string"Close""");
        }
    } 
Reply
#2

I'm assuming this code is inside a loop, so...
pawn Код:
case 2:
    {
        new name[MAX_PLAYER_NAME],string[128],id,admin[20],duty[32];
        GetPlayerName(id,name,sizeof(name));
        switch(PlayerInfo[id][pAdmin])
        {
            case 1: admin = "Moderator";
            case 2: admin = "Administrator";
            case 3: admin = "Head Administrator";
        }
        if(PlayerInfo[id][pDuty] == 0)
        {
            duty = "{FF0000}Off duty";
        }
        else if(PlayerInfo[playerid][pDuty] == 1)
        {
            duty = "{007F0E}On duty!";
        }
        if(PlayerInfo[id][pAdmin] > 0)
        {
            format(string,sizeof(string),"%s{FF7FB6}%s {A9C4E4}%s is %s\n",admin,name,duty);  
        }
    }
    ShowPlayerDialog(playerid,6,DIALOG_STYLE_MSGBOX,"Staff team", string, "Close", "");
NOTE: PlayerInfo[playerid][pAdmin]

You are not trying to find the Admin level of 'PLAYERID', you are trying to find the Admin level of 'ID', so you would use:
PlayerInfo[id][pAdmin]

Also, if you're formatting strings, you should always use the string outside the loop until it is fully built, like using string in a ShowPlayerDialog line, the ShowPlayerDialog should be OUTSIDE the loop. https://sampwiki.blast.hk/wiki/Loops
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)