Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions mods/ctf/ctf_modebase/ranking_commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,42 @@ minetest.register_chatcommand("top50", {
})
end,
})
minetest.register_chatcommand("top", {
description = "Show the top players [1-200]",
params = "[mode:technical modename] <value>",
func = function(name, param)
local mode_name, mode_data, top_amt = get_gamemode(param)
if not mode_name or not mode_data then
return false, mode_data
end
if not top_amt or tonumber(top_amt)>200 or tonumber(top_amt)<1 then
return false
end
top_amt = tonumber(top_amt)
local topPlayers = {}

for i, pname in ipairs(mode_data.rankings.top:get_top(top_amt)) do
local t = table.copy(mode_data.rankings:get(pname) or {})
t.pname = pname
table.insert(topPlayers, t)
end

local own_pos = mode_data.rankings.top:get_place(name)
if own_pos > top_amt then
local t = table.copy(mode_data.rankings:get(name) or {})
t.pname = name
t.number = own_pos
table.insert(topPlayers, t)
end

mode_data.summary_ranks._sort = "score"
ctf_modebase.summary.show_gui_sorted(name, topPlayers, {}, mode_data.summary_ranks, {
title = "Top "..top_amt.." Players",
gamemode = mode_name,
disable_nonuser_colors = true,
})
end,
})

minetest.register_chatcommand("make_pro", {
description = "Make yourself or another player a pro (Will break target player's ranks)",
Expand Down