Improve /report command
This commit is contained in:
parent
b675ab874e
commit
49c1019870
@ -3,7 +3,7 @@ unused_args = false
|
|||||||
globals = {
|
globals = {
|
||||||
"ctf_core", "ctf_map", "ctf_teams", "ctf_modebase", "ctf_gui",
|
"ctf_core", "ctf_map", "ctf_teams", "ctf_modebase", "ctf_gui",
|
||||||
"ctf_rankings", "ctf_playertag", "ctf_melee", "ctf_ranged", "ctf_combat_mode",
|
"ctf_rankings", "ctf_playertag", "ctf_melee", "ctf_ranged", "ctf_combat_mode",
|
||||||
"ctf_kill_list", "ctf_healing", "ctf_cosmetics",
|
"ctf_kill_list", "ctf_healing", "ctf_cosmetics", "ctf_report",
|
||||||
|
|
||||||
"PlayerObj", "PlayerName", "HumanReadable", "RunCallbacks",
|
"PlayerObj", "PlayerName", "HumanReadable", "RunCallbacks",
|
||||||
|
|
||||||
|
66
mods/ctf/ctf_report/init.lua
Normal file
66
mods/ctf/ctf_report/init.lua
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
ctf_report = {staff = {}}
|
||||||
|
|
||||||
|
function ctf_report.default_send_report(msg)
|
||||||
|
for name in pairs(ctf_report.staff) do
|
||||||
|
minetest.chat_send_player(name, '[REPORT] ' .. msg)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
ctf_report.send_report = ctf_report.default_send_report
|
||||||
|
|
||||||
|
minetest.register_chatcommand("report", {
|
||||||
|
params = "<msg>",
|
||||||
|
description = "Report misconduct or bugs",
|
||||||
|
func = function(name, param)
|
||||||
|
param = param:trim()
|
||||||
|
if param == "" then
|
||||||
|
return false, "Please add a message to your report. " ..
|
||||||
|
"If it's about (a) particular player(s), please also include their name(s)."
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Count the number of words, by counting for replaced spaces
|
||||||
|
-- Number of spaces = Number of words - 1
|
||||||
|
local _, count = string.gsub(param, " ", "")
|
||||||
|
if count == 0 then
|
||||||
|
return false, "If you're reporting a player, you should" ..
|
||||||
|
" also include a reason why (e.g. swearing, griefing, spawnkilling, etc.)."
|
||||||
|
end
|
||||||
|
|
||||||
|
local msg = name .. " reported: " .. param
|
||||||
|
|
||||||
|
-- Append player team for every player
|
||||||
|
msg = msg:gsub("[^ ]+", function(pname)
|
||||||
|
local team = ctf_teams.get(pname)
|
||||||
|
if team then
|
||||||
|
pname = string.format("%s (team %s)", pname, team)
|
||||||
|
end
|
||||||
|
return pname
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Append list of moderators in-game
|
||||||
|
local staff = ""
|
||||||
|
for pname in pairs(ctf_report.staff) do
|
||||||
|
staff = staff .. pname .. ", "
|
||||||
|
end
|
||||||
|
|
||||||
|
if staff == "" then
|
||||||
|
msg = msg .. " (no moderators online)"
|
||||||
|
else
|
||||||
|
msg = msg .. " (moderators online: " .. staff:sub(0, -3) .. ")"
|
||||||
|
end
|
||||||
|
|
||||||
|
ctf_report.send_report(msg)
|
||||||
|
|
||||||
|
return true, "Report has been sent."
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_on_joinplayer(function(player)
|
||||||
|
if minetest.check_player_privs(player, { kick = true }) then
|
||||||
|
ctf_report.staff[player:get_player_name()] = true
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
minetest.register_on_leaveplayer(function(player)
|
||||||
|
ctf_report.staff[player:get_player_name()] = nil
|
||||||
|
end)
|
3
mods/ctf/ctf_report/mod.conf
Normal file
3
mods/ctf/ctf_report/mod.conf
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
name = ctf_report
|
||||||
|
depends = ctf_teams
|
||||||
|
description = Allows players to report misconduct or bugs using /report.
|
Loading…
x
Reference in New Issue
Block a user