View Single Post
Author Message
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-08-2010 , 06:12   [CSTRIKE FIX] mp_autokick/cs_get_user_lastactivity FIX
Reply With Quote #1

Last Activity GameTime is stored in a private player offset that is updated each PreThink to the current gametime,
if players button have changed since last frame (button are stored each PostThink in another pdata).
Problem with this is that sometimes the game reset player button, so last activity is updated even if players are AFK.

The first plugin attempts to remove that bug, it makes so pdata is not updated in most situations like descripted above.
2nd plugin updates pdatas when players send a command, because if a player sends a command it means he is not AFK.
3rd plugin check players angles and updates pdatas if angles have changed,
so the pdata only takes in account AFK and not camping.


Related stuff :
To kick a player for idle, you can try this stock (not tested) :

PHP Code:
KickPlayerForIdle(id)
{
#if !defined m_flLastActivityTime
    #define m_flLastActivityTime 124
#endif

#if !defined m_flNextIdleCheckTime
    #define m_flNextIdleCheckTime 190
#endif

#if !defined m_afButtonLast
    #define m_afButtonLast 245
#endif

#if !defined mp_autokick
    
static mp_autokick
#endif
    
if( !mp_autokick )
    {
        
mp_autokick get_cvar_pointer("mp_autokick")
    }

    new 
iAutoKick get_pcvar_num(mp_autokick)

    if( !
iAutoKick )
    {
        
set_pcvar_num(mp_autokick1)
    }

    
set_pdata_float(idm_flLastActivityTime, -9999.9)
    
set_pdata_float(idm_flNextIdleCheckTime0.0)
    
set_pev(idpev_buttonget_pdata_int(idm_afButtonLast)
    
dllfunc(idDLLFunc_PlayerPreThink)

    if( !
iAutoKick )
    {
        
set_pcvar_num(mp_autokick0)
    }

Other version :
PHP Code:
KickPlayerForIdle(id)
{
    static 
__msgTextMsg 0
    
if( !__msgTextMsg )
    {
        
__msgTextMsg get_user_msgid("TextMsg")
    }

    new 
name[32] ; get_user_name(idnamecharsmax(name))
    
    
emessage_begin(MSG_ALL__msgTextMsg)
    
ewrite_byteprint_console )
    
ewrite_string"#Game_idle_kick" )
    
ewrite_stringname )
    
emessage_end()

    
server_cmd("kick ^"%s^""name)

Note : Max Idle Time allowed to a player is equal to mp_roundtime * 2 and is stored at each new round.
Big thanks to Arkshine who took time to decompile game and answer to specific questions i had.
Attached Files
File Type: sma Get Plugin or Get Source (lastactivity_normalizer.sma - 1309 views - 2.8 KB)
File Type: sma Get Plugin or Get Source (lastactivity_normalizer2.sma - 1407 views - 1.7 KB)
File Type: sma Get Plugin or Get Source (lastactivity_normalizer3.sma - 1199 views - 2.0 KB)
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 07-27-2012 at 06:51.
ConnorMcLeod is offline