Raised This Month: $12 Target: $400
 3% 

Chat spec gag


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GozarD
Junior Member
Join Date: Aug 2013
Old 03-07-2014 , 10:56   Chat spec gag
Reply With Quote #1

Hi, Im trying to spec team cant chat just only with team... They cant chat with "Y" just typing with "U"

PHP Code:
public Action:Command_Say(clientargs)
{
    if(
client>0)
    {
        if(
GetClientTeam(client) == 1)
        {
            new 
String:text[64];
            
GetCmdArgString(textsizeof(text));
            
StripQuotes(text);
            
CPrintToChat(client,"");
        }
    }
    return 
Plugin_Continue;

For example if they chat with Y ... in chat doesnt appear anything

Sorry my bad english

Last edited by GozarD; 03-07-2014 at 11:01.
GozarD is offline
rocknroller
Junior Member
Join Date: Jul 2011
Old 03-07-2014 , 14:41   Re: Chat spec gag
Reply With Quote #2

PHP Code:
public Action:Command_Say(clientargs)
{
    if(
client>0)
    {
        if(
GetClientTeam(client) == 1)
        {
            new 
String:text[64];
            
GetCmdArgString(textsizeof(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(clientargs)
{
    if(
client>&& 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 
iMaxClientsi++) // 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(textsizeof(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

Last edited by rocknroller; 03-07-2014 at 14:45.
rocknroller is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 03-07-2014 , 15:07   Re: Chat spec gag
Reply With Quote #3

Quote:
Originally Posted by rocknroller View Post
PHP Code:
public Action:Command_Say(clientargs)
{
    if(
client>0)
    {
        if(
GetClientTeam(client) == 1)
        {
            new 
String:text[64];
            
GetCmdArgString(textsizeof(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(clientargs)
{
    if(
client>&& 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 
iMaxClientsi++) // 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(textsizeof(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
As I recall, the current text limit is 128.

Also, if client < 65 should be client <= MaxClients. Also, IsClientConnected(i) should probably be IsClientInGame(i)
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 03-07-2014 at 15:08.
Powerlord is offline
rocknroller
Junior Member
Join Date: Jul 2011
Old 03-07-2014 , 15:12   Re: Chat spec gag
Reply With Quote #4

Quote:
Originally Posted by Powerlord View Post
As I recall, the current text limit is 128.

Also, if client < 65 should be client <= MaxClients. Also, IsClientConnected(i) should probably be IsClientInGame(i)
I wrote that in browser so there may be some mistakes. =P
rocknroller is offline
GozarD
Junior Member
Join Date: Aug 2013
Old 03-08-2014 , 13:09   Re: Chat spec gag
Reply With Quote #5

Oh, thanks ... what do you mean that its not a valid client... IsFakeClient() doesnt check that?
And i have to change the current text limit to 128. Thanks everyone
GozarD is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:50.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode