|
Senior Member
Join Date: Jan 2011
Location: Big snow country.. :)
|

01-01-2013
, 07:28
Help me please with chat plugin
|
#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(text2, 199); remove_quotes(text2); trim(text2); new name[32]; get_user_name(id, name, 31); if(equal(text2, "")) return PLUGIN_HANDLED; if(cs_get_user_team(id) == CS_TEAM_T) { if(is_user_alive(id)) { ColorChat(0, RED, "^x01[^x03 TR ^x01] ^x03%s^x01: %s", name, text2) } else if((is_user_alive(id) == 0)) { ColorChat(0, RED, "^x01[^x03 TR ^x01] [^x03 DEAD ^x01] ^x03%s^x01: %s", name, text2) } }
if(cs_get_user_team(id) == CS_TEAM_CT) { if(is_user_alive(id)) { ColorChat(0, BLUE, "^x01[^x03 CT ^x01] ^x03%s^x01: %s", name, text2) } else if((is_user_alive(id) == 0)) { ColorChat(0, BLUE, "^x01[^x03 CT ^x01] [^x03 DEAD ^x01] ^x03%s^x01: %s", name, text2) } } if(cs_get_user_team(id) == CS_TEAM_SPECTATOR || CS_TEAM_UNASSIGNED) { ColorChat(0, GREY, "^x01[^x03 SP ^x01] ^x03%s^x01: %s", name, text2); } return PLUGIN_HANDLED; }
public hook_team_say(id) { static text2[200]; read_args(text2, 199); remove_quotes(text2); trim(text2); new name[32]; get_user_name(id, name, 31); new players[32], inum get_players(players, inum) for (new i = 0; i < inum; ++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(id, RED, "^x01[^x03 TERRRORIST ^x01] ^x03%s^x01: %s", name, text2) } else if(is_user_alive(id) == 0 && players[i] != id) { ColorChat(id, RED, "^x01[^x03 TERRRORIST ^x01] [^x03 DEAD ^x01] ^x03%s^x01: %s", name, text2) } }
if(cs_get_user_team(id) == CS_TEAM_CT) { if(is_user_alive(id) && players[i] != id) { ColorChat(id, BLUE, "^x01[^x03 COUNTER-TERRRORIST ^x01] ^x03%s^x01: %s", name, text2) } else if(is_user_alive(id) == 0 && players[i] != id) { ColorChat(id, BLUE, "^x01[^x03 COUNTER-TERRRORIST ^x01] [^x03 DEAD ^x01] ^x03%s^x01: %s", name, text2) } }
if(cs_get_user_team(id) == CS_TEAM_SPECTATOR || CS_TEAM_UNASSIGNED) { if(players[i] != id) { ColorChat(id, GREY, "^x01[^x03 SPECTATOR ^x01] ^x03%s^x01: %s", name, text2); } } } return PLUGIN_HANDLED; }
public ColorChat(id, Color: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], 251, msg, 4);
// Make sure message is not longer than 192 character. Will crash the server. message[192] = '^0';
new team, ColorChange, index, MSG_Type; if(!id) { index = FindPlayer(); MSG_Type = MSG_ALL; } else { MSG_Type = MSG_ONE; index = id; } team = get_user_team(index); ColorChange = ColorSelection(index, MSG_Type, type);
ShowColorMessage(index, MSG_Type, message); if(ColorChange) { Team_Info(index, MSG_Type, TeamName[team]); } }
ShowColorMessage(id, type, message[]) { emessage_begin(type, SayText, _, id); ewrite_byte(id) ewrite_string(message); emessage_end(); }
Team_Info(id, type, team[]) { emessage_begin(type, TeamInfo, _, id); ewrite_byte(id); ewrite_string(team); emessage_end();
return 1; }
ColorSelection(index, type, Color:Type) { switch(Type) { case RED: { return Team_Info(index, type, TeamName[1]); } case BLUE: { return Team_Info(index, type, TeamName[2]); } case GREY: { return Team_Info(index, type, TeamName[0]); } }
return 0; }
FindPlayer() { new i = -1;
while(i <= 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
__________________
sorry my bad english...
Last edited by alonelive; 01-01-2013 at 07:35.
|
|