Added command find

This commit is contained in:
Cooldude2606
2019-05-27 14:38:23 +01:00
parent ac755ba2ac
commit e1ec16ac77
5 changed files with 32 additions and 2 deletions

View File

@@ -22,6 +22,7 @@ return {
'modules.commands.reports',
'modules.commands.spawn',
'modules.commands.warnings',
'modules.commands.find',
-- QoL Addons
'modules.addons.chat-popups',
'modules.addons.damage-popups',

View File

@@ -184,7 +184,7 @@ return {
['command/report'] = {
auth=function(player,action_player_name)
if not Roles.player_allowed(player,'command/give-warning') then
return auth_lower_role(player,action_player_name)
return not Roles.player_has_flag(action_player_name,'report-immune')
end
end,
reason_callback=report_player_callback,

View File

@@ -182,6 +182,7 @@ local default = Roles.new_role('Guest','')
'command/tag-clear',
'command/chelp',
'command/list-roles',
'command/find-on-map',
'command/report',
'gui/player-list',
}

11
modules/commands/find.lua Normal file
View File

@@ -0,0 +1,11 @@
local Commands = require 'expcore.commands'
require 'config.expcore-commands.parse_general'
Commands.new_command('find-on-map','Find a player on your map.')
:add_param('player',false,'player-online') -- the player to find on the map
:add_alias('find','zoom-to')
:register(function(player,action_player,raw)
local position = action_player.position
player.zoom_to_world(position,2)
return Commands.success -- prevents command complete message from showing
end)

View File

@@ -11,6 +11,15 @@ local Colors = require 'resources.color_presets'
local action_player_store = 'gui.left.player-list.action-player'
local action_name_store = 'gui.left.player-list.action-name'
--- used on player name label to allow zoom to map
local zoom_to_map_name = Gui.uid_name()
Gui.on_click(zoom_to_map_name,function(event)
local action_player_name = event.element.caption
local action_player = Game.get_player_from_any(action_player_name)
local position = action_player.position
event.player.zoom_to_world(position,2)
end)
--- Button used to open the action bar
local open_action_bar =
Gui.new_button()
@@ -204,9 +213,17 @@ end
local function add_player(list_table,player,role_name)
open_action_bar(list_table,player.name)
-- flow to contain player_name to allow all to have trigger for zoom to map
local player_name_flow =
list_table.add{
type='flow'
}
Gui.set_padding(player_name_flow)
-- player name with the tooltip of their highest role and in they colour
local player_name =
list_table.add{
player_name_flow.add{
name=zoom_to_map_name,
type='label',
caption=player.name,
tooltip=player.name..' '..player.tag..'\n'..role_name