mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 12:31:41 +09:00
Added /tag and /tag-clear
This commit is contained in:
@@ -18,7 +18,8 @@ local files = {
|
|||||||
'modules.test',
|
'modules.test',
|
||||||
'modules.commands.me',
|
'modules.commands.me',
|
||||||
'modules.commands.kill',
|
'modules.commands.kill',
|
||||||
'modules.commands.admin-chat'
|
'modules.commands.admin-chat',
|
||||||
|
'modules.commands.tag',
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Loads all files in array above and logs progress
|
-- Loads all files in array above and logs progress
|
||||||
|
|||||||
@@ -506,7 +506,7 @@ end
|
|||||||
function Commands.internal_error(success,command_name,error_message)
|
function Commands.internal_error(success,command_name,error_message)
|
||||||
if not success then
|
if not success then
|
||||||
Commands.error('Internal Error, Please contact an admin','utility/cannot_build')
|
Commands.error('Internal Error, Please contact an admin','utility/cannot_build')
|
||||||
log('[ERROR] command/'..command_name..' :: '..error_message)
|
log{'expcore-commands.command-error-log-format',command_name,error_message}
|
||||||
end
|
end
|
||||||
return not success
|
return not success
|
||||||
end
|
end
|
||||||
@@ -613,8 +613,7 @@ function Commands.run_command(command_event)
|
|||||||
-- used below as the reject function
|
-- used below as the reject function
|
||||||
local parse_fail = function(error_message)
|
local parse_fail = function(error_message)
|
||||||
error_message = error_message or ''
|
error_message = error_message or ''
|
||||||
Commands.error('Invalid Param "'..param_name..'"; '..error_message)
|
return Commands.error{'expcore-commands.invalid-param',param_name,error_message}
|
||||||
return
|
|
||||||
end
|
end
|
||||||
-- input: string, player: LuaPlayer, reject: function, ... extra args
|
-- input: string, player: LuaPlayer, reject: function, ... extra args
|
||||||
local success,param_parsed = pcall(parse_callback,raw_params[index],player,parse_fail,unpack(param_data.parse_args))
|
local success,param_parsed = pcall(parse_callback,raw_params[index],player,parse_fail,unpack(param_data.parse_args))
|
||||||
@@ -629,7 +628,9 @@ function Commands.run_command(command_event)
|
|||||||
end
|
end
|
||||||
elseif param_parsed == nil or param_parsed == Commands.defines.error or param_parsed == parse_fail then
|
elseif param_parsed == nil or param_parsed == Commands.defines.error or param_parsed == parse_fail then
|
||||||
-- no value was returned or error was returned, if nil then give generic error
|
-- no value was returned or error was returned, if nil then give generic error
|
||||||
if not param_parsed == Commands.defines.error then Commands.error('Invalid Param "'..param_name..'"; please make sure it is the correct type') end
|
if not param_parsed == Commands.defines.error then
|
||||||
|
Commands.error{'expcore-commands.command-error-param-format',param_name,'please make sure it is the correct type'}
|
||||||
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
-- adds the param to the table to be passed to the command callback
|
-- adds the param to the table to be passed to the command callback
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ end)
|
|||||||
Commands.add_parse('player',function(input,player,reject)
|
Commands.add_parse('player',function(input,player,reject)
|
||||||
if not input then return end -- nil check
|
if not input then return end -- nil check
|
||||||
local input_player = Game.get_player_from_any(input)
|
local input_player = Game.get_player_from_any(input)
|
||||||
if not player then
|
if not input_player then
|
||||||
return reject{'expcore-commands.reject-player',input}
|
return reject{'expcore-commands.reject-player',input}
|
||||||
else
|
else
|
||||||
return input_player
|
return input_player
|
||||||
|
|||||||
@@ -10,5 +10,7 @@ reject-player-alive=Player is dead.
|
|||||||
reject-force=Invaild Force Name
|
reject-force=Invaild Force Name
|
||||||
reject-surface=Invaild surface Name
|
reject-surface=Invaild surface Name
|
||||||
invalid-inputs=Invalid Input, /__1__ __2__
|
invalid-inputs=Invalid Input, /__1__ __2__
|
||||||
|
invalid-param=Invalid Param "__1__"; __2__
|
||||||
command-ran=Command Complete
|
command-ran=Command Complete
|
||||||
command-fail=Command failed to run: __1__
|
command-fail=Command failed to run: __1__
|
||||||
|
command-error-log-format=[ERROR] command/__1__ :: __2__
|
||||||
@@ -10,5 +10,7 @@ reject-player-alive=Player is dead.
|
|||||||
reject-force=Invaild Force Name
|
reject-force=Invaild Force Name
|
||||||
reject-surface=Invaild surface Name
|
reject-surface=Invaild surface Name
|
||||||
invalid-inputs=Invalid Input, /__1__ __2__
|
invalid-inputs=Invalid Input, /__1__ __2__
|
||||||
|
invalid-param=Invalid Param "__1__"; __2__
|
||||||
command-ran=Command Complete
|
command-ran=Command Complete
|
||||||
command-fail=Command failed to run: __1__
|
command-fail=Command failed to run: __1__
|
||||||
|
command-error-log-format=[ERROR] command/__1__ :: __2__
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
local Commands = require 'expcore.commands'
|
local Commands = require 'expcore.commands'
|
||||||
require 'expcore.common_parse'
|
|
||||||
|
|
||||||
Commands.new_command('me','Sends an action message in the chat')
|
Commands.new_command('me','Sends an action message in the chat')
|
||||||
:add_param('action',false)
|
:add_param('action',false)
|
||||||
|
|||||||
27
modules/commands/tag.lua
Normal file
27
modules/commands/tag.lua
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
local Commands = require 'expcore.commands'
|
||||||
|
require 'expcore.common_parse'
|
||||||
|
|
||||||
|
Commands.new_command('tag','Sets your player tag.')
|
||||||
|
:add_param('tag',false,'string-max-length',20)
|
||||||
|
:enable_auto_concat()
|
||||||
|
:register(function(player,tag,raw)
|
||||||
|
player.tag = ' - '..tag
|
||||||
|
end)
|
||||||
|
|
||||||
|
Commands.new_command('tag-clear','Clears your tag. Or another player if you are admin.')
|
||||||
|
:add_param('player',true,'player')
|
||||||
|
:add_defaults{player=function(player)
|
||||||
|
return player
|
||||||
|
end}
|
||||||
|
:register(function(player,action_player,raw)
|
||||||
|
if action_player.index == player.index then
|
||||||
|
-- no player given so removes your tag
|
||||||
|
action_player.tag = ''
|
||||||
|
elseif player.admin then
|
||||||
|
-- player given and user is admin so clears that player's tag
|
||||||
|
action_player.tag = ''
|
||||||
|
else
|
||||||
|
-- user is not admin and tried to clear another users tag
|
||||||
|
return Commands.error{'expcore-commands.unauthorized'}
|
||||||
|
end
|
||||||
|
end)
|
||||||
Reference in New Issue
Block a user