Add player as an event argument

This commit is contained in:
Cooldude2606
2025-01-29 23:47:32 +00:00
parent 1a88592a8a
commit 6850cfa968
17 changed files with 91 additions and 141 deletions

View File

@@ -64,8 +64,7 @@ end
--- Teleports the user to the action player
-- @element goto_player
local goto_player = new_button("utility/export", { "player-list.goto-player" })
:on_click(function(def, event, element)
local player = Gui.get_player(event)
:on_click(function(def, player, element)
local selected_player_name = get_action_player_name(player)
local selected_player = game.players[selected_player_name]
if not player.character or not selected_player.character then
@@ -78,8 +77,7 @@ local goto_player = new_button("utility/export", { "player-list.goto-player" })
--- Teleports the action player to the user
-- @element bring_player
local bring_player = new_button("utility/import", { "player-list.bring-player" })
:on_click(function(def, event, element)
local player = Gui.get_player(event)
:on_click(function(def, player, element)
local selected_player_name = get_action_player_name(player)
local selected_player = game.players[selected_player_name]
if not player.character or not selected_player.character then
@@ -92,8 +90,7 @@ local bring_player = new_button("utility/import", { "player-list.bring-player" }
--- Reports the action player, requires a reason to be given
-- @element report_player
local report_player = new_button("utility/spawn_flag", { "player-list.report-player" })
:on_click(function(def, event, element)
local player = Gui.get_player(event)
:on_click(function(def, player, element)
local selected_player_name = get_action_player_name(player)
if Reports.is_reported(selected_player_name, player.name) then
player.print({ "exp-commands_report.already-reported" }, Colors.orange_red)
@@ -113,8 +110,7 @@ end
--- Gives the action player a warning, requires a reason
-- @element warn_player
local warn_player = new_button("utility/spawn_flag", { "player-list.warn-player" })
:on_click(function(def, event, element)
local player = Gui.get_player(event)
:on_click(function(def, player, element)
SelectedAction:set(player, "command/give-warning")
end)
@@ -128,8 +124,7 @@ end
--- Jails the action player, requires a reason
-- @element jail_player
local jail_player = new_button("utility/multiplayer_waiting_icon", { "player-list.jail-player" })
:on_click(function(def, event, element)
local player = Gui.get_player(event)
:on_click(function(def, player, element)
local selected_player_name, selected_player_color = get_action_player_name(player)
if Jail.is_jailed(selected_player_name) then
player.print({ "exp-commands_jail.already-jailed", selected_player_color }, Colors.orange_red)
@@ -148,8 +143,7 @@ end
--- Kicks the action player, requires a reason
-- @element kick_player
local kick_player = new_button("utility/warning_icon", { "player-list.kick-player" })
:on_click(function(def, event, element)
local player = Gui.get_player(event)
:on_click(function(def, player, element)
SelectedAction:set(player, "command/kick")
end)
@@ -161,8 +155,7 @@ end
--- Bans the action player, requires a reason
-- @element ban_player
local ban_player = new_button("utility/danger_icon", { "player-list.ban-player" })
:on_click(function(def, event, element)
local player = Gui.get_player(event)
:on_click(function(def, player, element)
SelectedAction:set(player, "command/ban")
end)