Added warn to player list

This commit is contained in:
Cooldude2606
2019-05-26 22:16:47 +01:00
parent 77fc58c8a0
commit 3c604c3046
21 changed files with 33 additions and 6 deletions

View File

@@ -3,6 +3,7 @@ local Roles = require 'expcore.roles'
local Store = require 'expcore.store'
local Game = require 'utils.game'
local Reports = require 'modules.addons.reports-control'
local Warnings = require 'modules.addons.warnings-control'
local Jail = require 'modules.addons.jail-control'
local format_chat_player_name = ext_require('expcore.common','format_chat_player_name')
@@ -88,6 +89,22 @@ local function report_player_callback(player,reason)
Reports.report_player(action_player,reason,player.name)
end
local warn_player =
Gui.new_button()
:set_sprites('utility/spawn_flag')
:set_tooltip{'player-list.warn-player'}
:set_style('tool_button',tool_button_style)
:on_click(function(player,element)
Store.set_child(action_name_store,player.name,'command/give-warning')
end)
local function warn_player_callback(player,reason)
local action_player,action_player_name_color = get_action_player(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}
Warnings.add_warnings(action_player,player.name)
end
local jail_player =
Gui.new_button()
:set_sprites('utility/item_editor_icon')
@@ -165,10 +182,19 @@ return {
kill_player
},
['command/report'] = {
auth=auth_lower_role,
auth=function(player,action_player_name)
if not Roles.player_allowed(player,'command/give-warning') then
return auth_lower_role(player,action_player_name)
end
end,
reason_callback=report_player_callback,
report_player
},
['command/give-warning'] = {
auth=auth_lower_role,
reason_callback=warn_player_callback,
warn_player
},
['command/jail'] = {
auth=auth_lower_role,
reason_callback=jail_player_callback,

View File

@@ -2,8 +2,8 @@
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.received'},
{'warnings.received'},
{'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'}})

View File

@@ -7,6 +7,7 @@ goto-player=Goto player
bring-player=Bring player
kill-player=Kill player
report-player=Report player
warn-player=Warn player
jail-player=Jail player
temp-ban-player=Temp ban player
kick-player=Kick player

View File

@@ -44,7 +44,7 @@ end)
end)
--- Button used to confirm a reason
local reasonc_confirm =
local reason_confirm =
Gui.new_button()
:set_sprites('utility/confirm_slot')
:set_tooltip{'player-list.reason-confirm'}
@@ -145,7 +145,7 @@ local function generate_container(player,element)
reason_field.style.height = 28
reason_field.style.minimal_width = 160
reasonc_confirm(reason_bar)
reason_confirm(reason_bar)
return list_table, action_bar
end
@@ -194,7 +194,7 @@ local function update_action_bar(player)
for action_name,buttons in pairs(config) do
if buttons.auth and not buttons.auth(player,action_player) then
element[action_name].visible = false
else
elseif Roles.player_allowed(player,action_name) then
element[action_name].visible = true
end
end