admin chat help
#1

When i do /achat FUAUJPAOGJ it will show to everyone that is connected to server, please help
pawn Код:
CMD:achat(playerid, params[])
{
    if(PlayerData[playerid][AdminLevel] > 0)
    {
        new iName[MAX_PLAYER_NAME],iStr[128];
        if(isnull(params)) return SendClientMessage(playerid,0xFF9900AA,"USAGE: /achat [text]");
        GetPlayerName(playerid,iName,sizeof(iName));
        for(new i = 0; i < 10; ++i)
        {
            if(PlayerData[playerid][AdminLevel] > 0 && IsPlayerConnected(i) && !IsPlayerNPC(i))
            {
                format(iStr,sizeof(iStr),"[ADMIN CHAT] %s: %s",iName,params);
                SendClientMessage(i,0xFF9900AA,iStr);
            }
        }
    }
    else return 0;
    return 1;
}
Reply
#2

pawn Код:
CMD:achat(playerid, params[])
{
    if(PlayerData[playerid][AdminLevel] > 0)
    {
        new iName[MAX_PLAYER_NAME],iStr[128];
        if(isnull(params)) return SendClientMessage(playerid,0xFF9900AA,"USAGE: /achat [text]");
        GetPlayerName(playerid,iName,sizeof(iName));
        for(new i = 0; i < MAX_PLAYERS; ++i) // i recommend using Foreach
        {
            if(PlayerData[i][AdminLevel] > 0 && IsPlayerConnected(i) && !IsPlayerNPC(i))
            {
                format(iStr,sizeof(iStr),"[ADMIN CHAT] %s: %s",iName,params);
                SendClientMessage(i,0xFF9900AA,iStr);
            }
        }
    }
    else return 0;
    return 1;
}
Reply
#3

pawn Код:
CMD:achat(playerid, params[])
{
    if(PlayerData[playerid][AdminLevel] > 0)
    {
        if(isnull(params)) return SendClientMessage(playerid,0xFF9900AA,"USAGE: /achat [text]");
        new iStr[128+MAX_PLAYER_NAME+15]; //Place variables after error check -- Use only 1 appropriately sized string instead of 2
        GetPlayerName(playerid,iStr,24); //Switch iName with iStr
        format(iStr,sizeof(iStr),"[ADMIN CHAT] %s: %s",iStr,params); //format string BEFORE loop -- replace iName with iStr
        for(new i = 0; i < MAX_PLAYERS; ++i) //Change 10 to MAX_PLAYERS
        {
            if((PlayerData[i][AdminLevel] > 0) && IsPlayerConnected(i) && !IsPlayerNPC(i)) //Change playerid to i -- Enclose conditionals appropriately
            {
                SendClientMessage(i,0xFF9900AA,iStr);
            }
        }
    }
    else return 0;
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)