2021-03-22 12:46:02 +01:00
|
|
|
local Public = {}
|
2020-01-12 13:54:53 +01:00
|
|
|
|
|
|
|
--[[
|
|
|
|
on_inactive_players - Performs operation on inactive players from the game
|
|
|
|
if they exceed time.
|
|
|
|
@param time - Maximum time a player can be inactive.
|
|
|
|
--]]
|
2021-03-28 16:58:54 +02:00
|
|
|
Public.on_inactive_players = function(time)
|
|
|
|
if not time then
|
|
|
|
time = 5
|
|
|
|
end
|
|
|
|
|
2021-03-22 12:46:02 +01:00
|
|
|
for _, p in pairs(game.connected_players) do
|
2021-03-28 16:58:54 +02:00
|
|
|
local afk = p.afk_time
|
|
|
|
time = time * 60 * 60
|
2021-03-22 12:46:02 +01:00
|
|
|
if afk >= time then
|
2021-03-28 16:58:54 +02:00
|
|
|
game.kick_player(p, 'Kicked by script')
|
2021-03-22 12:46:02 +01:00
|
|
|
end
|
|
|
|
end
|
2020-01-12 13:54:53 +01:00
|
|
|
end
|
|
|
|
|
2021-03-22 12:46:02 +01:00
|
|
|
return Public
|