mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 12:31:41 +09:00
Changed kill and tag to use role system
This commit is contained in:
@@ -67,7 +67,9 @@ Roles.new_role('Trainee','TrMod')
|
|||||||
'command/admin-chat',
|
'command/admin-chat',
|
||||||
'command/teleport',
|
'command/teleport',
|
||||||
'command/bring',
|
'command/bring',
|
||||||
'command/goto'
|
'command/goto',
|
||||||
|
'command/kill/always',
|
||||||
|
'command/tag-clear/always',
|
||||||
}
|
}
|
||||||
|
|
||||||
Roles.new_role('Sponsor','Spon')
|
Roles.new_role('Sponsor','Spon')
|
||||||
@@ -122,6 +124,7 @@ Roles.new_role('Regular','Reg')
|
|||||||
:set_permission_group('Standard')
|
:set_permission_group('Standard')
|
||||||
:set_parent('Guest')
|
:set_parent('Guest')
|
||||||
:allow{
|
:allow{
|
||||||
|
'command/kill'
|
||||||
}
|
}
|
||||||
:set_auto_promote_condition(playtime(3*hours))
|
:set_auto_promote_condition(playtime(3*hours))
|
||||||
|
|
||||||
|
|||||||
@@ -21,3 +21,4 @@ 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.
|
||||||
@@ -103,6 +103,18 @@ function Roles.get_player_roles(player)
|
|||||||
return rtn
|
return rtn
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Roles.get_player_highest_role(player)
|
||||||
|
local roles = Roles.get_player_roels(player)
|
||||||
|
if not roles then return end
|
||||||
|
local highest
|
||||||
|
for _,role in pairs(roles) do
|
||||||
|
if not highest or role.index < highest.index then
|
||||||
|
highest = role
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return highest
|
||||||
|
end
|
||||||
|
|
||||||
function Roles.assign_player(player,roles,by_player_name)
|
function Roles.assign_player(player,roles,by_player_name)
|
||||||
player = Game.get_player_from_any(player)
|
player = Game.get_player_from_any(player)
|
||||||
if not player then return end
|
if not player then return end
|
||||||
@@ -410,13 +422,7 @@ local function role_update(event)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- Updates the players permission group
|
-- Updates the players permission group
|
||||||
local highest
|
local highest = Roles.get_player_highest_role(player)
|
||||||
local roles = Roles.get_player_roles(player)
|
|
||||||
for _,role in pairs(roles) do
|
|
||||||
if not highest or role.index < highest.index then
|
|
||||||
highest = role
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if highest.permission_group then
|
if highest.permission_group then
|
||||||
if highest.permission_group[1] then
|
if highest.permission_group[1] then
|
||||||
local group = game.permissions.get_group(highest.permission_group[2])
|
local group = game.permissions.get_group(highest.permission_group[2])
|
||||||
|
|||||||
@@ -23,3 +23,4 @@ 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.
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
local Commands = require 'expcore.commands'
|
local Commands = require 'expcore.commands'
|
||||||
|
local Roles = require 'expcore.roles'
|
||||||
require 'config.command_parse_general'
|
require 'config.command_parse_general'
|
||||||
|
|
||||||
Commands.new_command('kill','Kills yourself or another player.')
|
Commands.new_command('kill','Kills yourself or another player.')
|
||||||
@@ -9,11 +10,22 @@ Commands.new_command('kill','Kills yourself or another player.')
|
|||||||
return player
|
return player
|
||||||
end
|
end
|
||||||
end}
|
end}
|
||||||
:set_flag('admin_only',true)
|
|
||||||
:register(function(player,action_player,raw)
|
:register(function(player,action_player,raw)
|
||||||
if not action_player then
|
if not action_player then
|
||||||
-- can only be nil if no player given and the user is dead
|
-- can only be nil if no player given and the user is dead
|
||||||
return Commands.error{'exp-commands.kill-already-dead'}
|
return Commands.error{'exp-commands.kill-already-dead'}
|
||||||
end
|
end
|
||||||
action_player.character.die()
|
if player == action_player then
|
||||||
|
action_player.character.die()
|
||||||
|
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()
|
||||||
|
else
|
||||||
|
return Commands.error{'expcore-roles.command-error-higher-role',action_player.name}
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return Commands.error{'expcore-commands.unauthorized'}
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
local Commands = require 'expcore.commands'
|
local Commands = require 'expcore.commands'
|
||||||
|
local Roles = require 'expcore.roles'
|
||||||
require 'config.command_parse_general'
|
require 'config.command_parse_general'
|
||||||
|
|
||||||
Commands.new_command('tag','Sets your player tag.')
|
Commands.new_command('tag','Sets your player tag.')
|
||||||
@@ -17,9 +18,15 @@ end}
|
|||||||
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 = ''
|
action_player.tag = ''
|
||||||
elseif player.admin 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 = ''
|
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 = ''
|
||||||
|
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