Error with /admins
#3

pawn Код:
COMMAND:admins(playerid, params[])
    {
        new check = 0,
        info[150];
        SendClientMessage(playerid, COLOR_LIGHTGREEN, "Connected Administrators:");
        foreach(new i : Player)
        {
            if(IsPlayerConnected(i)) {

                if(PlayerInfo[i][pAdminlevel] > 0 && GetPVarInt(i, "AdminHide") == 0)
                {
               
                    format(info, sizeof(info), "(Level: %i) %s (%s) (ID: %i) AdminDuty: %s", PlayerInfo[i][pAdminlevel], GetNameWithSpace(i), PlayerInfo[i][pForumName], i, GetPVarInt(i, "AdminDuty") == 1? ("Yes") : ("No"));
                    SendClientMessage(playerid, GetPVarInt(i, "AdminDuty") == 1? COLOR_GREEN : COLOR_GREY, info); // so better, send it under this case only..
                    check++;
                }
                else
                {
                    if(PlayerInfo[i][pBanAppealer] == 1) strcat(info, " [BA]");
                    if(PlayerInfo[i][pBanAppealer] == 2) strcat(info, " [DOBA]");
                    if(PlayerInfo[i][pShopTech] == 1) strcat(info, " [ST]");
                    if(PlayerInfo[i][pShopTech] == 2) strcat(info, " [SST]");
                    if(PlayerInfo[i][pShopTech] == 3) strcat(info, " [DOCR]");
                    if(PlayerInfo[i][pFactionModerator] == 1) strcat(info, " [FMOD]");
                    if(PlayerInfo[i][pFactionModerator] == 2) strcat(info, " [DOFM]");
                    if(PlayerInfo[i][pPR] == 1) strcat(info, " [PR]");
                    if(PlayerInfo[i][pPR] == 2) strcat(info, " [DOPR]");
                    if(PlayerInfo[i][pHR] >= 1) strcat(info, "
"
);
                    if(PlayerInfo[i][pAP] >= 1) strcat(info, " [AP]");
                    if(PlayerInfo[i][pSecurity] >= 1) strcat(info, " [Sec]");
                    // "info" here will be empty, bcz u formatted it under another case.....
                }
            }
            else if(check == 0) return SendClientMessage(playerid, COLOR_GREY, "*** There are currently no administrators connected.");
        }
        return 1;
Your mistake was that you formatted the string "info" under a case, and sent it under another different case, which will make it empty string.
Second, you should check if the player was connected or not, to not return bugs.
Reply


Messages In This Thread
Error with /admins - by EmilLykke - 22.12.2014, 14:21
Re: Error with /admins - by Abagail - 22.12.2014, 14:27
Re: Error with /admins - by Sawalha - 22.12.2014, 14:35
Re: Error with /admins - by Threshold - 22.12.2014, 14:52

Forum Jump:


Users browsing this thread: 1 Guest(s)