Help in Admin chat command
#2

pawn Код:
public OnPlayerText(playerid, text[]) // Since OnPlayerCommandText only recognises commands with the prefix of /, we need to use OnPlayerText.
{
    if(text[0] == '@' && IsPlayerAdmin(playerid)) // If the first character of the text string equals '@' AND is the person who sent the text an admin?
    {
        new
            TextOutput[128], SenderName[MAX_PLAYER_NAME]; // Creating a couple of variables to store the completed string & the player's name.
           
        text[0] = ' '; // Replacing the @ with space
        GetPlayerName(playerid, SenderName, sizeof(SenderName)); // Getting the player's name
       
        format(TextOutput, sizeof(TextOutput), "%s:%s", SenderName, text); // Formatting the output string, since text[0] is now a space, an example output would be 'James: Hello'
   
        for(new i; i < MAX_PLAYERS; i++) // Replace with foreach if you're using it.
        {
            if(IsPlayerAdmin(i)) SendClientMessage(i,0xFFFFFFFF,TextOutput); // Send the text if the i is an admin. (Will send to the sender aswell.)
        }
   
        return 0; // Don't send the message publicly.
    }
    return 1;
}
Untested, but I've explained how it works.
Reply


Messages In This Thread
Help in Admin chat command - by BASITJALIL - 12.03.2011, 12:16
Re: Help in Admin chat command - by JamesC - 12.03.2011, 12:39
Re: Help in Admin chat command - by Montis123 - 12.03.2011, 12:41
Re: Help in Admin chat command - by JamesC - 12.03.2011, 12:44
Re: Help in Admin chat command - by BASITJALIL - 12.03.2011, 12:48
Re: Help in Admin chat command - by JamesC - 12.03.2011, 12:50
Re: Help in Admin chat command - by BASITJALIL - 12.03.2011, 12:56
Re: Help in Admin chat command - by Gagi_Corleone - 12.03.2011, 13:03
Re: Help in Admin chat command - by Stigg - 12.03.2011, 13:05

Forum Jump:


Users browsing this thread: 2 Guest(s)