Raised This Month: $12 Target: $400
 3% 

REQ


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mousesports
Senior Member
Join Date: Oct 2010
Old 03-24-2020 , 11:52   REQ
Reply With Quote #1

Hello ,
I have this simple afk kicker and i cant compile . Can enyone help me with this ? Thank you !
Attached Images
File Type: jpg afk.jpg (97.0 KB, 89 views)
Attached Files
File Type: sma Get Plugin or Get Source (afksimplu.sma - 74 views - 3.4 KB)
__________________

Last edited by mousesports; 03-27-2020 at 11:29.
mousesports is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 03-24-2020 , 13:08   Re: REQ
Reply With Quote #2

#include <amxmisc>

PHP Code:
/*
 *
 *    Author:        Cheesy Peteza
 *    Date:        18-Mar-2004
 *
 *
 *    Description:    A generic AFK Kicker that should work with nearly all Half-Life mods.
 *            Tested with Natural-Selection v3.0 beta 3, Counter-Strike 1.6 and Day of Defeat.
 *
 *    Cvars:
 *            mp_afktime 90        Time a player is allowed to be AFK in seconds before they are kicked. (minimum 30 sec)
 *                        They time is only accumulated while they are alive.
 *            mp_afkminplayers 8    Minimum number of players required to be on the server before the plugin starts kicking.
 *
 *
 *    Requirements:    AMXModX
 *
 *
 */

#include <amxmodx>
#include <amxmisc>

#define MIN_AFK_TIME 30        // I use this incase stupid admins accidentally set mp_afktime to something silly.
#define WARNING_TIME 15        // Start warning the user this many seconds before they are about to be kicked.
#define CHECK_FREQ 5        // This is also the warning message frequency.

new g_oldangles[33][3]
new 
g_afktime[33]
new 
bool:g_spawned[33] = {true, ...}

