From 3c604c304666e956abbb36aa8ec684a7f1be98b3 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Sun, 26 May 2019 22:16:47 +0100 Subject: [PATCH] Added warn to player list --- config/action_buttons.lua | 28 ++++++++++++++++++- config/warnings.lua | 4 +-- locale/en/gui.cfg | 1 + modules/gui/player-list.lua | 6 ++-- .../Guis}/ExpGamingAdmin/Gui/control.lua | 0 .../Guis}/ExpGamingAdmin/Gui/softmod.json | 0 .../Guis}/ExpGamingAdmin/control.lua | 0 .../Guis}/ExpGamingAdmin/locale/de.cfg | 0 .../Guis}/ExpGamingAdmin/locale/en.cfg | 0 .../Guis}/ExpGamingAdmin/locale/fr.cfg | 0 .../Guis}/ExpGamingAdmin/locale/nl.cfg | 0 .../Guis}/ExpGamingAdmin/locale/sv-SE.cfg | 0 .../Guis}/ExpGamingAdmin/softmod.json | 0 .../Guis}/playerList/control.lua | 0 .../Guis}/playerList/locale/de.cfg | 0 .../Guis}/playerList/locale/en.cfg | 0 .../Guis}/playerList/locale/fr.cfg | 0 .../Guis}/playerList/locale/nl.cfg | 0 .../Guis}/playerList/locale/sv-SE.cfg | 0 .../Guis}/playerList/softmod.json | 0 .../Guis}/playerList/src/ranking.lua | 0 21 files changed, 33 insertions(+), 6 deletions(-) rename old/modules/{ => DONE/Guis}/ExpGamingAdmin/Gui/control.lua (100%) rename old/modules/{ => DONE/Guis}/ExpGamingAdmin/Gui/softmod.json (100%) rename old/modules/{ => DONE/Guis}/ExpGamingAdmin/control.lua (100%) rename old/modules/{ => DONE/Guis}/ExpGamingAdmin/locale/de.cfg (100%) rename old/modules/{ => DONE/Guis}/ExpGamingAdmin/locale/en.cfg (100%) rename old/modules/{ => DONE/Guis}/ExpGamingAdmin/locale/fr.cfg (100%) rename old/modules/{ => DONE/Guis}/ExpGamingAdmin/locale/nl.cfg (100%) rename old/modules/{ => DONE/Guis}/ExpGamingAdmin/locale/sv-SE.cfg (100%) rename old/modules/{ => DONE/Guis}/ExpGamingAdmin/softmod.json (100%) rename old/modules/{ExpGamingPlayer => DONE/Guis}/playerList/control.lua (100%) rename old/modules/{ExpGamingPlayer => DONE/Guis}/playerList/locale/de.cfg (100%) rename old/modules/{ExpGamingPlayer => DONE/Guis}/playerList/locale/en.cfg (100%) rename old/modules/{ExpGamingPlayer => DONE/Guis}/playerList/locale/fr.cfg (100%) rename old/modules/{ExpGamingPlayer => DONE/Guis}/playerList/locale/nl.cfg (100%) rename old/modules/{ExpGamingPlayer => DONE/Guis}/playerList/locale/sv-SE.cfg (100%) rename old/modules/{ExpGamingPlayer => DONE/Guis}/playerList/softmod.json (100%) rename old/modules/{ExpGamingPlayer => DONE/Guis}/playerList/src/ranking.lua (100%) diff --git a/config/action_buttons.lua b/config/action_buttons.lua index 401854c8..b3da006a 100644 --- a/config/action_buttons.lua +++ b/config/action_buttons.lua @@ -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, diff --git a/config/warnings.lua b/config/warnings.lua index 5beace17..6e6c9211 100644 --- a/config/warnings.lua +++ b/config/warnings.lua @@ -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'}}) diff --git a/locale/en/gui.cfg b/locale/en/gui.cfg index bc5ea253..210f4ad1 100644 --- a/locale/en/gui.cfg +++ b/locale/en/gui.cfg @@ -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 diff --git a/modules/gui/player-list.lua b/modules/gui/player-list.lua index ba976685..e5b6e51b 100644 --- a/modules/gui/player-list.lua +++ b/modules/gui/player-list.lua @@ -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 diff --git a/old/modules/ExpGamingAdmin/Gui/control.lua b/old/modules/DONE/Guis/ExpGamingAdmin/Gui/control.lua similarity index 100% rename from old/modules/ExpGamingAdmin/Gui/control.lua rename to old/modules/DONE/Guis/ExpGamingAdmin/Gui/control.lua diff --git a/old/modules/ExpGamingAdmin/Gui/softmod.json b/old/modules/DONE/Guis/ExpGamingAdmin/Gui/softmod.json similarity index 100% rename from old/modules/ExpGamingAdmin/Gui/softmod.json rename to old/modules/DONE/Guis/ExpGamingAdmin/Gui/softmod.json diff --git a/old/modules/ExpGamingAdmin/control.lua b/old/modules/DONE/Guis/ExpGamingAdmin/control.lua similarity index 100% rename from old/modules/ExpGamingAdmin/control.lua rename to old/modules/DONE/Guis/ExpGamingAdmin/control.lua diff --git a/old/modules/ExpGamingAdmin/locale/de.cfg b/old/modules/DONE/Guis/ExpGamingAdmin/locale/de.cfg similarity index 100% rename from old/modules/ExpGamingAdmin/locale/de.cfg rename to old/modules/DONE/Guis/ExpGamingAdmin/locale/de.cfg diff --git a/old/modules/ExpGamingAdmin/locale/en.cfg b/old/modules/DONE/Guis/ExpGamingAdmin/locale/en.cfg similarity index 100% rename from old/modules/ExpGamingAdmin/locale/en.cfg rename to old/modules/DONE/Guis/ExpGamingAdmin/locale/en.cfg diff --git a/old/modules/ExpGamingAdmin/locale/fr.cfg b/old/modules/DONE/Guis/ExpGamingAdmin/locale/fr.cfg similarity index 100% rename from old/modules/ExpGamingAdmin/locale/fr.cfg rename to old/modules/DONE/Guis/ExpGamingAdmin/locale/fr.cfg diff --git a/old/modules/ExpGamingAdmin/locale/nl.cfg b/old/modules/DONE/Guis/ExpGamingAdmin/locale/nl.cfg similarity index 100% rename from old/modules/ExpGamingAdmin/locale/nl.cfg rename to old/modules/DONE/Guis/ExpGamingAdmin/locale/nl.cfg diff --git a/old/modules/ExpGamingAdmin/locale/sv-SE.cfg b/old/modules/DONE/Guis/ExpGamingAdmin/locale/sv-SE.cfg similarity index 100% rename from old/modules/ExpGamingAdmin/locale/sv-SE.cfg rename to old/modules/DONE/Guis/ExpGamingAdmin/locale/sv-SE.cfg diff --git a/old/modules/ExpGamingAdmin/softmod.json b/old/modules/DONE/Guis/ExpGamingAdmin/softmod.json similarity index 100% rename from old/modules/ExpGamingAdmin/softmod.json rename to old/modules/DONE/Guis/ExpGamingAdmin/softmod.json diff --git a/old/modules/ExpGamingPlayer/playerList/control.lua b/old/modules/DONE/Guis/playerList/control.lua similarity index 100% rename from old/modules/ExpGamingPlayer/playerList/control.lua rename to old/modules/DONE/Guis/playerList/control.lua diff --git a/old/modules/ExpGamingPlayer/playerList/locale/de.cfg b/old/modules/DONE/Guis/playerList/locale/de.cfg similarity index 100% rename from old/modules/ExpGamingPlayer/playerList/locale/de.cfg rename to old/modules/DONE/Guis/playerList/locale/de.cfg diff --git a/old/modules/ExpGamingPlayer/playerList/locale/en.cfg b/old/modules/DONE/Guis/playerList/locale/en.cfg similarity index 100% rename from old/modules/ExpGamingPlayer/playerList/locale/en.cfg rename to old/modules/DONE/Guis/playerList/locale/en.cfg diff --git a/old/modules/ExpGamingPlayer/playerList/locale/fr.cfg b/old/modules/DONE/Guis/playerList/locale/fr.cfg similarity index 100% rename from old/modules/ExpGamingPlayer/playerList/locale/fr.cfg rename to old/modules/DONE/Guis/playerList/locale/fr.cfg diff --git a/old/modules/ExpGamingPlayer/playerList/locale/nl.cfg b/old/modules/DONE/Guis/playerList/locale/nl.cfg similarity index 100% rename from old/modules/ExpGamingPlayer/playerList/locale/nl.cfg rename to old/modules/DONE/Guis/playerList/locale/nl.cfg diff --git a/old/modules/ExpGamingPlayer/playerList/locale/sv-SE.cfg b/old/modules/DONE/Guis/playerList/locale/sv-SE.cfg similarity index 100% rename from old/modules/ExpGamingPlayer/playerList/locale/sv-SE.cfg rename to old/modules/DONE/Guis/playerList/locale/sv-SE.cfg diff --git a/old/modules/ExpGamingPlayer/playerList/softmod.json b/old/modules/DONE/Guis/playerList/softmod.json similarity index 100% rename from old/modules/ExpGamingPlayer/playerList/softmod.json rename to old/modules/DONE/Guis/playerList/softmod.json diff --git a/old/modules/ExpGamingPlayer/playerList/src/ranking.lua b/old/modules/DONE/Guis/playerList/src/ranking.lua similarity index 100% rename from old/modules/ExpGamingPlayer/playerList/src/ranking.lua rename to old/modules/DONE/Guis/playerList/src/ranking.lua