View Single Post
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 01-08-2020 , 10:22   Re: Disconnect Reason
Reply With Quote #91

Quote:
Originally Posted by LithuanianJack View Post
How can I do that only admins (ADMIN_BAN) would be notified about player's disconnect?
Unrelated, but try this:
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <geoip>

// DON'T INCLUDE EXTENSION IN FILE NAME FOR WAV FILES !!!
new const g_szConnectSound[] = "sound/buttons/blip1";
//new g_szConnectSoundV[] = "sound/buttons/bell1";
new const g_szDisconnectSound[] = "sound/buttons/blip2";

new 
g_bConnectSoundIsMp3g_bDisconnectSoundIsMp3;//, g_bConnectSoundVIsMp3

new g_iMaxPlayersFloat:g_fTimeConnect[33], g_szIP[33][16], g_szName[33][31], g_szAuthID[33][45], g_szCountry[33][46], g_szShortCountry[33][4];

// Determine whether we're using new geoip with cities or not
#if defined SYSTEM_METRIC
new g_szCity[33][64];
#endif

#if AMXX_VERSION_NUM <= 182
enum (+= 33)
{
    
g_iIDTaskCheckConnected 32
}
#endif

public plugin_precache()
{
    new 
szTemp[128];
    
    if (
containi(g_szConnectSound".mp3") == -1)
    {
        
formatex(szTempcharsmax(szTemp), "%s.wav"g_szConnectSound)
        
precache_generic(szTemp)
    }
    else
    {
        
g_bConnectSoundIsMp3 1;
        
precache_generic(g_szConnectSound)
    }
/*    
    if (containi(g_szConnectSoundV, ".mp3") == -1)
    {
        formatex(szTemp, charsmax(szTemp), "%s.wav", g_szConnectSoundV)
        precache_generic(szTemp)
    }
    else
    {
        g_bConnectSoundVIsMp3 = 1;
        precache_generic(g_szConnectSoundV)
    }*/
    
    
if (containi(g_szDisconnectSound".mp3") == -1)
    {
        
formatex(szTempcharsmax(szTemp), "%s.wav"g_szDisconnectSound)
        
precache_generic(szTemp)
    }
    else
    {
        
g_bDisconnectSoundIsMp3 1;
        
precache_generic(g_szDisconnectSound)
    }
}

public 
plugin_init()
{
    
register_plugin("D7 Connect Messages""1.3.9""D i 5 7 i n c T")
    
    
register_forward(FM_ClientUserInfoChanged"fwFmClientUserInfoChanged"1)
    
    
g_iMaxPlayers get_maxplayers()
}

public 
client_connect(iID)
{
    
g_szIP[iID] = "";
    
    if (
is_user_bot(iID))
        return;
    
    
g_fTimeConnect[iID] = get_gametime();
}

#if AMXX_VERSION_NUM <= 182
public fwTaskCheckConnected(iID)
{
    
iID -= g_iIDTaskCheckConnected;
    
    if (!
is_user_connected(iID))//!is_user_connecting(iID) && 
    
{
        
client_disconnect(iID)
        
        return;
    }
}
#endif

public client_putinserver(iID)
{
    if (
is_user_bot(iID))
        return;
    
    
get_user_name(iIDg_szName[iID], charsmax(g_szName[]))
    
get_user_ip(iIDg_szIP[iID], charsmax(g_szIP[]), 1)
    
get_user_authid(iIDg_szAuthID[iID], charsmax(g_szAuthID[]))
    
geoip_country(g_szIP[iID], g_szCountry[iID])
    
geoip_code3_ex(g_szIP[iID], g_szShortCountry[iID])
    
    
#if defined SYSTEM_METRIC
    
geoip_city(g_szIP[iID], g_szCity[iID], charsmax(g_szCity[]))
    
    if (!
g_szCity[iID][0] || equali(g_szCity[iID], "error"))
        
g_szCity[iID] = "?";
    
    
#endif
    
if (!g_szCountry[iID][0] || equali(g_szCountry[iID], "error"))
    {
        
g_szCountry[iID] = "?";
        
g_szShortCountry[iID] = "?";
    }
    
    
g_fTimeConnect[iID] = get_gametime() - g_fTimeConnect[iID];
    
    
remove_task(iID)
    
set_task(3.0"fwTaskShowConnectMessage"iID)
    
    
#if AMXX_VERSION_NUM <= 182
    
set_task(0.1"fwTaskCheckConnected"iID g_iIDTaskCheckConnected__"b")
    
#endif
}

public 
fwFmClientUserInfoChanged(const iID)//, const iIDBuffer
{
    if (!(
<= iID <= g_iMaxPlayers) || !g_szIP[iID][0])
        return;
    
    
get_user_name(iIDg_szName[iID], charsmax(g_szName[]))
}

