mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-31 04:51:40 +09:00
Added command parse for roles
This commit is contained in:
38
config/command_parase_roles.lua
Normal file
38
config/command_parase_roles.lua
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
--- Adds some parse functions that can be used with the role system
|
||||||
|
local Commands = require 'expcore.commands'
|
||||||
|
local Roles = require 'expcore.roles'
|
||||||
|
require 'config.command_parse_general'
|
||||||
|
|
||||||
|
Commands.add_parse('role',function(input,player,reject)
|
||||||
|
if not role then return end
|
||||||
|
local role = Roles.get_role_from_any(input)
|
||||||
|
if not role then
|
||||||
|
return reject{'expcore-role.reject-role'}
|
||||||
|
else
|
||||||
|
return role
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
Commands.add_parse('player-role',function(input,player,reject)
|
||||||
|
local input_player = Commands.parse('player',input,player,reject)
|
||||||
|
if not input_player then return end -- nil check
|
||||||
|
local player_highest = Roles.get_player_highest_role(player)
|
||||||
|
local action_player_highest = Roles.get_player_highest_role(input_player)
|
||||||
|
if player_highest.index < action_player_highest.index then
|
||||||
|
return input_player
|
||||||
|
else
|
||||||
|
return reject{'expcore-roles.reject-player-role'}
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
Commands.add_parse('player-role-online',function(input,player,reject)
|
||||||
|
local input_player = Commands.parse('player-rank',input,player,reject)
|
||||||
|
if not input_player then return end -- nil check
|
||||||
|
return Commands.parse('player-online',input_player,player,reject)
|
||||||
|
end)
|
||||||
|
|
||||||
|
Commands.add_parse('player-role-alive',function(input,player,reject)
|
||||||
|
local input_player = Commands.parse('player-rank',input,player,reject)
|
||||||
|
if not input_player then return end -- nil check
|
||||||
|
return Commands.parse('player-alive',input_player,player,reject)
|
||||||
|
end)
|
||||||
@@ -1,14 +1,16 @@
|
|||||||
|
time-symbol-days-short=__1__d
|
||||||
|
|
||||||
[expcore-commands]
|
[expcore-commands]
|
||||||
unauthorized=Unauthorized, Access is denied due to invalid credentials
|
unauthorized=Unauthorized, Access is denied due to invalid credentials
|
||||||
reject-string-options=Invalid Option, Must be one of: __1__
|
reject-string-options=Invalid Option, Must be one of: __1__
|
||||||
reject-string-max-length=Invalid Length, Max: __1__
|
reject-string-max-length=Invalid Length, Max: __1__
|
||||||
reject-number=Invalid Number
|
reject-number=Invalid Number.
|
||||||
reject-number-range=Invalid Range, Min (inclusive): __1__, Max (inclusive): __2__
|
reject-number-range=Invalid Range, Min (inclusive): __1__, Max (inclusive): __2__
|
||||||
reject-player=Invaild Player Name, __1__ ,try using tab key to auto-complete the name
|
reject-player=Invaild Player Name, __1__ ,try using tab key to auto-complete the name
|
||||||
reject-player-online=Player is offline.
|
reject-player-online=Player is offline.
|
||||||
reject-player-alive=Player is dead.
|
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__
|
invalid-param=Invalid Param "__1__"; __2__
|
||||||
command-help=__1__ - __2__
|
command-help=__1__ - __2__
|
||||||
@@ -21,4 +23,5 @@ error-log-format-flag=[ERROR] roleFlag/__1__ :: __2__
|
|||||||
error-log-format-promote=[ERROR] rolePromote/__1__ :: __2__
|
error-log-format-promote=[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__
|
||||||
command-error-higher-role=Unauthorized, __1__ has a higher role than you.
|
reject-role=Invalid Role Name.
|
||||||
|
reject-player-role=Player has a higher role.
|
||||||
@@ -4,13 +4,13 @@ time-symbol-days-short=__1__d
|
|||||||
unauthorized=Unauthorized, Access is denied due to invalid credentials
|
unauthorized=Unauthorized, Access is denied due to invalid credentials
|
||||||
reject-string-options=Invalid Option, Must be one of: __1__
|
reject-string-options=Invalid Option, Must be one of: __1__
|
||||||
reject-string-max-length=Invalid Length, Max: __1__
|
reject-string-max-length=Invalid Length, Max: __1__
|
||||||
reject-number=Invalid Number
|
reject-number=Invalid Number.
|
||||||
reject-number-range=Invalid Range, Min (inclusive): __1__, Max (inclusive): __2__
|
reject-number-range=Invalid Range, Min (inclusive): __1__, Max (inclusive): __2__
|
||||||
reject-player=Invaild Player Name, __1__ ,try using tab key to auto-complete the name
|
reject-player=Invaild Player Name, __1__ ,try using tab key to auto-complete the name
|
||||||
reject-player-online=Player is offline.
|
reject-player-online=Player is offline.
|
||||||
reject-player-alive=Player is dead.
|
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__
|
invalid-param=Invalid Param "__1__"; __2__
|
||||||
command-help=__1__ - __2__
|
command-help=__1__ - __2__
|
||||||
@@ -23,4 +23,5 @@ error-log-format-flag=[ERROR] roleFlag/__1__ :: __2__
|
|||||||
error-log-format-promote=[ERROR] rolePromote/__1__ :: __2__
|
error-log-format-promote=[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__
|
||||||
command-error-higher-role=Unauthorized, __1__ has a higher role than you.
|
reject-role=Invalid Role Name.
|
||||||
|
reject-player-role=Player has a higher role.
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
local Commands = require 'expcore.commands'
|
local Commands = require 'expcore.commands'
|
||||||
local Roles = require 'expcore.roles'
|
local Roles = require 'expcore.roles'
|
||||||
require 'config.command_parse_general'
|
require 'config.command_parse_general'
|
||||||
|
require 'config.command_parse_role'
|
||||||
|
|
||||||
Commands.new_command('kill','Kills yourself or another player.')
|
Commands.new_command('kill','Kills yourself or another player.')
|
||||||
:add_param('player',true,'player-alive') -- the player to kill, must be alive to be valid
|
:add_param('player',true,'player-role-alive') -- the player to kill, must be alive to be valid
|
||||||
:set_defaults{player=function(player)
|
:set_defaults{player=function(player)
|
||||||
-- default is the player unless they are dead
|
-- default is the player unless they are dead
|
||||||
if player.character and player.character.health > 0 then
|
if player.character and player.character.health > 0 then
|
||||||
@@ -18,13 +19,7 @@ end}
|
|||||||
if player == action_player then
|
if player == action_player then
|
||||||
action_player.character.die()
|
action_player.character.die()
|
||||||
elseif Roles.player_allowed(player,'command/kill/always') then
|
elseif Roles.player_allowed(player,'command/kill/always') then
|
||||||
local player_highest = Roles.get_player_highest_role(player)
|
|
||||||
local action_player_highest = Roles.get_player_highest_role(action_player)
|
|
||||||
if player_highest.index < action_player_highest.index then
|
|
||||||
action_player.character.die()
|
action_player.character.die()
|
||||||
else
|
|
||||||
return Commands.error{'expcore-roles.command-error-higher-role',action_player.name}
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
return Commands.error{'expcore-commands.unauthorized'}
|
return Commands.error{'expcore-commands.unauthorized'}
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
local Commands = require 'expcore.commands'
|
local Commands = require 'expcore.commands'
|
||||||
local Roles = require 'expcore.roles'
|
local Roles = require 'expcore.roles'
|
||||||
require 'config.command_parse_general'
|
require 'config.command_parse_general'
|
||||||
|
require 'config.command_parse_role'
|
||||||
|
|
||||||
Commands.new_command('tag','Sets your player tag.')
|
Commands.new_command('tag','Sets your player tag.')
|
||||||
:add_param('tag',false,'string-max-length',20) -- new tag for your player max 20 char
|
:add_param('tag',false,'string-max-length',20) -- new tag for your player max 20 char
|
||||||
@@ -10,7 +11,7 @@ Commands.new_command('tag','Sets your player tag.')
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
Commands.new_command('tag-clear','Clears your tag. Or another player if you are admin.')
|
Commands.new_command('tag-clear','Clears your tag. Or another player if you are admin.')
|
||||||
:add_param('player',true,'player') -- player to remove the tag of, nil to apply to self
|
:add_param('player',true,'player-role') -- player to remove the tag of, nil to apply to self
|
||||||
:set_defaults{player=function(player)
|
:set_defaults{player=function(player)
|
||||||
return player -- default is the user using the command
|
return player -- default is the user using the command
|
||||||
end}
|
end}
|
||||||
@@ -20,13 +21,7 @@ end}
|
|||||||
action_player.tag = ''
|
action_player.tag = ''
|
||||||
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
|
||||||
local player_highest = Roles.get_player_highest_role(player)
|
|
||||||
local action_player_highest = Roles.get_player_highest_role(action_player)
|
|
||||||
if player_highest.index < action_player_highest.index then
|
|
||||||
action_player.tag = ''
|
action_player.tag = ''
|
||||||
else
|
|
||||||
return Commands.error{'expcore-roles.command-error-higher-role',action_player.name}
|
|
||||||
end
|
|
||||||
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