Raised This Month: $ Target: $400
 0% 

Country Chat


Post New Thread Reply   
 
Thread Tools Display Modes
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 10-30-2009 , 15:13   Re: Country Chat
Reply With Quote #11

Your code is actually bad.

Here is a better version of the old one I made.

It now has cvars for allchat and such.

cc_say_all <0|1>
0 = Only use say to players that are alive/dead status same as yours
1 = Use say to everyone

cc_sayteam_all <0|1>
0 = Only use sayteam to teammates that are alive/dead status same as yours
1 = Use sayteam to all teammates

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <geoip>

new const g_team_names[CsTeams][] =
{
    
"Spectator",
    
"Terrorist",
    
"Counter-Terrorist",
    
"Spectator"
};

new 
g_country_code[33][5];

new 
cvar_say_all;
new 
cvar_sayteam_all;

new 
g_msgid_SayText;

new 
g_max_clients;

public 
plugin_init()
{
    
register_plugin("Country Chat""0.1""Exolent");
    
    
register_clcmd("say""CmdSay");
    
register_clcmd("say_team""CmdTeamSay");
    
    
cvar_say_all register_cvar("cc_say_all""0");
    
cvar_sayteam_all register_cvar("cc_sayteam_all""0");
    
    
g_msgid_SayText get_user_msgid("SayText");
    
    
g_max_clients get_maxplayers();
    
    
GetCountryCode(0);
}

public 
client_putinserver(client)
{
    
GetCountryCode(client);
}

public 
CmdSay(client)
{
    new 
said[192];
    
read_args(saidsizeof(said) - 1);
    
remove_quotes(said);
    
    if( !
IsValidMessage(said) ) return PLUGIN_HANDLED;
    
    new 
name[32];
    
get_user_name(clientnamesizeof(name) - 1);
    
    new 
alive is_user_alive(client);
    
    new 
tag[9];
    if( 
cs_get_user_team(client) == CS_TEAM_SPECTATOR )
    {
        
copy(tagsizeof(tag) - 1"*SPEC* ");
    }
    else if( !
alive )
    {
        
copy(tagsizeof(tag) - 1"*DEAD* ");
    }
    
    new 
say_all get_pcvar_num(cvar_say_all);
    
    new 
message[192];
    
formatex(messagesizeof(message) - 1"^x01%s %s^x03 %s^x01 :  %s"g_country_code[client], tagnamesaid);
    
    for( new 
1<= g_max_clientsi++ )
    {
        if( 
== client
        
|| !is_user_connected(i)
        || 
say_all
        
|| is_user_alive(i) != alive ) continue;
        
        
message_begin(MSG_ONE_UNRELIABLEg_msgid_SayText_i);
        
write_byte(client);
        
write_string(message);
        
message_end();
    }
    
    return 
PLUGIN_HANDLED;
}

public 
CmdTeamSay(client)
{
    new 
said[192];
    
read_args(saidsizeof(said) - 1);
    
remove_quotes(said);
    
    if( !
IsValidMessage(said) ) return PLUGIN_HANDLED;
    
    new 
name[32];
    
get_user_name(clientnamesizeof(name) - 1);
    
    new 
alive is_user_alive(client);
    
    new 
CsTeams:team cs_get_user_team(client);
    
    new 
sayteam_all get_pcvar_num(cvar_sayteam_all);
    
    new 
message[192];
    
formatex(messagesizeof(message) - 1"^x01%s (%s)^x03 %s^x01 :  %s"g_country_code[client], g_team_names[team], namesaid);
    
    for( new 
1<= g_max_clientsi++ )
    {
        if( 
== client
        
|| !is_user_connected(i)
        || 
cs_get_user_team(i) != team
        
|| sayteam_all
        
|| is_user_alive(i) != alive ) continue;
        
        
message_begin(MSG_ONE_UNRELIABLEg_msgid_SayText_i);
        
write_byte(client);
        
write_string(message);
        
message_end();
    }
    
    return 
PLUGIN_HANDLED;
}

bool:IsValidMessage(const said[])
{
    for( new 
0said[i]; i++ )
    {
        if( 
said[i] != ' ' )
        {
            return 
true;
        }
    }
    
    return 
false;
}

