Landrover110 wrote:Hey guys its landrover i have been in the bush for many months so haven't been able to play i was doing antipoaching and stuff so i am going to becoming back online to continue building Landrovers cheap shop (LCS) haven't been on the server for months so it must of changed alot see you all soon
best regards
Landrover
Welcome back :)
RHR wrote:@Craig: Could you please update the overview map? :)
Yep I'll do that the next time I make a backup!
Esteban wrote:Hey Craigy! I think this would be useful to you. Many users just connect and are inactive, taking valuable space for player that are actually going to play. The following code kicks players if they stay inactive for too long:
kaeza on Disconnect player if inactive thread wrote:Hello and welcome.
Something like this should work:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
-- Interval between movement checks (in seconds).
local INTERVAL = 5
-- Minimum distance to move to register as not AFK (in blocks).
local MINDIST = 0.2
-- If player does not move within this time, kick player (in seconds).
local TIMEOUT = 300 -- 5 minutes
local time_afk = { }
local last_pos = { }
local function check_moved()
for _, p in ipairs(minetest.get_connected_players()) do
local plname = p:get_player_name()
local pos = p:getpos()
local kicked
if last_pos[plname] then
local d = vector.distance(last_pos[plname], pos)
print("Player: "..plname..", Dist: "..d)
if d < MINDIST then
time_afk[plname] = (time_afk[plname] or 0) + INTERVAL
if time_afk[plname] >= TIMEOUT then
minetest.kick_player(plname,
"Inactive for "..TIMEOUT.." seconds.")
kicked = true
end
end
end
if not kicked then
last_pos[plname] = pos
end
end
minetest.after(INTERVAL, check_moved)
end
minetest.after(INTERVAL, check_moved)
minetest.register_on_leaveplayer(function(player)
local plname = player:get_player_name()
time_afk[plname] = nil
last_pos[plname] = nil
end)
Looks useful, I might add this.