View Single Post
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 01-09-2023 , 16:05   Re: [CS:GO] Simple Connect Message
Reply With Quote #12

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_true1.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_true1.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]"clientsSteamIDsCountry);
}

public 
void OnClientDisconnect(int client)
{
    if(
bOut && GetInfo(client))
        
PrintToChatAll(" \x04[DISCONNECT]\x03 %N (%s) has left the server from [%s]"clientsSteamIDsCountry);
}

stock bool GetInfo(int client)
{
    if(
IsFakeClient(client))
        return 
false;

    
GetClientAuthId(clientAuthId_Steam2sSteamIDsizeof(sSteamID));
    if(!
GetClientIP(clientsIPsizeof(sIP), true) || !GeoipCountry(sIPsCountrysizeof(sCountry)))
        
sCountry "Unknown Country";
    return 
true;

Attached Thumbnails
Click image for larger version

Name:	csgo_colors_.png
Views:	37
Size:	7.9 KB
ID:	198897  
__________________
Grey83 is offline