mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 20:41:41 +09:00
Added Action Buttons
This commit is contained in:
@@ -2,6 +2,8 @@ local Gui = require 'expcore.gui'
|
|||||||
local Roles = require 'expcore.roles'
|
local Roles = require 'expcore.roles'
|
||||||
local Store = require 'expcore.store'
|
local Store = require 'expcore.store'
|
||||||
local Game = require 'utils.game'
|
local Game = require 'utils.game'
|
||||||
|
local Reports = require 'modules.addons.reports-control'
|
||||||
|
local Jail = require 'modules.addons.jail-control'
|
||||||
|
|
||||||
local action_player_store = 'gui.left.player-list.action-player'
|
local action_player_store = 'gui.left.player-list.action-player'
|
||||||
|
|
||||||
@@ -25,18 +27,124 @@ local function get_action_player(player)
|
|||||||
return action_player
|
return action_player
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function teleport(from_player,to_player)
|
||||||
|
local surface = to_player.surface
|
||||||
|
local position = surface.find_non_colliding_position('character',to_player.position,32,1)
|
||||||
|
if not position then return false end -- return false if no new position
|
||||||
|
if from_player.driving then from_player.driving = false end -- kicks a player out a vehicle if in one
|
||||||
|
from_player.teleport(position,surface)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
local goto_player =
|
||||||
|
Gui.new_button()
|
||||||
|
:set_sprites('utility/export')
|
||||||
|
:set_tooltip('Goto player')
|
||||||
|
:set_style('tool_button',tool_button_style)
|
||||||
|
:on_click(function(player,element)
|
||||||
|
local action_player = get_action_player(player)
|
||||||
|
teleport(player,action_player)
|
||||||
|
end)
|
||||||
|
|
||||||
|
local bring_player =
|
||||||
|
Gui.new_button()
|
||||||
|
:set_sprites('utility/import')
|
||||||
|
:set_tooltip('Bring player')
|
||||||
|
:set_style('tool_button',tool_button_style)
|
||||||
|
:on_click(function(player,element)
|
||||||
|
local action_player = get_action_player(player)
|
||||||
|
teleport(action_player,player)
|
||||||
|
end)
|
||||||
|
|
||||||
|
local kill_player =
|
||||||
|
Gui.new_button()
|
||||||
|
:set_sprites('utility/too_far')
|
||||||
|
:set_tooltip('Kill player')
|
||||||
|
:set_style('tool_button',tool_button_style)
|
||||||
|
:on_click(function(player,element)
|
||||||
|
local action_player = get_action_player(player)
|
||||||
|
if action_player.character then
|
||||||
|
action_player.character.die()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
local report_player =
|
local report_player =
|
||||||
Gui.new_button()
|
Gui.new_button()
|
||||||
:set_sprites('utility/warning')
|
:set_sprites('utility/spawn_flag')
|
||||||
:set_tooltip('Report player')
|
:set_tooltip('Report player')
|
||||||
:set_style('tool_button',tool_button_style)
|
:set_style('tool_button',tool_button_style)
|
||||||
:on_click(function(player,element)
|
:on_click(function(player,element)
|
||||||
local action_player = get_action_player(player)
|
local action_player = get_action_player(player)
|
||||||
|
Reports.report_player(action_player,reason,player.name)
|
||||||
|
end)
|
||||||
|
|
||||||
|
local jail_player =
|
||||||
|
Gui.new_button()
|
||||||
|
:set_sprites('utility/item_editor_icon')
|
||||||
|
:set_tooltip('Jail player')
|
||||||
|
:set_style('tool_button',tool_button_style)
|
||||||
|
:on_click(function(player,element)
|
||||||
|
local action_player = get_action_player(player)
|
||||||
|
Jail.jail_player(action_player,player.name)
|
||||||
|
end)
|
||||||
|
|
||||||
|
local temp_ban_player =
|
||||||
|
Gui.new_button()
|
||||||
|
:set_sprites('utility/clock')
|
||||||
|
:set_tooltip('Temp ban player')
|
||||||
|
:set_style('tool_button',tool_button_style)
|
||||||
|
:on_click(function(player,element)
|
||||||
|
local action_player = get_action_player(player)
|
||||||
|
Jail.temp_ban_player(action_player,player.name,reason)
|
||||||
|
end)
|
||||||
|
|
||||||
|
local kick_player =
|
||||||
|
Gui.new_button()
|
||||||
|
:set_sprites('utility/warning_icon')
|
||||||
|
:set_tooltip('Kick player')
|
||||||
|
:set_style('tool_button',tool_button_style)
|
||||||
|
:on_click(function(player,element)
|
||||||
|
local action_player = get_action_player(player)
|
||||||
|
game.kick_player(action_player,reason)
|
||||||
|
end)
|
||||||
|
|
||||||
|
local ban_player =
|
||||||
|
Gui.new_button()
|
||||||
|
:set_sprites('utility/danger_icon')
|
||||||
|
:set_tooltip('Ban player')
|
||||||
|
:set_style('tool_button',tool_button_style)
|
||||||
|
:on_click(function(player,element)
|
||||||
|
local action_player = get_action_player(player)
|
||||||
|
game.ban_player(action_player,reason)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
['command/teleport'] = {
|
||||||
|
goto_player,
|
||||||
|
bring_player
|
||||||
|
},
|
||||||
|
['command/kill/always'] = {
|
||||||
|
auth=auth_lower_role,
|
||||||
|
kill_player
|
||||||
|
},
|
||||||
['command/report'] = {
|
['command/report'] = {
|
||||||
auth=auth_lower_role,
|
auth=auth_lower_role,
|
||||||
report_player
|
report_player
|
||||||
|
},
|
||||||
|
['command/jail'] = {
|
||||||
|
auth=auth_lower_role,
|
||||||
|
jail_player
|
||||||
|
},
|
||||||
|
['command/temp-ban'] = {
|
||||||
|
auth=auth_lower_role,
|
||||||
|
temp_ban_player
|
||||||
|
},
|
||||||
|
['command/kick'] = {
|
||||||
|
auth=auth_lower_role,
|
||||||
|
kick_player
|
||||||
|
},
|
||||||
|
['command/ban'] = {
|
||||||
|
auth=auth_lower_role,
|
||||||
|
ban_player
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -94,6 +94,8 @@ Roles.new_role('Trainee','TrMod')
|
|||||||
'command/give-warning',
|
'command/give-warning',
|
||||||
'command/get-warnings',
|
'command/get-warnings',
|
||||||
'command/get-reports',
|
'command/get-reports',
|
||||||
|
'command/kick',
|
||||||
|
'command/ban',
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Trusted Roles
|
--- Trusted Roles
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ local function generate_action_bar(player,element)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if buttons.auth and action_player and not buttons.auth(player,action_player) then
|
if buttons.auth and action_player and not buttons.auth(player,action_player) then
|
||||||
permission_flow.visible = false
|
--permission_flow.visible = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -144,7 +144,7 @@ local function update_action_bar(player)
|
|||||||
element.visible = true
|
element.visible = true
|
||||||
for action_name,buttons in pairs(config) do
|
for action_name,buttons in pairs(config) do
|
||||||
if buttons.auth and not buttons.auth(player,action_player) then
|
if buttons.auth and not buttons.auth(player,action_player) then
|
||||||
element[action_name].visible = false
|
--element[action_name].visible = false
|
||||||
else
|
else
|
||||||
element[action_name].visible = true
|
element[action_name].visible = true
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user