Re: Player has joined the game-message
Code:
#include <amxmodx>
#include <geoip>
#define PLUGIN "Connect Announcer"
#define VERSION "1.0"
#define AUTHOR "xPaw"
#define CN_SOUND "buttons/bell1.wav" // Connect sound
#define DC_SOUND "fvox/blip.wav" // Disconnect sound
#define szPrefix "^4[^1ZP62-UltimateX^4]"
new gSayText;
public plugin_init()
{
register_plugin( PLUGIN, VERSION, AUTHOR );
gSayText = get_user_msgid("SayText");
}
public plugin_precache()
{
precache_sound( CN_SOUND );
precache_sound( DC_SOUND );
}
public client_putinserver( id )
{
if( !is_user_bot(id) )
{
new szName[32], szCountry[46];
get_user_name(id, szName, 31);
szCountry = get_user_country( id );
if( get_user_flags(id) & ADMIN_KICK )
show_msg_all("%s ^x01Admin ^x04%s (^x01%s^x04) ^x01has connected to the server.",szPrefix, szName, szCountry);
else
show_msg_all("%s ^x01Player ^x04%s (^x01%s^x04) ^x01has connected to the server.",szPrefix, szName, szCountry);
client_cmd(0, "spk %s", CN_SOUND);
}
}
public client_disconnect( id )
{
if( !is_user_bot(id) )
{
new szName[32], szCountry[46];
get_user_name(id, szName, 31);
szCountry = get_user_country( id );
if( get_user_flags(id) & ADMIN_KICK )
show_msg_all("%s ^x01Admin ^x04%s (^x01%s^x04) ^x01has disconnected from the server.",szPrefix, szName, szCountry);
else
show_msg_all("%s ^x01Player ^x04%s (^x01%s^x04) ^x01has disconnected from the server.",szPrefix, szName, szCountry);
client_cmd(0, "spk %s", DC_SOUND);
}
}
public get_user_country( index )
{
static szIP[32], szCountry[46];
get_user_ip(index, szIP, 31);
geoip_country(szIP, szCountry);
// By GHW_Chronic
if( equal(szCountry, "error") )
{
if( !contain(szIP, "192.168.") || !contain(szIP, "10. ") || !contain(szIP, "172.") || equal(szIP, "127.0.0.1") )
szCountry = "LAN";
else if( equal(szIP, "loopback") )
szCountry = "ListenServer User";
else
szCountry = "Unknown Country";
}
return szCountry;
}
stock show_msg_all(const szMsg[], any:...)
{
new szMessage[192];
vformat(szMessage, 191, szMsg, 2);
new iNum, iPlayers[32], index;
get_players(iPlayers, iNum, "ch");
for( new i = 0; i < iNum; i++ )
{
index = iPlayers[i];
message_begin( MSG_ONE, gSayText, _, index );
write_byte( index );
write_string( szMessage );
message_end();
}
}
|