diff --git a/exp_commands/module/commands/types.lua b/exp_commands/module/commands/types.lua index 451ef0a0..46b3ad91 100644 --- a/exp_commands/module/commands/types.lua +++ b/exp_commands/module/commands/types.lua @@ -25,6 +25,8 @@ local Commands = require("modules/exp_commands") local add, parse = Commands.add_data_type, Commands.parse_input local valid, invalid = Commands.status.success, Commands.status.invalid_input +local Roles = require("modules.exp_legacy.expcore.roles") --- @dep expcore.roles + local types = {} --- @class Commands._types --- A boolean value where true is one of: yes, y, true, 1 @@ -229,4 +231,29 @@ types.color = end end) +--- A player who has joined the game at least once, with a lower role +types.lower_role_player = +add("player", function(input, player) + local player_i = game.get_player(input) + local player = game.get_player(player) + + if Roles.get_player_highest_role(player_i).index <= Roles.get_player_highest_role(player).index then + return invalid{ "exp-commands-parse.player", input } + else + return valid(player) + end +end) + +--- A role that is lower than given user +types.lower_role = + add("role", function(input) + local player = game.get_player(input) + + if Roles.config.roles[input] and (Roles.config.roles[input].index >= Roles.get_player_highest_role(player).index) then + return valid(player) + else + return invalid{ "exp-commands-parse.role", input } + end + end) + return types diff --git a/exp_commands/module/locale/en.cfg b/exp_commands/module/locale/en.cfg index 5691ca4c..bc241876 100644 --- a/exp_commands/module/locale/en.cfg +++ b/exp_commands/module/locale/en.cfg @@ -27,6 +27,7 @@ force=Invalid Force Name. surface=Invalid Surface Name. planet=Invalid Planet Name. color=Invalid Color Name. +role=Invalid Role Name. [exp-commands-authorities] character-only=This command can not be used in remote view. diff --git a/exp_commands/module/locale/zh-CN.cfg b/exp_commands/module/locale/zh-CN.cfg index 8eb8c6ea..59c4d760 100644 --- a/exp_commands/module/locale/zh-CN.cfg +++ b/exp_commands/module/locale/zh-CN.cfg @@ -27,6 +27,7 @@ force=勢力名稱錯誤。 surface=地表名稱錯誤。 planet=星球名稱錯誤。 color=顏色名稱錯誤。 +role=權限組名稱錯誤。 [exp-commands-authorities] character-only=該命令不能在遠端視圖中使用。 diff --git a/exp_commands/module/locale/zh-TW.cfg b/exp_commands/module/locale/zh-TW.cfg index 8eb8c6ea..59c4d760 100644 --- a/exp_commands/module/locale/zh-TW.cfg +++ b/exp_commands/module/locale/zh-TW.cfg @@ -27,6 +27,7 @@ force=勢力名稱錯誤。 surface=地表名稱錯誤。 planet=星球名稱錯誤。 color=顏色名稱錯誤。 +role=權限組名稱錯誤。 [exp-commands-authorities] character-only=該命令不能在遠端視圖中使用。