mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-31 04:51:40 +09:00
Added warning commands
This commit is contained in:
@@ -2,14 +2,14 @@
|
|||||||
return {
|
return {
|
||||||
actions = { -- what actions are taking at number of warnings
|
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)
|
-- 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.received'},
|
||||||
{'warnings.recived'},
|
{'warnings.received'},
|
||||||
{'warnings.recived',{'warnings.pre-kick'}},
|
{'warnings.received',{'warnings.pre-kick'}},
|
||||||
function(player,by_player_name,number_of_warnings)
|
function(player,by_player_name,number_of_warnings)
|
||||||
game.kick_player(player,{'warnings.received',by_player_name,number_of_warnings,{'warnings.kick'}})
|
game.kick_player(player,{'warnings.received',by_player_name,number_of_warnings,{'warnings.kick'}})
|
||||||
end,
|
end,
|
||||||
{'warnings.recived',{'warnings.pre-pre-ban'}},
|
{'warnings.received',{'warnings.pre-pre-ban'}},
|
||||||
{'warnings.recived',{'warnings.pre-ban'}},
|
{'warnings.received',{'warnings.pre-ban'}},
|
||||||
function(player,by_player_name,number_of_warnings)
|
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'}}})
|
game.ban_player(player,{'warnings.received',by_player_name,number_of_warnings,{'warnings.ban',{'info.website-link'}}})
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -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.
|
lhd=All trains must be LHD! This is a long standing rule on our servers, please resepect this.
|
||||||
|
|
||||||
[warnings]
|
[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.
|
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.
|
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.
|
pre-pre-ban=You are close to reciving a ban; successful ban appeals are unlikely.
|
||||||
|
|||||||
@@ -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-count-title=The following players have reports against them:
|
||||||
report-player-report-title=__1__ has the following reports agasinst them:
|
report-player-report-title=__1__ has the following reports agasinst them:
|
||||||
report-list=__1__: __2__
|
report-list=__1__: __2__
|
||||||
report-removed=__1__ has one or more reports removed by __2__.
|
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__.
|
||||||
@@ -141,6 +141,7 @@ Event.on_nth_tick(temp_warning_cool_down/4,function()
|
|||||||
for index,time in pairs(temp_warnings) do
|
for index,time in pairs(temp_warnings) do
|
||||||
if time <= check_time then
|
if time <= check_time then
|
||||||
table.remove(temp_warnings,index)
|
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,'<server>')
|
event_emit(Public.player_temp_warning_removed,player,'<server>')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -212,9 +213,4 @@ Event.add(Public.player_temp_warning_added,function(event)
|
|||||||
end
|
end
|
||||||
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
|
return Public
|
||||||
57
modules/commands/warnings.lua
Normal file
57
modules/commands/warnings.lua
Normal file
@@ -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)
|
||||||
Reference in New Issue
Block a user