mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-03-03 14:53:01 +02:00
added back /report commnad
This commit is contained in:
parent
630f204175
commit
b6fbebfd44
@ -624,14 +624,14 @@ end
|
|||||||
|
|
||||||
local function admin_chat(cmd)
|
local function admin_chat(cmd)
|
||||||
if not game.player or game.player.admin then --admins AND server
|
if not game.player or game.player.admin then --admins AND server
|
||||||
for _,p in pairs(game.players) do
|
for _, p in pairs(game.players) do
|
||||||
if p.admin then
|
if p.admin then
|
||||||
local tag = ''
|
local tag = ''
|
||||||
if game.player.tag and game.player.tag ~= '' then
|
if game.player.tag and game.player.tag ~= '' then
|
||||||
tag = ' ' .. game.player.tag
|
tag = ' ' .. game.player.tag
|
||||||
end
|
end
|
||||||
p.print(string.format("(Admin) %s%s: %s", game.player.name, tag, cmd.parameter), game.player.chat_color)
|
p.print(string.format('(Admin) %s%s: %s', game.player.name, tag, cmd.parameter), game.player.chat_color)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -697,7 +697,34 @@ commands.add_command(
|
|||||||
commands.add_command('a', 'Admin chat. Messages all other admins (Admins only)', admin_chat)
|
commands.add_command('a', 'Admin chat. Messages all other admins (Admins only)', admin_chat)
|
||||||
|
|
||||||
local Report = require('report')
|
local Report = require('report')
|
||||||
commands.add_command('showreports', 'Shows user reports (Admins only)',
|
|
||||||
|
local function report(cmd)
|
||||||
|
local reporting_player = game.player
|
||||||
|
if reporting_player then
|
||||||
|
local params = {}
|
||||||
|
for param in string.gmatch(cmd.parameter, '%S+') do
|
||||||
|
table.insert(params, param)
|
||||||
|
end
|
||||||
|
if #params < 2 then
|
||||||
|
reporting_player.print('Please enter then name of the offender and the reason for the report.')
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
local reported_player_name = params[1] or ''
|
||||||
|
local reported_player = game.players[reported_player_name]
|
||||||
|
|
||||||
|
if not reported_player then
|
||||||
|
reporting_player.print(reported_player_name .. ' does not exist.')
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
Report.report(reporting_player, reported_player, string.sub(cmd.parameter, string.len(params[1]) + 2))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
commands.add_command('report', '<griefer-name> <message> Reports a user to admins', report)
|
||||||
|
|
||||||
|
commands.add_command(
|
||||||
|
'showreports',
|
||||||
|
'Shows user reports (Admins only)',
|
||||||
function(event)
|
function(event)
|
||||||
if game.player and game.player.admin then
|
if game.player and game.player.admin then
|
||||||
Report.show_reports(game.players[event.player_index])
|
Report.show_reports(game.players[event.player_index])
|
||||||
|
@ -73,7 +73,7 @@ Module.show_reports = function(player)
|
|||||||
draw_report(report_body, #reports)
|
draw_report(report_body, #reports)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function report(reporting_player, reported_player, message)
|
function Module.report(reporting_player, reported_player, message)
|
||||||
table.insert(global.reports, {reporting_player_index = reporting_player.index, reported_player_index = reported_player.index, message = message, tick = game.tick})
|
table.insert(global.reports, {reporting_player_index = reporting_player.index, reported_player_index = reported_player.index, message = message, tick = game.tick})
|
||||||
|
|
||||||
local notified = false
|
local notified = false
|
||||||
@ -149,7 +149,7 @@ Module.spawn_reporting_popup = function(player, reported_player)
|
|||||||
input.style.width = 400
|
input.style.width = 400
|
||||||
input.style.height = 85
|
input.style.height = 85
|
||||||
local button_flow = reporting_popup.add {type = "flow"}
|
local button_flow = reporting_popup.add {type = "flow"}
|
||||||
submit_button = button_flow.add {type = "button", name = reporting_submit_button_name, caption="Submit"}
|
local submit_button = button_flow.add {type = "button", name = reporting_submit_button_name, caption="Submit"}
|
||||||
button_flow.add {type = "button", name = reporting_cancel_button_name, caption="Cancel"}
|
button_flow.add {type = "button", name = reporting_cancel_button_name, caption="Cancel"}
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -178,7 +178,7 @@ Gui.on_click(
|
|||||||
local reported_player_index = data["reported_player_index"]
|
local reported_player_index = data["reported_player_index"]
|
||||||
|
|
||||||
Gui.destroy(frame)
|
Gui.destroy(frame)
|
||||||
report(event.player, game.players[reported_player_index], msg)
|
Module.report(event.player, game.players[reported_player_index], msg)
|
||||||
|
|
||||||
event.player.print("Sucessfully reported " .. game.players[reported_player_index].name)
|
event.player.print("Sucessfully reported " .. game.players[reported_player_index].name)
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user