Added simple_ranks support

master
Роман 2017-10-21 00:39:48 +03:00
parent 91895fc1a9
commit e8effb87b3
2 changed files with 17 additions and 11 deletions

View File

@ -1,19 +1,19 @@
Afk tag mod for Minetest by Dargod, fork of GunshipPenguin afkkick mod
Afk Kick mod for Minetest by GunshipPenguin
Change players tag to [AFK] after they are Afk for an amount of time. By default,
players are marked as afk after two minutes, although this can be configured.
Kicks players after they are Afk for an amount of time. By default,
players are kicked after five minutes, although this can be configured.
Licence: CC0 (see COPYING file)
This mod can be configured by changing the variables declared in the
start of init.lua. The following is a brief explanation of each one.
MAX_INACTIVE_TIME (default 120)
MAX_INACTIVE_TIME (default 300)
Maximum amount of time that a player may remain AFK (in seconds)
before being marked.
before being kicked.
CHECK_INTERVAL (default 2)
CHECK_INTERVAL (default 1)
Time between checks for inactivity (In seconds)

View File

@ -8,8 +8,7 @@ distributed without any warranty.
]]
local MAX_INACTIVE_TIME = 120
local CHECK_INTERVAL = 2
local WARN_TIME = 20
local CHECK_INTERVAL = 1
local players = {}
local checkTimer = 0
@ -44,10 +43,17 @@ minetest.register_globalstep(function(dtime)
checkTimer = 0
--Change tag of player if he/she has been inactive for longer than MAX_INACTIVE_TIME seconds
if players[playerName]["lastAction"] + MAX_INACTIVE_TIME < currGameTime then
if minetest.get_modpath("rank") then
if players[playerName]["lastAction"] + MAX_INACTIVE_TIME < currGameTime then
minetest.get_player_by_name(playerName):set_nametag_attributes({text = "[AFK] " ..rank.getRankName(playerName).. " " ..playerName})
else minetest.get_player_by_name(playerName):set_nametag_attributes({text = "" ..rank.getRankName(playerName).. " " ..playerName})
end
else
if players[playerName]["lastAction"] + MAX_INACTIVE_TIME < currGameTime then
minetest.get_player_by_name(playerName):set_nametag_attributes({text = "[AFK] " ..playerName})
--minetest.chat_send_player("You have been marked as AFK")
else minetest.get_player_by_name(playerName):set_nametag_attributes({text = "" ..playerName})
--minetest.chat_send_player(playerName, "You have been marked as AFK")
else minetest.get_player_by_name(playerName):set_nametag_attributes({text = "" ..playerName})
end
end
end