12.03.2011, 12:39
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;
}