DarkRP - AutoAFK Kicker

This small script will kick players who have been afk the longest in order to allow other players to keep joining,
For example if you have a 20 slot server, and you wanted to allow people to go afk up until there are only 2 slots open
This script will kick the player who has been afk the longest (after the grace period) in order to keep those 2 slots open at all times (unless there are no afk players)

Do with it what you will. i just thought someone might find it useful

Config options are in the only file there,

AFKKickinMinOpenSlots = 2 --Number of Slots to attempt to leave open
AFKKickinGracePeriod = 300 – Grace period(seconds) you can be afk before there is a chance you get kicked
AFKKickinKickMessage = “You have been kicked for being afk the longest in order to make room for other players. Feel free to rejoin” --Kick Message

Changed link to github because someone requested it?

will post a video tomorrow afternoon , this has not been tested in a server environment yet so please feel free to let me know if you have issues and i will fix it :slight_smile:

Now im off to watch GOT

[editline]6th May 2016[/editline]

side note, does not include players who are joining when considering to kick someone or not, so if you have 16 players on and 2 joining it will not attempt to kick someone with 2 reserve spots (not sure how to get the player count with joining players as well, let me know and il add that)

With 60 seconds I can take a piss and come back finding myself kicked for being AFK. You should definitely raise the default.

Other than that, I really like that it doesn’t kick people unless the server is full. That’s really the only point where AFK kicking becomes somewhat justified. After all, it solves a very specific problem: the AFK people preventing new and active players from joining.

if you set yourself afk with /afk before going to take a piss then yes it could kick you for that, but it only takes into account the person who has been darkrp afk the longest. idk about you but i personally don’t set myself afk every time i leave to take a leak.

But that is why the grace period is there so you cant be kicked if you go afk for a few seconds and someone decides to join

maybe 5 minutes would be a better number.

Why would you ever run /afk if the only possible purpose of it is to get you kicked? Why isn’t it automatic?

This does not have its own afk timer it uses the default afk system in DarkRP. If you go afk with darkrp either from the timer or /afk that is when it saves the time you went afk and uses that to determine if you get kicked or not. (longest afk)

Very simple and less then 50 lines of code. didnt feel like recreating the wheel to do something that is already there

this was intended for personal use on a server that uses the afk timer already built into darkrp
figured someone would find it useful so i released it.

changed the afk grace to 300 seconds by default.

you should make it auto to catch those non +left’ers


I think he means the +right / +left command which lets you automatically spin around. (Prevents you from getting kicked for being afk)

oh, right. honestly didnt think about that. but. not every afker will do that and if someone is then your staff should deal with it. i dont control the darkrp afk and im not going to make my own afk system just for this one issue. if i did then this would not be a free release by me.