Admins and MMmembers only shows one admin ..
#1

hello guys so i created a cmd to check online admins and online mm members but it only shows one admin and one member it don't show the rest
codes:
Admins
pawn Код:
CMD:admins(playerid, params[])
{
    new Count = 0, playername[128], string[1400], AdminRank[25];
    for(new i = 0; i < MAX_PLAYERS; i++) //I would recommend foreach.
    {
        if(!IsPlayerConnected(i)) continue;
        switch(PlayerInfo[i][Level])
        {
            case 0: continue;
            case 1: AdminRank = "New Born Admin";
            case 2: AdminRank = "Developer Admin";
            case 3: AdminRank = "Well Get The Job";
            case 4: AdminRank = "Served Enough";
            case 5: AdminRank = "Trusted Admin";
            case 6: AdminRank = "Highly Recommended Admin";
        }
        new fstr[70];
        GetPlayerName(i, playername, sizeof(playername));
        if(PlayerInfo[i][Level] == 6) format(string, 128, "{FF0000}Rank: %d - %s (Id:%i) | %s |", PlayerInfo[i][Level], playername, i, AdminRank);
        else format(string, 128, "Rank: %d - %s (Id:%i) | %s |", PlayerInfo[i][Level], playername, i, AdminRank);
        strcat(string, fstr);
        Count++;
        if(Count >= 20)
        {
            strcat(string, "\n{FF0000}Not all Admins could be listed. (More than 20 online)");
            break;
        }
    }
    if(!Count) string = "{FF0000}There are currently no vips online";
    format(string, sizeof(string), "{FF0000}Online Server Adminstrators\n{FFFFFF}%s", string);
    ShowPlayerDialog(playerid, 12, DIALOG_STYLE_MSGBOX, "{FF0000}CCTDM - Online Admins", string, "OK", "");
    return 1;
}
MM members
pawn Код:
CMD:mmmembers(playerid, params[])
{
    new Count = 0, playername[MAX_PLAYER_NAME], string[1400], MuRank[25];
    for(new i = 0; i < MAX_PLAYERS; i++) //I would recommend foreach.
    {
        if(!IsPlayerConnected(i)) continue; //Remove if using foreach.
        switch(PlayerInfo[i][MMRank])
        {
            case 0: continue;
            case 1: MuRank = "Newest Member";
            case 2: MuRank = "Junior Member";
            case 3: MuRank = "Executive Member";
            case 4: MuRank = "Senior Member";
            case 5: MuRank = "Head Member";
            case 6: MuRank = "Lieutenant";
            case 7: MuRank = "General";
            case 8: MuRank = "Leader";
        }
        new fstr[70];
        GetPlayerName(i, playername, sizeof(playername));
        if(PlayerInfo[i][MMRank] == 8) format(string, 128, "{FF0000}Rank: %d - %s (Id:%i) | %s |", PlayerInfo[i][MMRank], playername, i, MuRank);
        else format(string, 128, "Rank: %d - %s (Id:%i) | %s |", PlayerInfo[i][MMRank], playername, i, MuRank);
        strcat(string, fstr);
        Count++;
        if(Count >= 20)
        {
            strcat(string, "\n{FF0000}Not all MMs could be listed. (More than 20 online)");
            break;
        }
    }
    if(!Count) string = "{FF0000}There are currently no MMs online";
    format(string, sizeof(string), "{FF0000}Online MurderMubsters\n{FFFFFF}%s", string);
    ShowPlayerDialog(playerid, 12, DIALOG_STYLE_MSGBOX, "{FF0000}CCTDM - Online MMs", string, "OK", "");
    return 1;
}
Reply
#2

Bump please i need help
Reply
#3

You need to format "fstr", not "string" itself because you're concatenating "fstr" with "string".

Use a proper naming scheme so errors like this don't happen. Don't use abbreviations (what does the "f" mean in "fstr"?) and don't use generic terms like "string" either. A variable's purpose should be able to be deducted from its name. A name like "dialogOutput" is far more descriptive.
Reply
#4

honestly i can't get it bro ... btw thanks for replying
Reply
#5

Bump i need help guys!
Reply
#6

Try this:
PHP код:
if(PlayerInfo[i][MMRank] == 8format(fstr128"{FF0000}Rank: %d - %s (Id:%i) | %s |\n"PlayerInfo[i][MMRank], playernameiMuRank);
          else 
format(fstr128"Rank: %d - %s (Id:%i) | %s |\n"PlayerInfo[i][MMRank], playernameiMuRank);
          
strcat(stringfstr); 
You were formatting your line into variable "string" and you were appending the empty 'fstr" to it.
Also, you forgot the "\n" to start a new line in your dialog after each new admin, without it, everything would be on 1 line and the dialog would be a mess.

And I agree with Vince, never use "string" or "fstr" or any other variable-name that doesn't state it's usage.
Variables like "AdminList" and "AdminLine" would be proper descriptive variable names as the AdminList would hold the entire list of admins (the full list eventually being displayed in the dialog), while AdminLine only holds one line in the dialog.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)