mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-31 04:51:40 +09:00
Added player tags
This commit is contained in:
@@ -8,6 +8,20 @@ local Roles = require 'expcore.roles' --- @dep expcore.roles
|
|||||||
require 'config.expcore.command_general_parse'
|
require 'config.expcore.command_general_parse'
|
||||||
require 'config.expcore.command_role_parse'
|
require 'config.expcore.command_role_parse'
|
||||||
|
|
||||||
|
--- Stores the tag for a player
|
||||||
|
local PlayerData = require 'expcore.player_data' --- @dep expcore.player_data
|
||||||
|
local PlayerTags = PlayerData.Settings:combine('Tag')
|
||||||
|
|
||||||
|
--- When your tag is updated then apply the changes
|
||||||
|
PlayerTags:on_update(function(player_name, player_tag)
|
||||||
|
local player = game.players[player_name]
|
||||||
|
if player_tag == nil or player_tag == '' then
|
||||||
|
player_tag.tag = ''
|
||||||
|
else
|
||||||
|
player.tag = '- '..player_tag
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
--- Sets your player tag.
|
--- Sets your player tag.
|
||||||
-- @command tag
|
-- @command tag
|
||||||
-- @tparam string tag the tag that will be after the name, there is a max length
|
-- @tparam string tag the tag that will be after the name, there is a max length
|
||||||
@@ -15,7 +29,7 @@ Commands.new_command('tag', 'Sets your player tag.')
|
|||||||
:add_param('tag', false, 'string-max-length', 20)
|
:add_param('tag', false, 'string-max-length', 20)
|
||||||
:enable_auto_concat()
|
:enable_auto_concat()
|
||||||
:register(function(player, tag)
|
:register(function(player, tag)
|
||||||
player.tag = '- '..tag
|
PlayerTags:set(player, tag)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--- Clears your tag. Or another player if you are admin.
|
--- Clears your tag. Or another player if you are admin.
|
||||||
@@ -29,10 +43,10 @@ end}
|
|||||||
:register(function(player, action_player)
|
:register(function(player, action_player)
|
||||||
if action_player.index == player.index then
|
if action_player.index == player.index then
|
||||||
-- no player given so removes your tag
|
-- no player given so removes your tag
|
||||||
action_player.tag = ''
|
PlayerTags:remove(action_player)
|
||||||
elseif Roles.player_allowed(player, 'command/clear-tag/always') then
|
elseif Roles.player_allowed(player, 'command/clear-tag/always') then
|
||||||
-- player given and user is admin so clears that player's tag
|
-- player given and user is admin so clears that player's tag
|
||||||
action_player.tag = ''
|
PlayerTags:remove(action_player)
|
||||||
else
|
else
|
||||||
-- user is not admin and tried to clear another users tag
|
-- user is not admin and tried to clear another users tag
|
||||||
return Commands.error{'expcore-commands.unauthorized'}
|
return Commands.error{'expcore-commands.unauthorized'}
|
||||||
Reference in New Issue
Block a user