-
-
Save kaeza/14f85ed2389a8d6855b7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local KICK_TIME = 300 -- 5 minutes | |
local player_info = { } | |
local timer = 0 | |
minetest.register_globalstep(function(dtime) | |
timer = timer + dtime | |
if timer < 5 then return end | |
for _, pl in ipairs(minetest.get_connected_players()) do | |
local pos = pl:getpos() | |
if not player_info[pl] then | |
player_info[pl] = { | |
pos = pos, | |
timer = 0, | |
} | |
end | |
local d = vector.distance(player_info[pl].pos.x, pos) | |
if d < 0.1 then | |
player_info[pl].timer = player_info[pl].timer + timer | |
if player_info[pl].timer >= KICK_TIME then | |
minetest.kick_player(pl:get_player_name(), "Kicked for idling.") | |
end | |
else | |
player_info[pl].timer = 0 | |
end | |
player_info[pl].pos = pos | |
end | |
timer = 0 | |
end) | |
minetest.register_on_leaveplayer(function(player) | |
player_info[player] = nil | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment