Thread: [Solved] afk slay plugin
View Single Post
Author Message
mousesports
Senior Member
Join Date: Oct 2010
Old 01-13-2019 , 04:18   afk slay plugin
Reply With Quote #1

Hello,
I have this slay_afk plugin that sometimes fails. He is set to slay after 15 seconds to those who are afk, but sometimes he also kills at least one person who is not afk.
Thank you !

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fakemeta>
#define TIME 20.0
new Float:player_origin[33][3];
public 
plugin_init()
{
     
RegisterHam(Ham_Spawn"player""e_Spawn"1);
}
 
public 
e_Spawn(id)
{
     if(
is_user_alive(id))
     {
           
set_task(0.8"get_spawn"id);
     }
     return 
HAM_IGNORED;
}

public 
get_spawn(id)
{
     
pev(idpev_originplayer_origin[id]);
     
set_task(TIME"check_afk"id);
}
 
public 
check_afk(id)
{
     if(
is_user_alive(id))
     {
          if(
same_origin(id))
          {
               
user_kill(id);
               new 
name[33];
               
get_user_name(idname32);
               
client_print(0print_chat"%s was killed for being an AFK."name);
          }
     }
}
 
public 
same_origin(id)
{
       new 
Float:origin[3];
       
pev(idpev_originorigin);
       for(new 
03i++)
             if(
origin[i] != player_origin[id][i])
                   return 
0;
       return 
1;


Last edited by mousesports; 01-13-2019 at 09:51.
mousesports is offline