mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-31 04:51:40 +09:00
feat(roles): deferred role assignment message
This commit is contained in:
@@ -148,7 +148,7 @@ end)
|
|||||||
--- Internal function used to trigger a few different things when roles are changed
|
--- Internal function used to trigger a few different things when roles are changed
|
||||||
-- this is the raw internal trigger as the other function is called at other times
|
-- this is the raw internal trigger as the other function is called at other times
|
||||||
-- there is a second half called role_update which triggers after the event call, it also is called when a player joins
|
-- there is a second half called role_update which triggers after the event call, it also is called when a player joins
|
||||||
local function emit_player_roles_updated(player, type, roles, by_player_name, skip_game_print)
|
local function emit_player_roles_updated(player, type, roles, by_player_name, skip_game_print, deferred)
|
||||||
by_player_name = game.player and game.player.name or by_player_name or '<server>'
|
by_player_name = game.player and game.player.name or by_player_name or '<server>'
|
||||||
local by_player = game.players[by_player_name]
|
local by_player = game.players[by_player_name]
|
||||||
local by_player_index = by_player and by_player.index or 0
|
local by_player_index = by_player and by_player.index or 0
|
||||||
@@ -168,8 +168,12 @@ local function emit_player_roles_updated(player, type, roles, by_player_name, sk
|
|||||||
end
|
end
|
||||||
-- output to all the different locations: game print, player sound, event trigger and role log
|
-- output to all the different locations: game print, player sound, event trigger and role log
|
||||||
if not skip_game_print then
|
if not skip_game_print then
|
||||||
|
if deferred then
|
||||||
|
game.print({'expcore-roles.game-message-deferred-'..type, player.name, table.concat(role_names, ', '), by_player_name}, Colours.cyan)
|
||||||
|
else
|
||||||
game.print({'expcore-roles.game-message-'..type, player.name, table.concat(role_names, ', '), by_player_name}, Colours.cyan)
|
game.print({'expcore-roles.game-message-'..type, player.name, table.concat(role_names, ', '), by_player_name}, Colours.cyan)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
if type == 'assign' then
|
if type == 'assign' then
|
||||||
player.play_sound{path='utility/achievement_unlocked'}
|
player.play_sound{path='utility/achievement_unlocked'}
|
||||||
else
|
else
|
||||||
@@ -378,10 +382,17 @@ function Roles.assign_player(player, roles, by_player_name, skip_checks, silent)
|
|||||||
-- if the player has a role that needs to defer the role changes, save the roles that need to be assigned later into a table
|
-- if the player has a role that needs to defer the role changes, save the roles that need to be assigned later into a table
|
||||||
if valid_player and Roles.player_has_flag(player, "defer_role_changes") then
|
if valid_player and Roles.player_has_flag(player, "defer_role_changes") then
|
||||||
local assign_later = Roles.config.deferred_roles[valid_player.name] or {}
|
local assign_later = Roles.config.deferred_roles[valid_player.name] or {}
|
||||||
|
local were_changes = false
|
||||||
for _, role in ipairs(roles) do
|
for _, role in ipairs(roles) do
|
||||||
|
if not assign_later[role] then
|
||||||
assign_later[role] = 1
|
assign_later[role] = 1
|
||||||
|
were_changes = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
Roles.config.deferred_roles[valid_player.name] = assign_later
|
Roles.config.deferred_roles[valid_player.name] = assign_later
|
||||||
|
if were_changes then
|
||||||
|
emit_player_roles_updated(valid_player, 'assign', roles, by_player_name, silent, true)
|
||||||
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ error-log-format-flag=[ERROR] roleFlag/__1__ :: __2__
|
|||||||
error-log-format-assign=[ERROR] rolePromote/__1__ :: __2__
|
error-log-format-assign=[ERROR] rolePromote/__1__ :: __2__
|
||||||
game-message-assign=__1__ has been assigned to __2__ by __3__
|
game-message-assign=__1__ has been assigned to __2__ by __3__
|
||||||
game-message-unassign=__1__ has been unassigned from __2__ by __3__
|
game-message-unassign=__1__ has been unassigned from __2__ by __3__
|
||||||
|
game-message-deferred-assign=__1__ will been assigned to __2__ by __3__
|
||||||
reject-role=Invalid Role Name.
|
reject-role=Invalid Role Name.
|
||||||
reject-player-role=Player has a higher role.
|
reject-player-role=Player has a higher role.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user