Made requested changes

This commit is contained in:
Cooldude2606
2021-04-06 22:58:10 +01:00
parent 91bcda6d48
commit 4e9e2747fb
3 changed files with 9 additions and 6 deletions

View File

@@ -5,5 +5,5 @@ return {
afk_time = 3600*10, --- @setting afk_time The time in ticks that must pass for a player to be considered afk
kick_time = 3600*30, --- @setting kick_time The time in ticks that must pass without any active players for all players to be kicked
trust_time = 3600*60*10, --- @setting trust_time The time in ticks that a player must be online for to count as trusted
update_time = 3600*30, --- @setting update_time How often in ticks the script check for active players
update_time = 3600*30, --- @setting update_time How often in ticks the script checks for active players
}

View File

@@ -75,4 +75,7 @@ get-mead-1= Filling the drinking horn
get-mead-2= Skål!
get-beer-1= 🍺 Pouring A Glass 🍺
get-beer-2= 🍻 Chears Mate 🍻
verify=Please return to our discord and type r!verify __1__
verify=Please return to our discord and type r!verify __1__
[afk-kick]
message=All players were kicked because everyone was AFK.

View File

@@ -18,14 +18,14 @@ Global.register(primitives, function(tbl)
primitives = tbl
end)
--- Kicks an afk player, used to give to for gui to show
--- Kicks an afk player, used to add a delay so the gui has time to appear
local kick_player =
Async.register(function(player)
if game.tick - primitives.last_active < config.kick_time then return end -- Safety Catch
game.kick_player(player, 'Afk while no active players on the server')
game.kick_player(player, 'AFK while no active players on the server')
end)
--- Check for an active player every 5 minutes
--- Check for an active player every update_time number of ticks
Event.on_nth_tick(config.update_time, function()
-- Check for active players
for _, player in ipairs(game.connected_players) do
@@ -50,7 +50,7 @@ Event.on_nth_tick(config.update_time, function()
player.gui.screen.add{
type = 'frame',
name = 'afk-kick',
caption = 'All players were kicked because everyone was afk.',
caption = {'afk-kick.message'},
}.location = { x=res.width*(0.5 - 0.11*uis), y=res.height*(0.5 - 0.14*uis) }
-- Kick the player, some delay needed because network delay