Added warnings to control

This commit is contained in:
Cooldude2606
2019-06-29 01:28:17 +01:00
parent c8c0bba860
commit 5d0ef2f11a
76 changed files with 1738 additions and 409 deletions

View File

@@ -1,5 +1,5 @@
local Commands = require 'expcore.commands'
local WarningsControl = require 'modules.addons.warnings-control'
local Warnings = require 'modules.addons.warnings'
local format_chat_player_name = ext_require('expcore.common','format_chat_player_name')
local config = require 'config.warnings'
require 'config.expcore-commands.parse_roles'
@@ -10,7 +10,7 @@ Commands.new_command('give-warning','Gives a warning to a player; may lead to au
:add_alias('warn')
:enable_auto_concat()
:register(function(player,action_player,reason,raw)
WarningsControl.add_warnings(action_player,player.name)
Warnings.add_warning(action_player,player.name,reason)
local action_player_name_color = format_chat_player_name(action_player)
local by_player_name_color = format_chat_player_name(player)
game.print{'expcom-warnings.received',action_player_name_color,by_player_name_color,reason}
@@ -21,18 +21,18 @@ Commands.new_command('get-warnings','Gets the number of warnings a player has. I
:add_alias('warnings','list-warnings')
:register(function(player,action_player,raw)
if action_player then
local warnings = WarningsControl.get_warnings(action_player)
local script_warnings = WarningsControl.get_temp_warnings(action_player)
local warnings = Warnings.get_warnings(action_player)
local script_warnings = Warnings.get_script_warnings(action_player)
local action_player_name_color = format_chat_player_name(action_player)
Commands.print{'expcom-warnings.player',action_player_name_color,warnings,script_warnings,config.temp_warning_limit}
else
local rtn = {}
local user_warnings = WarningsControl.user_warnings
local user_temp_warnings = WarningsControl.user_temp_warnings
local user_warnings = Warnings.user_warnings
local user_script_warnings = Warnings.user_script_warnings
for player_name,warnings in pairs(user_warnings) do
rtn[player_name] = {#warnings,0}
end
for player_name,warnings in pairs(user_temp_warnings) do
for player_name,warnings in pairs(user_script_warnings) do
if not rtn[player_name] then
rtn[player_name] = {0,0}
end
@@ -49,8 +49,8 @@ end)
Commands.new_command('clear-warnings','Clears all warnings (and script warnings) from a player')
:add_param('player',false,'player')
:register(function(player,action_player,raw)
WarningsControl.clear_warnings(action_player,player.name)
WarningsControl.clear_temp_warnings(action_player,player.name)
Warnings.clear_warnings(action_player,player.name)
Warnings.clear_script_warnings(action_player,player.name)
local action_player_name_color = format_chat_player_name(action_player)
local by_player_name_color = format_chat_player_name(player)
game.print{'expcom-warnings.cleared',action_player_name_color,by_player_name_color}