From 4727296ea47f6896ee2be83f461d1e4d192fd2f0 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Sat, 6 Jan 2018 15:47:03 +0000 Subject: [PATCH] Fixed Reports --- Addons/Admin/reports.lua | 9 +++++---- Addons/Guis/player-list.lua | 20 +++++++++++--------- Addons/Guis/reports.lua | 22 +++++++++++----------- Addons/load.lua | 2 +- 4 files changed, 28 insertions(+), 25 deletions(-) diff --git a/Addons/Admin/reports.lua b/Addons/Admin/reports.lua index 7d6cb8a7..592ab09c 100644 --- a/Addons/Admin/reports.lua +++ b/Addons/Admin/reports.lua @@ -154,12 +154,13 @@ function Admin.report(player,by_player,reason) local player, by_player_name = valid_players(player,by_player) if not player or Ranking.get_rank(player):allowed('no-report') then return end if rank:allowed('varified') then - _reports.varified[player.name] = _reports.varified[player.name] or {} - table.insert(_reports.varified,{by_player_name,reason}) + _reports().varified[player.name] = _reports().varified[player.name] or {} + table.insert(_reports().varified,{by_player_name,reason}) else - _reports.reports[player.name] = _reports.reports[player.name] or {} - table.insert(_reports.reports,{by_player_name,reason}) + _reports().reports[player.name] = _reports().reports[player.name] or {} + table.insert(_reports().reports,{by_player_name,reason}) end + report_message(player,by_player,reason) cheak_reports(player) end diff --git a/Addons/Guis/player-list.lua b/Addons/Guis/player-list.lua index 215104cb..a41da941 100644 --- a/Addons/Guis/player-list.lua +++ b/Addons/Guis/player-list.lua @@ -49,11 +49,11 @@ Gui.left.add{ draw=function(frame) frame.caption = '' local player_list = frame.add{ - name="scroll", - type = "scroll-pane", - direction = "vertical", - vertical_scroll_policy="always", - horizontal_scroll_policy="never" + name='scroll', + type = 'scroll-pane', + direction = 'vertical', + vertical_scroll_policy='always', + horizontal_scroll_policy='never' } for _,rank in pairs(Ranking._ranks()) do for _,player in pairs(rank:get_players(true)) do @@ -73,10 +73,12 @@ Gui.left.add{ caption={'player-list.format',tick_to_display_format(player.online_time),player.name,rank.short_hand} }.style.font_color = rank.colour end - if Admin.report_btn and not rank:allowed('no-report') and not player.index == frame.player_index then - local btn = Admin.report_btn:draw(flow) - btn.style.height = 20 - btn.style.width = 20 + if Admin.report_btn then + if not rank:allowed('no-report') and player.index ~= frame.player_index then + local btn = Admin.report_btn:draw(flow) + btn.style.height = 20 + btn.style.width = 20 + end end end end diff --git a/Addons/Guis/reports.lua b/Addons/Guis/reports.lua index f0e58ee1..5205775c 100644 --- a/Addons/Guis/reports.lua +++ b/Addons/Guis/reports.lua @@ -11,27 +11,24 @@ Discord: https://discord.gg/r6dC2uK local confirm_report = Gui.inputs.add{ type='button', name='admin-report-confirm', - caption='utility/spawn_flag' + caption='utility/spawn_flag', + tooltip={'reports.name'} }:on_event('click',function(event) - local parent = evet.element.parent + local parent = event.element.parent local player = Game.get_player(parent.player.caption) local reason = parent.reason.text Admin.report(player,event.player_index,reason) + Gui.center.clear(event.player_index) end) Admin.report_btn = Gui.inputs.add{ type='button', name='admin-report', - caption='utility/spawp_flag' + caption='utility/spawn_flag', + tooltip={'reports.name'} }:on_event('click',function(event) local parent = event.element.parent - local player = nil - for name,_ in pairs(parent.children) do - if name ~= 'admin-report' then - player = Game.get_player(name) - break - end - end + local player = Game.get_player(parent.children[1].name) if not player then return end local _player = Game.get_player(event) Gui.center.clear(_player) @@ -39,12 +36,15 @@ Admin.report_btn = Gui.inputs.add{ type='frame', name='report-gui' } + _player.opened=frame frame.caption={'reports.name'} frame.add{ type='textfield', name='reason' }.style.width = 300 - confirm_report:draw(frame) + local btn = confirm_report:draw(frame) + btn.style.height = 30 + btn.style.width = 30 frame.add{ type='label', name='player', diff --git a/Addons/load.lua b/Addons/load.lua index 45af3c1f..ae69689a 100644 --- a/Addons/load.lua +++ b/Addons/load.lua @@ -40,7 +40,7 @@ require('Guis/player-list') require('Guis/tasklist') require('Guis/rank-changer') require('Guis/admin-gui') -- used with Admin/admin, requires Admin/admin -require('Guis/game-settings') require('Guis/reports') -- requires Admin/reports +require('Guis/game-settings') -- other \ No newline at end of file