Add userlimit skip if sufficient score

This commit is contained in:
rubenwardy 2018-01-02 23:51:38 +00:00
parent 15653f7648
commit d66cabe446
4 changed files with 30 additions and 11 deletions

View file

@ -104,14 +104,7 @@ function chatplus.save()
end end
end end
function chatplus.clean_players() local function clean_player(name, value)
if not chatplus.players then
chatplus.players = {}
return
end
minetest.log("[Chatplus] Cleaning player lists")
for key,value in pairs(chatplus.players) do
if value.messages then if value.messages then
value.inbox = value.messages value.inbox = value.messages
value.messages = nil value.messages = nil
@ -121,8 +114,19 @@ function chatplus.clean_players()
(not value.inbox or #value.inbox==0) and (not value.inbox or #value.inbox==0) and
(not value.ignore or #value.ignore==0) (not value.ignore or #value.ignore==0)
) then ) then
chatplus.players[key] = nil chatplus.players[name] = nil
end end
end
function chatplus.clean_players()
if not chatplus.players then
chatplus.players = {}
return
end
minetest.log("[Chatplus] Cleaning player lists")
for key,value in pairs(chatplus.players) do
clean_player(key, value)
end end
chatplus.save() chatplus.save()
end end
@ -151,6 +155,7 @@ function chatplus.poke(name,player)
if player=="end" then if player=="end" then
chatplus.players[name].enabled = false chatplus.players[name].enabled = false
chatplus.loggedin[name] = nil chatplus.loggedin[name] = nil
clean_player(name, chatplus.players[name])
else else
if not chatplus.loggedin[name] then if not chatplus.loggedin[name] then
chatplus.loggedin[name] = {} chatplus.loggedin[name] = {}

View file

@ -76,6 +76,10 @@ ctf.register_on_save(function()
return nil return nil
end) end)
function ctf_stats.player_or_nil(name)
return ctf_stats.players[name], ctf_stats.current.red[name] or ctf_stats.current.blue[name]
end
-- Returns a tuple: `player_stats`, `match_player_stats` -- Returns a tuple: `player_stats`, `match_player_stats`
function ctf_stats.player(name) function ctf_stats.player(name)
local player_stats = ctf_stats.players[name] local player_stats = ctf_stats.players[name]

View file

@ -0,0 +1,2 @@
ctf
ctf_stats

View file

@ -0,0 +1,8 @@
minetest.register_can_bypass_userlimit(function(name, ip)
local pstat, discard = ctf_stats.player_or_nil(name)
local actual_max_users = tonumber(minetest.settings:get("max_users")) +
tonumber(minetest.settings:get("max_extra_users") or "10")
local req_score = tonumber(minetest.settings:get("userlimit_bypass_required_score") or "10000")
return pstat and pstat.score > req_score and #minetest.get_connected_players() < actual_max_users
end)