Added /tag and /tag-clear

This commit is contained in:
Cooldude2606
2019-03-04 19:01:34 +00:00
parent d6aa2e0225
commit 08038272b6
7 changed files with 41 additions and 9 deletions

View File

@@ -1,5 +1,4 @@
local Commands = require 'expcore.commands'
require 'expcore.common_parse'
Commands.new_command('me','Sends an action message in the chat')
:add_param('action',false)

27
modules/commands/tag.lua Normal file
View 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)