Raised This Month: $ Target: $400
 0% 

Players chat colors problem


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
medow
Member
Join Date: Mar 2013
Old 08-02-2013 , 07:03   Players chat colors problem
Reply With Quote #1

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

#define MAXSLOTS 32

enum Color
{
    
YELLOW 1// Yellow
    
GREEN// Green Color
    
TEAM_COLOR// Red, grey, blue
    
GREY// grey
    
RED// Red
    
BLUE// Blue
}

new 
TeamInfo;
new 
SayText;
new 
MaxSlots;

new 
bool:IsConnected[MAXSLOTS 1];

new 
TeamName[][] = 
{
    
"",
    
"TERRORIST",
    
"CT",
    
"SPECTATOR"
}

new 
ColorMode;

public 
plugin_init() {
    
register_plugin("Color Chat""1.03""MaTTe");
    
    
ColorMode register_cvar("colorchat_mode""2");
    
    
register_clcmd("say""hook_say",ADMIN_KICK);
    
register_clcmd("say_team""hook_team_say",ADMIN_KICK);
    
    
TeamInfo get_user_msgid("TeamInfo");
    
SayText get_user_msgid("SayText");
    
MaxSlots get_maxplayers();
}

public 
client_putinserver(player)
{
    
IsConnected[player] = true;
}

public 
client_disconnect(player)
{
    
IsConnected[player] = false;
}

public 
hook_say(id) {
    if(!
get_pcvar_num(ColorMode))
        return 
PLUGIN_CONTINUE;

    static 
text2[200];
    
read_args(text2199);
    
remove_quotes(text2);
    
trim(text2);
    
    new 
name[32];
    
get_user_name(idname31);
    
    if(
equal(text2""))
        return 
PLUGIN_HANDLED;
    switch(
get_pcvar_num(ColorMode)) {
        case 
1
        {
            if(
is_user_alive(id)) 
                
ColorChat(0RED"^x03%s : %s"nametext2);
            else
                
ColorChat(0RED"^x03*DEAD* %s : ^x03%s"nametext2);
        }
        case 
2
                        
        {
            if(
is_user_alive(id) & get_user_team(id) == 1)
                
ColorChat(0RED"%s : %s"nametext2);
                if(!
is_user_alive(id) && get_user_team(id) == 1)    
                
ColorChat(0RED"*DEAD* %s : %s"nametext2);
                        if(
is_user_alive(id) & get_user_team(id) == 2)
                                
ColorChat(0BLUE"%s : %s"nametext2);
                        if(!
is_user_alive(id) && get_user_team(id) == 1)
                                
ColorChat(0BLUE"*DEAD* %s : %s"nametext2);
                        if(
is_user_alive(id) & get_user_team(id) == 3)
                                
ColorChat(0GREY"%s : %s"nametext2);
                        if(!
is_user_alive(id) && get_user_team(id) == 3)
                                
ColorChat(0GREY"*DEAD* %s : %s"nametext2);
        }
        case 
3
        {
            if(
is_user_alive(id))
                
ColorChat(0BLUE"^x01%s : ^x03%s"nametext2);
            else
                
ColorChat(0BLUE"^x01*DEAD* %s : ^x03%s"nametext2);
        }
    }
    
    return 
PLUGIN_HANDLED;
}

public 
hook_team_say(id) {
    if(!
get_pcvar_num(ColorMode))
        return 
PLUGIN_CONTINUE;
        
    static 
text2[200];
    
read_args(text2199);
    
remove_quotes(text2);
    
trim(text2);
    
    new 
name[32];
    
get_user_name(idname31);
    
    if(
equal(text2""))
        return 
PLUGIN_HANDLED;
    switch(
get_pcvar_num(ColorMode)) {
        case 
1
        {
            if((
is_user_alive(id) == 0))
                
ColorChat(0RED"^x03*DEAD* %s : %s"nametext2);
            else
                
ColorChat(0RED"^x03%s : %s"nametext2);
        }
        case 
2
        {
            
            if(
is_user_alive(id) & get_user_team(id) == 1)
                
ColorChat(0RED"%s : %s"nametext2);
                if(!
is_user_alive(id) && get_user_team(id) == 1)    
                
ColorChat(0RED"*DEAD* %s : %s"nametext2);
                        if(
is_user_alive(id) & get_user_team(id) == 2)
                                
ColorChat(0BLUE"%s : %s"nametext2);
                        if(!
is_user_alive(id) && get_user_team(id) == 1)
                                
ColorChat(0BLUE"*DEAD* %s : %s"nametext2);
                        if(
is_user_alive(id) & get_user_team(id) == 3)
                                
ColorChat(0GREY"%s : %s"nametext2);
                        if(!
is_user_alive(id) && get_user_team(id) == 3)
                                
ColorChat(0GREY"*DEAD* %s : %s"nametext2);
        }
        case 
3
        {
            if((
is_user_alive(id) == 0))
                
ColorChat(0BLUE"^x01*DEAD* %s : ^x03%s"nametext2);
            else
                
ColorChat(0BLUE"%s : %s"nametext2);
        }
    }
    
    return 
PLUGIN_HANDLED;
}            

public 
ColorChat(idColor:type, const msg[], {Float,Sql,Result,_}:...)
{
    static 
message[256];

    switch(
type)
    {
        case 
YELLOW// Yellow
        
{
            
message[0] = 0x01;
        }
        case 
GREEN// Green
        
{
            
message[0] = 0x04;
        }
        default: 
// White, Red, Blue
        
{
            
message[0] = 0x03;
        }
    }

    
vformat(message[1], 251msg4);

    
// Make sure message is not longer than 192 character. Will crash the server.
    
message[192] = '^0';

    new 
teamColorChangeindexMSG_Type;
    
    if(!
id)
    {
        
index FindPlayer();
        
MSG_Type MSG_ALL;
    
    } else {
        
MSG_Type MSG_ONE;
        
index id;
    }
    
    
team get_user_team(index);    
    
ColorChange ColorSelection(indexMSG_Typetype);

    
ShowColorMessage(indexMSG_Typemessage);
        
    if(
ColorChange)
    {
        
Team_Info(indexMSG_TypeTeamName[team]);
    }
}

ShowColorMessage(idtypemessage[])
{
    
emessage_begin(typeSayText_id);
    
ewrite_byte(id)        
    
ewrite_string(message);
    
emessage_end();    
}

Team_Info(idtypeteam[])
{
    
emessage_begin(typeTeamInfo_id);
    
ewrite_byte(id);
    
ewrite_string(team);
    
emessage_end();

    return 
1;
}

ColorSelection(indextypeColor:Type)
{
    switch(
Type)
    {
        case 
RED:
        {
            return 
Team_Info(indextypeTeamName[1]);
        }
        case 
BLUE:
        {
            return 
Team_Info(indextypeTeamName[2]);
        }
        case 
GREY:
        {
            return 
Team_Info(indextypeTeamName[0]);
        }
    }

    return 
0;
}

FindPlayer()
{
    new 
= -1;

    while(
<= MaxSlots)
    {
        if(
IsConnected[++i])
        {
            return 
i;
        }
    }

    return -
1;

The problem is that players can't write in chat.(The text doesn't appear - look just in case 2)
medow is offline
 


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 15:50.


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