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).
__________________