admin chat is not working...
#1

hello i have this admin chat but when only one admin is online i can see chat but when more admins online i cant see admin chat...
here are codes...
pawn Код:
dcmd_a(playerid, params[])
{
        new chat[100];
        if(pInfo[playerid][Adminlevel] < 1) return SendClientMessage(playerid, COLOR_RED, ""ERROR_MESSAGE"");
        if(sscanf(params, "s", chat)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /a [chat]");
        for (new i = 0; i < MAX_PLAYERS; i++)
        {
           if(IsPlayerConnected(i))
            {
                if(pInfo[i][Adminlevel] > 0)
                {
                new str[128];
                new playername[MAX_PLAYER_NAME];
                GetPlayerName(playerid,playername,24);
                format(str,sizeof(str),"[ADMIN CHAT] %s(%d): %s", playername, playerid, chat);
                SCM(i, COLOR_HOTPINK, str);
                print(str);
                return 1;
                }

            }

        }

        return 1;
}
Reply
#2

sorry but i need a solution...
Reply
#3

Try:

PHP код:
dcmd_a(playeridparams[])
{
    new 
chat[100], str[150];
    if(
pInfo[playerid][Adminlevel] < 1) return SendClientMessage(playeridCOLOR_RED""ERROR_MESSAGE"");
    if(
sscanf(params"s[100]"chat)) return SendClientMessage(playeridCOLOR_RED"USAGE: /a [chat]");
    for (new 
0MAX_PLAYERSi++)
    {
       if(
IsPlayerConnected(i))
        {
            if(
pInfo[i][Adminlevel] >= 1)
            {
                
format(str,sizeof(str),"[ADMIN CHAT] %s(%d): %s"Name(playerid), playeridchat);
                
SendClientMessage(iCOLOR_HOTPINKstr);
                print(
str);
            }
        }
    }
    return 
1;
}
stock Name(playerid)
{
    new 
name[24];
    
GetPlayerName(playeridnamesizeof(name));
    return 
name;

Reply
#4

It's most likely because of the "return 1" inside the loop, which ends if it finds an online admin(?) - it it does, just remove it instead.
Quote:
Originally Posted by Anak
Посмотреть сообщение
PHP код:
if(IsPlayerConnected(i))
{
        if(
pInfo[i][Adminlevel] > 0)
        {
                new 
str[128];
                new 
playername[MAX_PLAYER_NAME];
                
GetPlayerName(playerid,playername,24);
                
format(str,sizeof(str),"[ADMIN CHAT] %s(%d): %s"playernameplayeridchat);
                
SCM(iCOLOR_HOTPINKstr);
                return 
1//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        
}

Reply
#5

That's mine working 100%
pawn Код:
forward SendAdminMessage(color, string[]);
public SendAdminMessage(color, string[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(PlayerInfo[i][pAdmin] > 0)
            {
                SendClientMessage(i, COLOR_YELLOW, string);
            }
        }
    }
}

//command
dcmd_ac(playerid,params[])
{
    new string[128];
    new pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pname,sizeof(pname));
    if(!strlen(params))
    {
        SendClientMessage(playerid,COLOR_ERROR,"[USAGE] /ac (Message)");
        return 1;
    }
    format(string,sizeof(string),"[ADMIN CHAT]  %s(%d): %s",pname,playerid,params);
    SendAdminMessage(COLOR_YELLOW,string);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)