admin chat bugged.
#1

Ok.. this is a bit weird, command works fine but only for the admin who have PLAYERID 0, like I have ID 1 and my friend have ID 0, he can see what he and I wrote(If he have ID 0) but I can't see his chat, nor mine..(If I have ID 1-9999)

pawn Код:
if(strcmp(cmdtext, "/adm ", true, 5) == 0)
    {
        if(adminlevel[playerid]==0) return SendClientMessage(playerid, COLOR_WHITE, "Server: Wrong command. Do /commands.");
        if(!cmdtext[5]) return SendClientMessage(playerid, COLOR_ADMINBLUE, "Correct usage: /adm [message]");
        for(new i=0; i<MAX_PLAYERS; i++)
        {
            new iadminlevel;
            INI_ParseFile(UserPath(i), "LoadUser_%s", .bExtra = true, .extra = i);
            iadminlevel= PlayerInfo[i][pAdmin];
            new admmessage[128], playername[128];
            GetPlayerName(playerid, playername, sizeof(playername));
            format(admmessage, sizeof(admmessage), "(Admin Chat) %s: %s", playername, cmdtext[5]);
            if(iadminlevel>0) return SendClientMessage(i, COLOR_RED, admmessage);
        }
        return 1;
    }
Reply
#2

Quote:
Originally Posted by Nitin
Посмотреть сообщение
Ok.. this is a bit weird, command works fine but only for the admin who have PLAYERID 0, like I have ID 1 and my friend have ID 0, he can see what he and I wrote(If he have ID 0) but I can't see his chat, nor mine..(If I have ID 1-9999)

pawn Код:
if(strcmp(cmdtext, "/adm ", true, 5) == 0)
    {
        if(adminlevel[playerid]==0) return SendClientMessage(playerid, COLOR_WHITE, "Server: Wrong command. Do /commands.");
        if(!cmdtext[5]) return SendClientMessage(playerid, COLOR_ADMINBLUE, "Correct usage: /adm [message]");
        for(new i=0; i<MAX_PLAYERS; i++)
        {
            new iadminlevel;
            INI_ParseFile(UserPath(i), "LoadUser_%s", .bExtra = true, .extra = i);
            iadminlevel= PlayerInfo[i][pAdmin];
            new admmessage[128], playername[128];
            GetPlayerName(playerid, playername, sizeof(playername));
            format(admmessage, sizeof(admmessage), "(Admin Chat) %s: %s", playername, cmdtext[5]);
            if(iadminlevel>0) return SendClientMessage(i, COLOR_RED, admmessage);
        }
        return 1;
    }
pawn Код:
if(strcmp(cmdtext, "/adm ", true, 5) == 0)
    {
        if(adminlevel[playerid]==0) return SendClientMessage(playerid, COLOR_WHITE, "Server: Wrong command. Do /commands.");
        if(!cmdtext[5]) return SendClientMessage(playerid, COLOR_ADMINBLUE, "Correct usage: /adm [message]");
        for(new i=0; i<MAX_PLAYERS; i++)
        {
            if(PlayerInfo[i][pAdmin]>0)
            {
                new admmessage[100], playername[MAX_PLAYER_NAME];
                GetPlayerName(playerid, playername, sizeof(playername));
                format(admmessage, sizeof(admmessage), "(Admin Chat) %s: %s", playername, cmdtext[5]);
                SendClientMessage(i, COLOR_RED, admmessage);
            }
        }
        return 1;
    }
For starters you don't need to reload the player file for every single command. Create a saving stock and loading stock, and that'll do. Second, player names do not use 128 sized arrays/slots. Use MAX_PLAYER_NAME. Third, a client message can only have up to 128 characters. Fourth, always try to limit stuff, by filtering out, to assure minimal resources are used. In example: have IF ... so that certain functions or w/e aren't processed when they're not needed. These things will make your script lag.

Didn't get time to look at the rest.
Reply
#3

edit:....
Reply
#4

Try this:
pawn Код:
if(strcmp(cmdtext, "/adm ", true, 5) == 0)
    {
        if(adminlevel[playerid]==0) return SendClientMessage(playerid, COLOR_WHITE, "Server: Wrong command. Do /commands.");
        if(!cmdtext[5]) return SendClientMessage(playerid, COLOR_ADMINBLUE, "Correct usage: /adm [message]");
        new admmessage[128], playername[128];
        GetPlayerName(playerid, playername, sizeof(playername));
        format(admmessage, sizeof(admmessage), "(Admin Chat) %s: %s", playername, cmdtext[5]);
        for(new i=0; i<MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
        {
            if(adminlevel[i] >= 1)
        {
            SendClientMessage(i, COLOR_RED, admmessage);
        }
        }
       
        }
        return 1;
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)