From f05c02da8125f30da5e44c6204c9318a82eb468f Mon Sep 17 00:00:00 2001 From: plague006 Date: Sat, 16 Feb 2019 13:43:48 -0500 Subject: [PATCH 1/3] Hacky fix for how event handles unjailing via the button --- features/report.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/features/report.lua b/features/report.lua index 37e06eb2..317b14d5 100644 --- a/features/report.lua +++ b/features/report.lua @@ -329,7 +329,10 @@ Gui.on_click( Module.jail(target, event.player) else target_name = string.sub(event.element.caption, 8) - Module.unjail({['parameter'] = target_name, ['player'] = event.player}) + target = game.players[target_name] + if target then + Module.unjail(target, event.player) + end end Module.show_reports(event.player) Module.show_reports(event.player) -- Double toggle, first destroy then draw. From af179c71898503c6416f122d0e0a4c1bff7ea8d8 Mon Sep 17 00:00:00 2001 From: plague006 Date: Sat, 16 Feb 2019 15:09:04 -0500 Subject: [PATCH 2/3] Fix unjailing player not in jail --- features/report.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/features/report.lua b/features/report.lua index 317b14d5..88e531e8 100644 --- a/features/report.lua +++ b/features/report.lua @@ -262,9 +262,13 @@ function Module.unjail(target_player, player) local target_name = target_player.name local target_index = target_player.index - local permissions = game.permissions local target_jail_data = jail_data[target_index] + if not target_jail_data then + Game.player_print(format('%s is already not in Jail.', target_name)) + return + end + local permissions = game.permissions -- Check if the permission group exists, if it doesn't, create it. local permission_group = target_jail_data.perm_group or permissions.get_group(default_group) if not permission_group then From 24d2ad8c6b64b22027c5e5e6f4a44ad23d8c81cd Mon Sep 17 00:00:00 2001 From: plague006 Date: Sat, 16 Feb 2019 15:11:33 -0500 Subject: [PATCH 3/3] Improve fix --- features/report.lua | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/features/report.lua b/features/report.lua index 88e531e8..55db0b63 100644 --- a/features/report.lua +++ b/features/report.lua @@ -263,24 +263,20 @@ function Module.unjail(target_player, player) local target_name = target_player.name local target_index = target_player.index local target_jail_data = jail_data[target_index] - if not target_jail_data then + + local permissions = game.permissions + local jail_permission_group = permissions.get_group(jail_name) + if (not jail_permission_group) or target_player.permission_group ~= jail_permission_group or not target_jail_data then Game.player_print(format('%s is already not in Jail.', target_name)) return end - local permissions = game.permissions - -- Check if the permission group exists, if it doesn't, create it. + -- Check if the player's former permission group exists, if it doesn't, create it. local permission_group = target_jail_data.perm_group or permissions.get_group(default_group) if not permission_group then permission_group = permissions.create_group(default_group) end - local jail_permission_group = permissions.get_group(jail_name) - if (not jail_permission_group) or target_player.permission_group ~= jail_permission_group then - Game.player_print(format('%s is already not in Jail.', target_name)) - return - end - -- Move player permission_group.add_player(target_player) -- Set player to a non-shooting state (solves a niche case where players jailed while shooting will be locked into a shooting state)