From d9878742ec81903bd9918b867093fa15f3e8c690 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Fri, 16 Mar 2018 19:26:48 +0000 Subject: [PATCH] Added Auto Kick --- Addons/Admin/afk-kick.lua | 31 +++++++++++++++++++++++++++++++ Addons/load.lua | 1 + 2 files changed, 32 insertions(+) create mode 100644 Addons/Admin/afk-kick.lua diff --git a/Addons/Admin/afk-kick.lua b/Addons/Admin/afk-kick.lua new file mode 100644 index 00000000..dd68e7c9 --- /dev/null +++ b/Addons/Admin/afk-kick.lua @@ -0,0 +1,31 @@ +--[[ +Explosive Gaming + +This file can be used with permission but this and the credit below must remain in the file. +Contact a member of management on our discord to seek permission to use our code. +Any changes that you may make to the code are yours but that does not make the script yours. +Discord: https://discord.gg/r6dC2uK +]] +--Please Only Edit Below This Line----------------------------------------------------------- + +Event.register(-1,function(event) + Server.new_thread{ + name='afk-kick', + }:on_event('tick',function(self) + if (game.tick%3600) ~= 0 then return end + for _,player in pairs(game.connected_players) do + local afk = Ranking.get_rank(player).max_afk_time or false + if afk then + if player.afk_time > afk then game.kick_player(player) end + end + end + end):on_event('error',function(self,err) + discord_emit{ + title='Auto Kick Error', + color=Color.to_hex(defines.text_color.bg), + description='Auto Kick Error - Closed Thread', + Error=err + } + self:close() + end):open() +end) \ No newline at end of file diff --git a/Addons/load.lua b/Addons/load.lua index 31a5b49a..ff9d82b8 100644 --- a/Addons/load.lua +++ b/Addons/load.lua @@ -25,6 +25,7 @@ require('Admin/auto-message') require('Admin/tree-decon') require('Admin/inventory-search') require('Admin/base-damage') +require('Admin/afk-kick') -- commands dir require('Commands/cheat-mode')