Raised This Month: $ Target: $400
 0% 

Problem with AFK Detection


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 05-23-2020 , 06:33   Problem with AFK Detection
Reply With Quote #1

Hello,
I have a problem with AFK Detection, it detect me as afk, but at next spawn, when I move, it count me as AFK.
Code:
Code:
public DeathMsg() {       new iKiller = read_data( 1 );     new iVictim = read_data( 2 );     if(g_bMapBanned || !is_user_connected(iVictim) || !is_user_connected(iKiller))         return PLUGIN_HANDLED         if(afkCheck[iVictim] && afkCheck[iVictim] < 3)     {         new Float:origin[3], Float:angles[3], afk;         pev(iVictim,pev_origin,origin);         pev(iVictim,pev_v_angle,angles);         if(get_pcvar_num(spawn_afk_protection) == 2) //here is the problem. Explained at (1)         {             afk = (origin[0] == player_origin[iVictim][0]) && (origin[1] == player_origin[iVictim][1]) && (angles[0] == spawnAngles[iVictim][0]) && (angles[1] == spawnAngles[iVictim][1]) && (angles[2] == spawnAngles[iVictim][2]);         }         else         {             origin[2] = player_origin[iVictim][2]; // ignore Z-component, they fall             afk = (vector_distance(origin,player_origin[iVictim]) < 28.0) && (angles[0] == spawnAngles[iVictim][0]) && (angles[2] == spawnAngles[iVictim][2]);         }                 if(afk)         {             new name[32];             get_user_name(iVictim,name,31);                         ChatColor(iKiller, "!g* !yPlayer !g%s !yis AFK", name) // (2)             afkCheck[iVictim] = 0;                         return PLUGIN_HANDLED;         }           else         {             k++ // the counter             return PLUGIN_HANDLED         }         return PLUGIN_CONTINUE     }     afkCheck[iVictim] = 0;         return PLUGIN_HANDLED }
Registered events:
Code:
register_event( "DeathMsg" , "DeathMsg" , "a" , "4=knife" , "1>0" ); RegisterHam(Ham_Spawn,"player","fwSpawn",1)

fwSpawn() function:
Code:
public fwSpawn(id) {     if(!is_user_alive(id)         return HAM_IGNORED     spawned(id);     return HAM_IGNORED }

(1): When cvar value is 1, it increase my k with an unit and print the message from (2) point, even I am AFK or not. When it is 2, it doesn't increase k if I am AFK or now, but it show me the message from (2).
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]

Last edited by Shadows Adi; 05-23-2020 at 06:34.
Shadows Adi is offline
 



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:50.


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