public 
fwTaskShowConnectMessage(const iID)
{
    
//new iVIP = (get_user_flags(iID) & read_flags("v"))
    
    //for (new i = 1; i <= g_iMaxPlayers; i++)
    //{
    #if defined SYSTEM_METRIC
    
ftClientPrintChatColor(0iID"^3%s ^1connected in ^4%.2f^1 seconds from ^4%s^1, ^4%s^1(^4%s^1)",//"%s
    
g_szName[iID], g_fTimeConnect[iID], g_szCity[iID], g_szCountry[iID], g_szShortCountry[iID])//!iVIP ? "" : "^4VIP ", 
    
client_cmd(0"%s ^"%s^""g_bConnectSoundIsMp3 "mp3 play" "spk"g_szConnectSound)//, !iVIP ? g_szConnectSound : g_szConnectSoundV
    #else
    
ftClientPrintChatColor(0iID"^3%s ^1connected in ^4%.2f^1 seconds from ^4%s^1(^4%s^1)",//"%s
    
g_szName[iID], g_fTimeConnect[iID], g_szCountry[iID], g_szShortCountry[iID])//!iVIP ? "" : "^4VIP ", 
    
client_cmd(0"%s ^"%s^""g_bConnectSoundIsMp3 "mp3 play" "spk"g_szConnectSound)//, !iVIP ? g_szConnectSound : g_szConnectSoundV
    #endif
    //}
}

#if AMXX_VERSION_NUM <= 182
public client_disconnect(iID)
#else
public client_disconnected(iID)
#endif
{
    
remove_task(iID)
    
    if (
is_user_bot(iID) || !g_szIP[iID][0])
        return;
    
    
//new iVIP = (get_user_flags(iID) & read_flags("v"))
    
    //ftClientPrintChatColor(0, iID, "^3%s ^1[^4%s^1][^4%s^1][^4%s^1] dropped(^3%s^1)",
    //g_szName[iID], szAuthID, g_szIP[iID], g_szCountry[iID], g_szActions[g_iAction[iID]]) //, g_szAuthID[iID]
    //%s , !iVIP ? "" : "^4VIP "
    
    #if defined SYSTEM_METRIC
    
ftClientPrintChatColor(0iID"^3%s ^1from ^4%s^1, ^4%s^1(^4%s^1) disconnected."g_szName[iID], g_szCity[iID], g_szCountry[iID], g_szShortCountry[iID])
    
#else
    
ftClientPrintChatColor(0iID"^3%s ^1from ^4%s^1(^4%s^1) disconnected."g_szName[iID], g_szCountry[iID], g_szShortCountry[iID])
    
#endif
    
    
for (new 1<= g_iMaxPlayersi++)
    {
        
client_cmd(i"%s ^"%s^""g_bDisconnectSoundIsMp3 "mp3 play" "spk"g_szDisconnectSound)
        
        if (
get_user_flags(i) & ADMIN_BAN)
        {
            
client_print(iprint_console"---------------------------------------------------------------------------")
            
            
#if defined SYSTEM_METRIC
            
client_print(iprint_console"^"%s^" ^"%s^" ^"%s^" ^"%s, %s(%s)^" disconnected."g_szName[iID],
            
g_szAuthID[iID], g_szIP[iID], g_szCity[iID], g_szCountry[iID], g_szShortCountry[iID])
            
#else
            
client_print(iprint_console"^"%s^" ^"%s^" ^"%s^" ^"%s(%s)^" disconnected."g_szName[iID],
            
g_szAuthID[iID], g_szIP[iID], g_szCountry[iID], g_szShortCountry[iID])
            
#endif
            
            
client_print(iprint_console"---------------------------------------------------------------------------")
        }
    }
    
    
g_szIP[iID] = "";
    
    
#if AMXX_VERSION_NUM <= 182
    
remove_task(iID g_iIDTaskCheckConnected)
    
#endif
}

ftClientPrintChatColor(const iIDTarget 0, const iIDSender 0, const szMessage[], any:...)
{
    if (
iIDTarget && !is_user_connected(iIDTarget))
        return;
    
    static 
szBuffer[192];
    
vformat(szBuffercharsmax(szBuffer), szMessage4)
    
    static const 
szChatTag[] = "^1[^4D7^1] ";
    
format(szBuffercharsmax(szBuffer), "%s%s"szChatTagszBuffer)
    
    static 
iIDMsgSayText;
    if (!
iIDMsgSayText)
        
iIDMsgSayText get_user_msgid("SayText");
    
    if (
iIDTarget)
        
message_begin(MSG_ONEiIDMsgSayText_iIDTarget)
    else
        
message_begin(MSG_ALLiIDMsgSayText)
    
    
write_byte(!iIDSender iIDTarget iIDSender)
    
write_string(szBuffer)
    
message_end()

Attached Files
File Type: sma Get Plugin or Get Source (D7(Dis)connectMessages.sma - 210 views - 6.4 KB)
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57