Add /makecapturepro command
This commit is contained in:
parent
9712c7999c
commit
96d2be9ebd
1 changed files with 45 additions and 0 deletions
|
@ -259,3 +259,48 @@ minetest.register_chatcommand("makepro", {
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_chatcommand("makecapturepro", {
|
||||||
|
params = "[player_name]",
|
||||||
|
description = "Make player a 'capture pro'",
|
||||||
|
privs = {ctf_admin = true},
|
||||||
|
func = function(name, param)
|
||||||
|
-- Check if param is specified, else target the caller
|
||||||
|
param = param:trim()
|
||||||
|
if param == "" then
|
||||||
|
param = name
|
||||||
|
end
|
||||||
|
|
||||||
|
local modified = false
|
||||||
|
local stats = ctf_stats.player(param)
|
||||||
|
|
||||||
|
local deaths = math.max(stats.deaths, 1)
|
||||||
|
if stats.kills < 1.0 * deaths then
|
||||||
|
stats.kills = math.ceil(1.01 * deaths)
|
||||||
|
modified = true
|
||||||
|
end
|
||||||
|
|
||||||
|
if stats.score < 10000 then
|
||||||
|
stats.score = 10000
|
||||||
|
modified = true
|
||||||
|
end
|
||||||
|
|
||||||
|
if stats.captures < 30 then
|
||||||
|
stats.captures = 30
|
||||||
|
modified = true
|
||||||
|
end
|
||||||
|
|
||||||
|
local attempts = math.max(stats.attempts, 1)
|
||||||
|
if stats.captures < 0.33 * attempts then
|
||||||
|
stats.captures = math.ceil(0.34 * attempts)
|
||||||
|
modified = true
|
||||||
|
end
|
||||||
|
|
||||||
|
if modified then
|
||||||
|
ctf_stats.request_save()
|
||||||
|
return true, "Made " .. param .. " a pro!"
|
||||||
|
else
|
||||||
|
return false, param .. " is already a pro!"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
Loading…
Reference in a new issue