GetCountryCode(client)
{
    new 
ip[64];
    
get_user_ip(clientipsizeof(ip) - 11);
    
    new 
code[3];
    
    if( !
geoip_code2_ex(ipcode) )
    {
        
code[0] = '-';
        
code[1] = '-';
    }
    
    
g_country_code[client][0] = '[';
    
g_country_code[client][1] = code[0];
    
g_country_code[client][2] = code[1];
    
g_country_code[client][3] = ']';
    
    if( (
<= client <= g_max_clients)
    && 
code[0] == g_country_code[0][1]
    && 
code[1] == g_country_code[0][2] )
    {
        
g_country_code[client][0] = 0;
    }

__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Nightfall1
Senior Member
Join Date: Aug 2008
Old 10-31-2009 , 10:27   Re: Country Chat
Reply With Quote #12

You are the best Exolent[jNr] tanx
__________________
SIGNATURE
Nightfall1 is offline
Owyn
Veteran Member
Join Date: Nov 2007
Old 10-31-2009 , 13:48   Re: Country Chat
Reply With Quote #13

Quote:
3. You can crush server if you know how to.
how? i think only if author forgot to limit msg to 192
__________________
☜ Free Mozy ☂backup\҉sync user
Quote:
Американский форум - Задаёшь вопрос, потом тебе отвечают.
Израильский форум - Задаёшь вопрос, потом тебе задают вопрос.
Русский форум - Задаёшь вопрос, потом тебе долго рассказывают, какой ты мудак.
Owyn is offline
Send a message via ICQ to Owyn
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 10-31-2009 , 14:17   Re: Country Chat
Reply With Quote #14

Quote:
Originally Posted by Owyn View Post
how? i think only if author forgot to limit msg to 192
There's many ways ;)
__________________
xPaw is offline
KadiR
Unnecessary Member
Join Date: Aug 2008
Location: Zürich / Switzerland
Old 10-31-2009 , 14:51   Re: Country Chat
Reply With Quote #15

Quote:
Originally Posted by xPaw View Post
There are many ways ;)
KadiR is offline
K.K.Lv
Veteran Member
Join Date: Aug 2008
Location: GameFolder
Old 10-31-2009 , 14:52   Re: Country Chat
Reply With Quote #16

xPaw, I have a question !
What's the different from
PHP Code:
if(equal(chat""))
  return 
PLUGIN_HANDLED 
between
PHP Code:
bool:IsValidMessage(const said[]) 

    for( new 
0said[i]; i++ ) 
    { 
        if( 
said[i] != ' ' 
        { 
            return 
true
        } 
    } 
 
    return 
false

__________________
QQ:116268742
K.K.Lv is offline
Send a message via MSN to K.K.Lv
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 10-31-2009 , 14:55   Re: Country Chat
Reply With Quote #17

First: You're checking if the string is empty
Second: It checks if what player said is only spaces
@Kadir: and? do you really care what my english is bad? yours isnt perfect as well.
__________________
xPaw is offline
Owyn
Veteran Member
Join Date: Nov 2007
Old 10-31-2009 , 16:29   Re: Country Chat
Reply With Quote #18

why not let people say spaces?

btw, could you tell me ways, cuz i have simular plugin running
__________________
☜ Free Mozy ☂backup\҉sync user
Quote:
Американский форум - Задаёшь вопрос, потом тебе отвечают.
Израильский форум - Задаёшь вопрос, потом тебе задают вопрос.
Русский форум - Задаёшь вопрос, потом тебе долго рассказывают, какой ты мудак.
Owyn is offline
Send a message via ICQ to Owyn
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-31-2009 , 17:04   Re: Country Chat
Reply With Quote #19

Quote:
Originally Posted by Owyn View Post
why not let people say spaces?

btw, could you tell me ways, cuz i have simular plugin running
It's pointless to print a message that is completely composed of spaces. It doesn't prevent people from using spaces. It prevent them from saying ONLY spaces.
__________________
fysiks is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 10-31-2009 , 17:18   Re: Country Chat
Reply With Quote #20

Quote:
Originally Posted by Owyn View Post
why not let people say spaces?
Ask VALVe. If you try to say a message containing only spaces, it won't be shown.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Reply


Thread Tools
Display Modes

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 20:19.


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