diff --git a/config/warnings.lua b/config/warnings.lua index 92498102..5beace17 100644 --- a/config/warnings.lua +++ b/config/warnings.lua @@ -2,14 +2,14 @@ return { actions = { -- what actions are taking at number of warnings -- if a localized string is used then __1__ will by_player_name and __2__ will be the current warning count (auto inserted) - {'warnings.recived'}, - {'warnings.recived'}, - {'warnings.recived',{'warnings.pre-kick'}}, + {'warnings.received'}, + {'warnings.received'}, + {'warnings.received',{'warnings.pre-kick'}}, function(player,by_player_name,number_of_warnings) game.kick_player(player,{'warnings.received',by_player_name,number_of_warnings,{'warnings.kick'}}) end, - {'warnings.recived',{'warnings.pre-pre-ban'}}, - {'warnings.recived',{'warnings.pre-ban'}}, + {'warnings.received',{'warnings.pre-pre-ban'}}, + {'warnings.received',{'warnings.pre-ban'}}, function(player,by_player_name,number_of_warnings) game.ban_player(player,{'warnings.received',by_player_name,number_of_warnings,{'warnings.ban',{'info.website-link'}}}) end diff --git a/locale/en/addons.cfg b/locale/en/addons.cfg index be0775a6..07441927 100644 --- a/locale/en/addons.cfg +++ b/locale/en/addons.cfg @@ -28,7 +28,7 @@ redmew=We dont talk about redmew here; they beat us to 1000 members ;-; lhd=All trains must be LHD! This is a long standing rule on our servers, please resepect this. [warnings] -recived=You recived a warning from __1__. You have __2__ warnings. __3__ +received=You recived a warning from __1__. You have __2__ warnings. __3__ pre-kick=This is your last warning before you are kicked. kick=You were kicked for having too many warnings; you may rejoy if you wish. pre-pre-ban=You are close to reciving a ban; successful ban appeals are unlikely. diff --git a/locale/en/commands.cfg b/locale/en/commands.cfg index 8bf0ea4b..182899f8 100644 --- a/locale/en/commands.cfg +++ b/locale/en/commands.cfg @@ -28,4 +28,9 @@ report-not-reported=The player had no reports on them. report-player-count-title=The following players have reports against them: report-player-report-title=__1__ has the following reports agasinst them: report-list=__1__: __2__ -report-removed=__1__ has one or more reports removed by __2__. \ No newline at end of file +report-removed=__1__ has one or more reports removed by __2__. +warnings-received=__1__ recived a warning from __2__ for __3__. +warnings-player=__1__ has __2__ warnings and __3__/__4__ script warnings. +warnings-list-tilte=The following player have this many warnings (and this many script warnings): +warnings-list=__1__: __2__ (__3__/__4__) +warnings-cleared=__1__ had all they warnings cleared by __2__. \ No newline at end of file diff --git a/modules/addons/warnings-control.lua b/modules/addons/warnings-control.lua index 235b5b07..18e12d19 100644 --- a/modules/addons/warnings-control.lua +++ b/modules/addons/warnings-control.lua @@ -141,6 +141,7 @@ Event.on_nth_tick(temp_warning_cool_down/4,function() for index,time in pairs(temp_warnings) do if time <= check_time then table.remove(temp_warnings,index) + player.print{'warnings.script-warning-removed',#temp_warnings,config.temp_warning_limit} event_emit(Public.player_temp_warning_removed,player,'') end end @@ -212,9 +213,4 @@ Event.add(Public.player_temp_warning_added,function(event) end end) -Event.add(Public.player_temp_warning_removed,function(event) - local player = Game.get_player_by_index(event.player_index) - player.print{'warnings.script-warning-removed',event.temp_warning_count,config.temp_warning_limit} -end) - return Public \ No newline at end of file diff --git a/modules/commands/warnings.lua b/modules/commands/warnings.lua new file mode 100644 index 00000000..c4fe12f1 --- /dev/null +++ b/modules/commands/warnings.lua @@ -0,0 +1,57 @@ +local Commands = require 'expcore.commands' +local WarningsControl = require 'modules.addons.warnings-control' +local format_chat_player_name = ext_require('expcore.common','format_chat_player_name') +local config = require 'config.warnings' +require 'config.command_parse_roles' + +Commands.new_command('give-warning','Gives a warning to a player; may lead to automatic script action.') +:add_param('player',false,'player-role') +:add_param('reason',false) +:add_alias('warn') +:enable_auto_concat() +:register(function(player,action_player,reason,raw) + WarningsControl.add_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{'exp-commands.warnings-received',action_player_name_color,by_player_name_color,reason} +end) + +Commands.new_command('get-warnings','Gets the number of warnings a player has. If no player then lists all players and the number of warnings they have.') +:add_param('player',true,'player') +: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 action_player_name_color = format_chat_player_name(action_player) + Commands.print{'exp-commands.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 + 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 + if not rtn[player_name] then + rtn[player_name] = {0,0} + end + rtn[player_name][2] = #warnings + end + Commands.print{'exp-commands.warnings-list-tilte'} + for player_name,warnings in pairs(rtn) do + local player_name_color = format_chat_player_name(player_name) + Commands.print{'exp-commands.warnings-list',player_name_color,warnings[1],warnings[2],config.temp_warning_limit} + end + end +end) + +Commands.new_command('clear-warnigns','Clears all warnings (and script warnings) from a player') +:add_param('player',false,'player') +:register(function(player,action_player,raw) + WarningsControl.clear_warnings(player,player.name) + WarningsControl.clear_temp_warnings(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{'exp-commands.warnings-cleared',action_player_name_color,by_player_name_color} +end) \ No newline at end of file