PHP Code:
public Action:Command_Say(client, args)
{
if(client>0)
{
if(GetClientTeam(client) == 1)
{
new String:text[64];
GetCmdArgString(text, sizeof(text));
StripQuotes(text);
CPrintToChat(client,"");
}
}
return Plugin_Continue;
}
If you try to make a spectators-only chat, with
GetClientTeam(client) == 1 you should provide a Plugin_Handled return in if statement and you should cycle through all clients so you can print text only to spectators.
PHP Code:
public Action:Command_Say(client, args)
{
if(client>0 && client < 65) // We are checking if the client who sent a message is valid client. Better to check with IsClientInGame etc, because the fact that player id is between 1 and 64 DOES NOT mean that it's a valid client.
{
if(GetClientTeam(client) == 1) // checking team of client who sent a message
{
for (new i; i < MaxClients; i++) // fall through all clients who will possibly receive the message
{
if (IsClientConnected(i)) // cheking if selected client is valid one, better to do that with multiple functions
{
if(GetClientTeam(i) == 1) // checking selected client's team
{
new String:text[64];
GetCmdArgString(text, sizeof(text));
StripQuotes(text);
CPrintToChat(client,"%s", text);
return Plugin_Handled; // make sure that messages won't dublicate and players from other teams won't see it
}
}
}
}
}
return Plugin_Continue; // if client who we got message from is not spectator then just continue
}
Edit: You should better use higher value for text string size because if message is longer than 64 symbols rest of them will be cutten off