Raised This Month: $32 Target: $400
 8% 

[CSTRIKE FIX] mp_autokick/cs_get_user_lastactivity FIX


Post New Thread Reply   
 
Thread Tools Display Modes
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 - 1295 views - 2.8 KB)
File Type: sma Get Plugin or Get Source (lastactivity_normalizer2.sma - 1391 views - 1.7 KB)
File Type: sma Get Plugin or Get Source (lastactivity_normalizer3.sma - 1185 views - 2.0 KB)
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 07-27-2012 at 06:51.
ConnorMcLeod is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 08-08-2010 , 06:13   Re: [CSTRIKE FIX] mp_autokick/cs_get_user_lastactivity FIX
Reply With Quote #2

Shouldn't this have been posted in new plugins?
Edit: GJ.
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-08-2010 , 06:20   Re: [CSTRIKE FIX] mp_autokick/cs_get_user_lastactivity FIX
Reply With Quote #3

I don't think so (Precedent Here), but if it has i would be pleased someone move it there.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
tm.
Member
Join Date: Apr 2010
Old 08-09-2010 , 04:01   Re: [CSTRIKE FIX] mp_autokick/cs_get_user_lastactivity FIX
Reply With Quote #4

In lastactivity_normalizer3.sma if you change MAX_PLAYERS to a value smaller than 32, compiler will return at this line:
Code:
get_players(iPlayers, iNum, "ach")
this error:
Code:
error 047: array size do not match, or destination array is to small
It seems that get_players requires an array of size 32 to work.

Last edited by tm.; 08-09-2010 at 04:18.
tm. is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-09-2010 , 04:36   Re: [CSTRIKE FIX] mp_autokick/cs_get_user_lastactivity FIX
Reply With Quote #5

You should not modify this value. It's used as reference not as a value you can customize.
__________________
Arkshine is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 12-12-2010 , 20:22   Re: [CSTRIKE FIX] mp_autokick/cs_get_user_lastactivity FIX
Reply With Quote #6

Quote:
Originally Posted by ConnorMcLeod View Post
Problem with this is that sometimes the game reset player button, so last activity is updated even if players are AFK.
Can you be more specific please? This is interesting.
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
kNowo
Senior Member
Join Date: Apr 2011
Location: Malaysia
Old 11-04-2013 , 05:03   Re: [CSTRIKE FIX] mp_autokick/cs_get_user_lastactivity FIX
Reply With Quote #7

During my debugging, the pdata offset of 124 (m_flLastActivityTime) is set to the time when a player dies because his lastbutton pdata offset (245) is set to IN_SCORE (32768) at that time.

I can think of 2 solutions:
1. hook cmdstart and block the key
2. save the player's last activity time at pre death and set that value at post death

I'm sure they are a few other methods too. What is the best method to fix this bug?

EDIT: Also, it seems that lastactivity_normalizer.sma is not working correctly. Plugin is running but the pdata is still getting updated on death and pre spawn events of an afk player.

Last edited by kNowo; 11-04-2013 at 05:48.
kNowo is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 11-04-2013 , 07:09   Re: [CSTRIKE FIX] mp_autokick/cs_get_user_lastactivity FIX
Reply With Quote #8

Quote:
Originally Posted by kNowo View Post
During my debugging, the pdata offset of 124 (m_flLastActivityTime) is set to the time when a player dies because his lastbutton pdata offset (245) is set to IN_SCORE (32768) at that time.

I can think of 2 solutions:
1. hook cmdstart and block the key
2. save the player's last activity time at pre death and set that value at post death

I'm sure they are a few other methods too. What is the best method to fix this bug?

EDIT: Also, it seems that lastactivity_normalizer.sma is not working correctly. Plugin is running but the pdata is still getting updated on death and pre spawn events of an afk player.

omg, it is fixed since last hlds build and this topic is older than 2010.
update your server and use mp_autokick and mp_autokick_timeout vars.
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 11-04-2013 at 07:10.
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
kNowo
Senior Member
Join Date: Apr 2011
Location: Malaysia
Old 11-04-2013 , 09:34   Re: [CSTRIKE FIX] mp_autokick/cs_get_user_lastactivity FIX
Reply With Quote #9

Quote:
Originally Posted by ^SmileY View Post
omg, it is fixed since last hlds build and this topic is older than 2010.
update your server and use mp_autokick and mp_autokick_timeout vars.
Get your facts straight before posting or don't post at all.
kNowo is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 11-04-2013 , 09:50   Re: [CSTRIKE FIX] mp_autokick/cs_get_user_lastactivity FIX
Reply With Quote #10

Why? If you are using a old server the fact is then you need to fix using this tip.
But i assume you are a Non Steammer user for not using a updated server.

Here is the fact!

This is a 2010 article, you should really consider to update you server to correctly use the mp_autokick* vars.

__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
Old 11-04-2013, 10:29
kNowo
This message has been deleted by ConnorMcLeod. Reason: you don't want to start this
Old 11-04-2013, 10:36
^SmileY
This message has been deleted by ConnorMcLeod. Reason: you don't want to start this
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:47.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode