Kód: Vybrat vše
ColorChat(0, GREEN, "%s^x01 s IP ^x03%s^x01 Sa odpojil (^x03%s^x01)", user, ip, Country )
Podľa tohto má IP a Krajinu písať v chate takou farbou v akom ste práve teame (CT - modrou, T - červenou, SPEC - sivou) a raz napíše modrou potom zase červenou, neviete kde je chyba?
Tu je .sma
Kód: Vybrat vše
#include <amxmodx>
#include <amxmisc>
#include <geoip>
#if defined _colorchat_included
#endinput
#endif
#define _colorchat_included
enum Color
{
NORMAL = 1, // culoarea jucatorilor adica fiecare ce culoare are in config
GREEN, // verde
TEAM_COLOR, // culoare echipa
GREY, // gri
RED, // rosu
BLUE, // albastru
}
new const TeamName[][] =
{
"",
"TERRORIST",
"CT",
"SPECTATOR"
}
public plugin_init ( )
{
register_plugin ( "Player Connect", "1.0", "C" )
}
public client_putinserver(player)
{
new user[32],ip[32],Country[33]
get_user_name(player,user,31)
get_user_ip(player,ip,31,1)
geoip_country(ip,Country)
if(equal(Country,"error"))
{
if(contain(ip,"192.168.")==0 || equal(ip,"127.0.0.1") || contain(ip,"10.")==0 || contain(ip,"172.")==0)
{
Country = "LAN"
}
if(equal(ip,"loopback"))
{
Country = "ListenServer User"
}
else
{
Country = "Neznama Krajina"
}
}
ColorChat(0, GREEN, "%s^x01 s IP ^x03%s^x01 Sa pripojil (^x03%s^x01)", user, ip, Country )
}
public client_authorized(player)
{
new user[32],ip[32],Country[33]
get_user_name(player,user,31)
get_user_ip(player,ip,31,1)
geoip_country(ip,Country)
if(equal(Country,"error"))
{
if(contain(ip,"192.168.")==0 || equal(ip,"127.0.0.1") || contain(ip,"10.")==0 || contain(ip,"172.")==0)
{
Country = "LAN"
}
if(equal(ip,"loopback"))
{
Country = "ListenServer User"
}
else
{
Country = "Neznama Krajina"
}
}
ColorChat(0, GREEN, "%s^x01 Sa pripaja (^x03%s^x01)", user, Country )
}
public client_disconnect(player)
{
new user[32],ip[32],Country[33]
get_user_name(player,user,31)
get_user_ip(player,ip,31,1)
geoip_country(ip,Country)
if(equal(Country,"error"))
{
if(contain(ip,"192.168.")==0 || equal(ip,"127.0.0.1") || contain(ip,"10.")==0 || contain(ip,"172.")==0)
{
Country = "LAN"
}
if(equal(ip,"loopback"))
{
Country = "ListenServer User"
}
else
{
Country = "Neznama Krajina"
}
}
ColorChat(0, GREEN, "%s^x01 s IP ^x03%s^x01 Sa odpojil (^x03%s^x01)", user, ip, Country )
}
ColorChat(id, Color:type, const msg[], any:...)
{
new message[256];
switch(type)
{
case NORMAL:
{
message[0] = 0x01;
}
case GREEN:
{
message[0] = 0x04;
}
default:
{
message[0] = 0x03;
}
}
vformat(message[1], 251, msg, 4);
message[192] = '^0';
new team, ColorChange, index, MSG_Type;
if(id)
{
MSG_Type = MSG_ONE_UNRELIABLE;
index = id;
} else {
index = FindPlayer();
MSG_Type = MSG_BROADCAST;
}
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[])
{
static msgSayText;
if(!msgSayText)
{
msgSayText = get_user_msgid("SayText");
}
message_begin(type, msgSayText, _, id);
write_byte(id)
write_string(message);
message_end();
}
Team_Info(id, type, team[])
{
static msgTeamInfo;
if(!msgTeamInfo)
{
msgTeamInfo = get_user_msgid("TeamInfo");
}
message_begin(type, msgTeamInfo, _, id);
write_byte(id);
write_string(team);
message_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 <= get_maxplayers())
{
if(is_user_connected(++i))
return i;
}
return -1;
}
Ďakujem