#include <amxmodx>
#include <amxmisc>
#define PLUGIN "Say rank"
#define VERSION "1.0"
#define AUTHOR "aha"
#define MAXSLOTS 32
new MaxSlots;
new TeamInfo;
new SayText;
new bool:IsConnected[MAXSLOTS + 1];
new TeamName[][] =
{
"",
"TERRORIST",
"CT",
"SPECTATOR"
}
enum Color
{
YELLOW = 1, // Yellow
GREEN, // Green Color
TEAM_COLOR, // Red, grey, blue
GREY, // grey
RED, // Red
BLUE, // Blue
}
public plugin_init()
{
register_plugin(PLUGIN,VERSION,AUTHOR)
register_dictionary("sayrank.txt")
register_clcmd("say /rank", "text")
register_clcmd("say rank", "text")
register_clcmd("say /top15", "text")
register_clcmd("say top15", "text")
register_clcmd("say /rankstats", "text")
register_clcmd("say /stats", "text")
register_clcmd("say /statsme", "text")
register_clcmd("say /rank2", "text2")
TeamInfo = get_user_msgid("TeamInfo");
SayText = get_user_msgid("SayText");
MaxSlots = get_maxplayers();
}
public text(id)
{
new msg[128]
format(msg, 127, "%L", id, "STATISTIKA")
client_color(id,msg)
}
public client_color(id,msg[]){
new playerslist[32],playerscount//,i
get_players(playerslist,playerscount,"c")
while(replace(msg,127,"!W","^x01")){}
while(replace(msg,127,"0x02","^x02")){}
while(replace(msg,127,"!T","^x03")){}
while(replace(msg,127,"!G","^x04")){}
if(id==0){
message_begin(MSG_ALL, get_user_msgid("SayText"), {0,0,0},id)
write_byte(id)
write_string(msg)
message_end()
}
else{
message_begin(MSG_ONE, get_user_msgid("SayText"), {0,0,0}, id)
write_byte(id)
write_string(msg)
message_end()
}
}
public text2(id)
{
ColorChat(id, GREY, "Web Stats on
http://xxx.xx ");
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]);
}
}
FindPlayer()
{
new i = -1;
while(i <= MaxSlots)
{
if(IsConnected[++i])
{
return i;
}
}
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;
}
ShowColorMessage(id, type, message[])
{
message_begin(type, SayText, _, id);
write_byte(id)
write_string(message);
message_end();
}
Team_Info(id, type, team[])
{
message_begin(type, TeamInfo, _, id);
write_byte(id);
write_string(team);
message_end();
return 1;
}