Raised This Month: $ Target: $400
 0% 

Help me please with chat plugin


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
alonelive
Senior Member
Join Date: Jan 2011
Location: Big snow country.. :)
Old 01-01-2013 , 07:28   Help me please with chat plugin
Reply With Quote #1

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

#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"
}


public 
plugin_init() {
    
register_plugin("Color Chat""1.03""MaTTe");
    
    
register_clcmd("say""hook_say");
    
register_clcmd("say_team""hook_team_say");
    
    
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) {


    static 
text2[200];
    
read_args(text2199);
    
remove_quotes(text2);
    
trim(text2);
    
    new 
name[32];
    
get_user_name(idname31);
    
    if(
equal(text2""))
        return 
PLUGIN_HANDLED;
        
    if(
cs_get_user_team(id) == CS_TEAM_T) {
    
        if(
is_user_alive(id)) {        
        
ColorChat(0RED"^x01[^x03 TR ^x01] ^x03%s^x01: %s"nametext2)
        }
        
        else if((
is_user_alive(id) == 0)) {
        
ColorChat(0RED"^x01[^x03 TR ^x01] [^x03 DEAD ^x01] ^x03%s^x01: %s"nametext2)
        }
    }

    
    if(
cs_get_user_team(id) == CS_TEAM_CT) {
    
        if(
is_user_alive(id)) {        
        
ColorChat(0BLUE"^x01[^x03 CT ^x01] ^x03%s^x01: %s"nametext2)
        }
        
        else if((
is_user_alive(id) == 0)) {
        
ColorChat(0BLUE"^x01[^x03 CT ^x01] [^x03 DEAD ^x01] ^x03%s^x01: %s"nametext2)
        }
    }
    
        
    if(
cs_get_user_team(id) == CS_TEAM_SPECTATOR || CS_TEAM_UNASSIGNED) {
        
ColorChat(0GREY"^x01[^x03 SP ^x01] ^x03%s^x01: %s"nametext2);
    }
  
    return 
PLUGIN_HANDLED;
}

public 
hook_team_say(id) {
        
    static 
text2[200];
    
read_args(text2199);
    
remove_quotes(text2);
    
trim(text2);
    
    new 
name[32];
    
get_user_name(idname31);
        
    new 
players[32], inum
    get_players
(playersinum)
    
    for (new 
0inum; ++i) {
        
    if(
equal(text2""))
        return 
PLUGIN_HANDLED;
        
    if(
cs_get_user_team(id) == CS_TEAM_T) {
    
        if(
is_user_alive(id) && players[i] != id) {        
        
ColorChat(idRED"^x01[^x03 TERRRORIST ^x01] ^x03%s^x01: %s"nametext2)
        }
        
        else if(
is_user_alive(id) == && players[i] != id) {
        
ColorChat(idRED"^x01[^x03 TERRRORIST ^x01] [^x03 DEAD ^x01] ^x03%s^x01: %s"nametext2)
        }
    }

    
    if(
cs_get_user_team(id) == CS_TEAM_CT) {
    
        if(
is_user_alive(id) && players[i] != id) {        
        
ColorChat(idBLUE"^x01[^x03 COUNTER-TERRRORIST ^x01] ^x03%s^x01: %s"nametext2)
        }
        
        else if(
is_user_alive(id) == && players[i] != id) {
        
ColorChat(idBLUE"^x01[^x03 COUNTER-TERRRORIST ^x01] [^x03 DEAD ^x01] ^x03%s^x01: %s"nametext2)
        }
    }

        
    if(
cs_get_user_team(id) == CS_TEAM_SPECTATOR || CS_TEAM_UNASSIGNED) {
        if(
players[i] != id) {
        
ColorChat(idGREY"^x01[^x03 SPECTATOR ^x01] ^x03%s^x01: %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;

When i use team chat (key "U"), the message duplicated several times..
In future i want also add a logging functions for chat.

Team chat for CT and T does not work. I tried some ways to solve this function, but.. Not works CORRECTLY
Attached Thumbnails
Click image for larger version

Name:	de_inferno0000.jpg
Views:	217
Size:	99.1 KB
ID:	113886  
__________________
sorry my bad english...

Last edited by alonelive; 01-01-2013 at 07:35.
alonelive 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 13:27.


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