Added report jail

This commit is contained in:
Cooldude2606
2021-04-05 22:21:46 +01:00
parent 7381541aee
commit 0c859c228b
3 changed files with 30 additions and 1 deletions

View File

@@ -43,6 +43,7 @@ return {
'modules.addons.discord-alerts',
'modules.addons.chat-reply',
'modules.addons.tree-decon',
'modules.addons.report-jail',
--- Data
'modules.data.statistics',

View File

@@ -75,4 +75,7 @@ get-mead-1= Filling the drinking horn
get-mead-2= Skål!
get-beer-1= 🍺 Pouring A Glass 🍺
get-beer-2= 🍻 Chears Mate 🍻
verify=Please return to our discord and type r!verify __1__
verify=Please return to our discord and type r!verify __1__
[report-jail]
jail=__1__ was jailed because they have been reported too many times.

View File

@@ -0,0 +1,25 @@
--- When a player is reported by players with a greater combined delta playtime, the player is automatically jailed
-- @addon report-jail
local Event = require 'utils.event' ---@dep utils.event
local Jail = require 'modules.control.jail' ---@dep modules.control.jail
local Reports = require 'modules.control.reports' --- @dep modules.control.reports
local format_chat_player_name = _C.format_chat_player_name --- @dep expcore.common
--- Returns the playtime of the reporter, used to sum the playtime of all reporters
local function reporter_playtime(_, by_player_name, _)
local player = game.get_player(by_player_name)
if player == nil then return 0 end
return player.online_time
end
--- Tests the combined playtime of all reporters against the reported player
Event.add(Reports.events.on_player_reported, function(event)
local player = game.get_player(event.player_index)
local total_playtime = Reports.count_reports(player, reporter_playtime)
if total_playtime < player.online_time*1.5 then return end
-- Combined playtime is greater than 150% of the reported's playtime
local player_name_color = format_chat_player_name(player)
Jail.jail_player(player, '<reports>', 'Reported by too many players, please wait for a moderator.')
game.print{'report-jail.jail', player_name_color}
end)