PHP Code:
#pragma semicolon 1
#include <geoip>
bool
bIn,
bOut;
char
sSteamID[24],
sIP[16],
sCountry[64];
public Plugin myinfo =
{
name = "Connect MSG",
author = "Crazy",
description = "Provides Info of the player when he joins",
version = "1.1",
}
public OnPluginStart()
{
ConVar cvar;
cvar = CreateConVar("sm_connectmsg", "1", "Shows a connect message in the chat once a player joins.", _, true, _, true, 1.0);
cvar.AddChangeHook(CVarChange_In);
bIn = cvar.BoolValue;
cvar = CreateConVar("sm_disconnectmsg", "1", "Shows a disconnect message in the chat once a player leaves.", _, true, _, true, 1.0);
cvar.AddChangeHook(CVarChange_Out);
bOut = cvar.BoolValue;
}
public void CVarChange_In(ConVar cvar, const char[] oldValue, const char[] newValue)
{
bIn = cvar.BoolValue;
}
public void CVarChange_Out(ConVar cvar, const char[] oldValue, const char[] newValue)
{
bOut = cvar.BoolValue;
}
public OnClientPutInServer(int client)
{
if(bIn && GetInfo(client))
PrintToChatAll(" \x04[CONNECT]\x03 %N (%s) has joined the server from [%s]", client, sSteamID, sCountry);
}
public void OnClientDisconnect(int client)
{
if(bOut && GetInfo(client))
PrintToChatAll(" \x04[DISCONNECT]\x03 %N (%s) has left the server from [%s]", client, sSteamID, sCountry);
}
stock bool GetInfo(int client)
{
if(IsFakeClient(client))
return false;
GetClientAuthId(client, AuthId_Steam2, sSteamID, sizeof(sSteamID));
if(!GetClientIP(client, sIP, sizeof(sIP), true) || !GeoipCountry(sIP, sCountry, sizeof(sCountry)))
sCountry = "Unknown Country";
return true;
}