public 
plugin_init() {
    
register_plugin("AFK Kicker","1.0b","Cheesy Peteza"
    
register_cvar("afk_version""1.0b"FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_SPONLY)

    
register_cvar("mp_afktime""90")    // Kick people AFK longer than this time
    
register_cvar("mp_afkminplayers""8")    // Only kick AFKs when there is atleast this many players on the server
    
set_task(float(CHECK_FREQ),"checkPlayers",_,_,_,"b")
    
register_event("ResetHUD""playerSpawned""be")
}

public 
checkPlayers() {
    for (new 
1<= get_maxplayers(); i++) {
        if (
is_user_alive(i) && is_user_connected(i) && !is_user_admin(i) && !is_user_bot(i) && !is_user_hltv(i) && g_spawned[i]) {
            new 
newangle[3]
            
get_user_origin(inewangle)

            if ( 
newangle[0] == g_oldangles[i][0] && newangle[1] == g_oldangles[i][1] && newangle[2] == g_oldangles[i][2] ) {
                
g_afktime[i] += CHECK_FREQ
                check_afktime
(i)
            } else {
                
g_oldangles[i][0] = newangle[0]
                
g_oldangles[i][1] = newangle[1]
                
g_oldangles[i][2] = newangle[2]
                
g_afktime[i] = 0
            
}
        }
    }
    return 
PLUGIN_HANDLED
}

check_afktime(id) {
    new 
numplayers get_playersnum()
    new 
minplayers get_cvar_num("mp_afkminplayers")
                    
    if (
numplayers >= minplayers) {
        new 
maxafktime get_cvar_num("mp_afktime")
        if (
maxafktime MIN_AFK_TIME) {
            
log_amx("cvar mp_afktime %i is too low. Minimum value is %i."maxafktimeMIN_AFK_TIME)
            
maxafktime MIN_AFK_TIME
            set_cvar_num
("mp_afktime"MIN_AFK_TIME)
        }

        if ( 
maxafktime-WARNING_TIME <= g_afktime[id] < maxafktime) {
            new 
timeleft maxafktime g_afktime[id]
            
client_print(idprint_chat"[ms-afk] You have %i seconds to move or you will be kicked for being AFK"timeleft)
        } else if (
g_afktime[id] > maxafktime) {
            new 
name[32]
            
get_user_name(idname31)
            
client_print(0print_chat"[ms-afk] %s was kicked for being AFK longer than %i seconds"namemaxafktime)
            
log_amx("%s was kicked for being AFK longer than %i seconds"namemaxafktime)
            
server_cmd("kick #%d ^"You were kicked for being AFK longer than %i seconds^""get_user_userid(id), maxafktime)
        }
    }
}

public 
client_connect(id) {
    
g_afktime[id] = 0
    
return PLUGIN_HANDLED
}

public 
client_putinserver(id) {
    
g_afktime[id] = 0
    
return PLUGIN_HANDLED
}

public 
playerSpawned(id) {
    
g_spawned[id] = false
    
new sid[1]
    
sid[0] = id
    set_task
(0.75"delayedSpawn",_sid1)    // Give the player time to drop to the floor when spawning
    
return PLUGIN_HANDLED
}

public 
delayedSpawn(sid[]) {
    
get_user_origin(sid[0], g_oldangles[sid[0]])
    
g_spawned[sid[0]] = true
    
return PLUGIN_HANDLED

__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
mousesports
Senior Member
Join Date: Oct 2010
Old 03-24-2020 , 13:11   Re: REQ
Reply With Quote #3

Thank you !
__________________
mousesports is offline
mousesports
Senior Member
Join Date: Oct 2010
Old 03-27-2020 , 11:29   Re: REQ
Reply With Quote #4

Quote:
Originally Posted by Napoleon_be View Post
#include <amxmisc>

PHP Code:
/*
 *
 *    Author:        Cheesy Peteza
 *    Date:        18-Mar-2004
 *
 *
 *    Description:    A generic AFK Kicker that should work with nearly all Half-Life mods.
 *            Tested with Natural-Selection v3.0 beta 3, Counter-Strike 1.6 and Day of Defeat.
 *
 *    Cvars:
 *            mp_afktime 90        Time a player is allowed to be AFK in seconds before they are kicked. (minimum 30 sec)
 *                        They time is only accumulated while they are alive.
 *            mp_afkminplayers 8    Minimum number of players required to be on the server before the plugin starts kicking.
 *
 *
 *    Requirements:    AMXModX
 *
 *
 */

#include <amxmodx>
#include <amxmisc>

#define MIN_AFK_TIME 30        // I use this incase stupid admins accidentally set mp_afktime to something silly.
#define WARNING_TIME 15        // Start warning the user this many seconds before they are about to be kicked.
#define CHECK_FREQ 5        // This is also the warning message frequency.

new g_oldangles[33][3]
new 
g_afktime[33]
new 
bool:g_spawned[33] = {true, ...}

public 
plugin_init() {
    
register_plugin("AFK Kicker","1.0b","Cheesy Peteza"
    
register_cvar("afk_version""1.0b"FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_SPONLY)

    
register_cvar("mp_afktime""90")    // Kick people AFK longer than this time
    
register_cvar("mp_afkminplayers""8")    // Only kick AFKs when there is atleast this many players on the server
    
set_task(float(CHECK_FREQ),"checkPlayers",_,_,_,"b")
    
register_event("ResetHUD""playerSpawned""be")
}

public 
checkPlayers() {
    for (new 
1<= get_maxplayers(); i++) {
        if (
is_user_alive(i) && is_user_connected(i) && !is_user_admin(i) && !is_user_bot(i) && !is_user_hltv(i) && g_spawned[i]) {
            new 
newangle[3]
            
get_user_origin(inewangle)

            if ( 
newangle[0] == g_oldangles[i][0] && newangle[1] == g_oldangles[i][1] && newangle[2] == g_oldangles[i][2] ) {
                
g_afktime[i] += CHECK_FREQ
                check_afktime
(i)
            } else {
                
g_oldangles[i][0] = newangle[0]
                
g_oldangles[i][1] = newangle[1]
                
g_oldangles[i][2] = newangle[2]
                
g_afktime[i] = 0
            
}
        }
    }
    return 
PLUGIN_HANDLED
}

check_afktime(id) {
    new 
numplayers get_playersnum()
    new 
minplayers get_cvar_num("mp_afkminplayers")
                    
    if (
numplayers >= minplayers) {
        new 
maxafktime get_cvar_num("mp_afktime")
        if (
maxafktime MIN_AFK_TIME) {
            
log_amx("cvar mp_afktime %i is too low. Minimum value is %i."maxafktimeMIN_AFK_TIME)
            
maxafktime MIN_AFK_TIME
            set_cvar_num
("mp_afktime"MIN_AFK_TIME)
        }

        if ( 
maxafktime-WARNING_TIME <= g_afktime[id] < maxafktime) {
            new 
timeleft maxafktime g_afktime[id]
            
client_print(idprint_chat"[ms-afk] You have %i seconds to move or you will be kicked for being AFK"timeleft)
        } else if (
g_afktime[id] > maxafktime) {
            new 
name[32]
            
get_user_name(idname31)
            
client_print(0print_chat"[ms-afk] %s was kicked for being AFK longer than %i seconds"namemaxafktime)
            
log_amx("%s was kicked for being AFK longer than %i seconds"namemaxafktime)
            
server_cmd("kick #%d ^"You were kicked for being AFK longer than %i seconds^""get_user_userid(id), maxafktime)
        }
    }
}

public 
client_connect(id) {
    
g_afktime[id] = 0
    
return PLUGIN_HANDLED
}

public 
client_putinserver(id) {
    
g_afktime[id] = 0
    
return PLUGIN_HANDLED
}

public 
playerSpawned(id) {
    
g_spawned[id] = false
    
new sid[1]
    
sid[0] = id
    set_task
(0.75"delayedSpawn",_sid1)    // Give the player time to drop to the floor when spawning
    
return PLUGIN_HANDLED
}

public 
delayedSpawn(sid[]) {
    
get_user_origin(sid[0], g_oldangles[sid[0]])
    
g_spawned[sid[0]] = true
    
return PLUGIN_HANDLED

This is kicking admins if they are afk . Cand you please make it imune for admins and spectators to be kicked the same if they are afk ? But admin to be imune
__________________
mousesports is offline
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 03-27-2020 , 13:22   Re: REQ
Reply With Quote #5

this is not kicking admins.
PHP Code:
 if (is_user_alive(i) && is_user_connected(i) && !is_user_admin(i) && !is_user_bot(i) && !is_user_hltv(i) && g_spawned[i]) 
PHP Code:
!is_user_admin(i
I dont think so that there would work something like kicking AFK spectators, like how could you find out that they're AFK if they're spectator, not moving or something
__________________
a simple act of caring creates an endless ripple.
Nutu_ is offline
mousesports
Senior Member
Join Date: Oct 2010
Old 03-29-2020 , 07:07   Re: REQ
Reply With Quote #6

Quote:
Originally Posted by Nutu_ View Post
this is not kicking admins.
PHP Code:
 if (is_user_alive(i) && is_user_connected(i) && !is_user_admin(i) && !is_user_bot(i) && !is_user_hltv(i) && g_spawned[i]) 
PHP Code:
!is_user_admin(i
I dont think so that there would work something like kicking AFK spectators, like how could you find out that they're AFK if they're spectator, not moving or something
I was afk and that plugin kicked me .. Its hard to understand ?
__________________
mousesports is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-29-2020 , 07:41   Re: REQ
Reply With Quote #7

You weren't an admin.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Reply


Thread Tools
Display Modes

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 07:06.


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