mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 11:35:22 +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/teleport',
|
||||
'command/bring',
|
||||
'command/goto'
|
||||
'command/goto',
|
||||
'command/kill/always',
|
||||
'command/tag-clear/always',
|
||||
}
|
||||
|
||||
Roles.new_role('Sponsor','Spon')
|
||||
@@ -122,6 +124,7 @@ Roles.new_role('Regular','Reg')
|
||||
:set_permission_group('Standard')
|
||||
:set_parent('Guest')
|
||||
:allow{
|
||||
'command/kill'
|
||||
}
|
||||
:set_auto_promote_condition(playtime(3*hours))
|
||||
|
||||
|
||||
@@ -20,4 +20,5 @@ command-error-log-format=[ERROR] command/__1__ :: __2__
|
||||
error-log-format-flag=[ERROR] roleFlag/__1__ :: __2__
|
||||
error-log-format-promote=[ERROR] rolePromote/__1__ :: __2__
|
||||
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
|
||||
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)
|
||||
player = Game.get_player_from_any(player)
|
||||
if not player then return end
|
||||
@@ -410,13 +422,7 @@ local function role_update(event)
|
||||
end
|
||||
end
|
||||
-- Updates the players permission group
|
||||
local highest
|
||||
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
|
||||
local highest = Roles.get_player_highest_role(player)
|
||||
if highest.permission_group then
|
||||
if highest.permission_group[1] then
|
||||
local group = game.permissions.get_group(highest.permission_group[2])
|
||||
|
||||
@@ -22,4 +22,5 @@ command-error-log-format=[ERROR] command/__1__ :: __2__
|
||||
error-log-format-flag=[ERROR] roleFlag/__1__ :: __2__
|
||||
error-log-format-promote=[ERROR] rolePromote/__1__ :: __2__
|
||||
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 Roles = require 'expcore.roles'
|
||||
require 'config.command_parse_general'
|
||||
|
||||
Commands.new_command('kill','Kills yourself or another player.')
|
||||
@@ -9,11 +10,22 @@ Commands.new_command('kill','Kills yourself or another player.')
|
||||
return player
|
||||
end
|
||||
end}
|
||||
:set_flag('admin_only',true)
|
||||
:register(function(player,action_player,raw)
|
||||
if not action_player then
|
||||
-- can only be nil if no player given and the user is dead
|
||||
return Commands.error{'exp-commands.kill-already-dead'}
|
||||
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)
|
||||
@@ -1,4 +1,5 @@
|
||||
local Commands = require 'expcore.commands'
|
||||
local Roles = require 'expcore.roles'
|
||||
require 'config.command_parse_general'
|
||||
|
||||
Commands.new_command('tag','Sets your player tag.')
|
||||
@@ -17,9 +18,15 @@ end}
|
||||
if action_player.index == player.index then
|
||||
-- no player given so removes your 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
|
||||
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
|
||||
-- user is not admin and tried to clear another users tag
|
||||
return Commands.error{'expcore-commands.unauthorized'}
|
||||
|
||||
Reference in New Issue
Block a user