Added SERVER Role

This commit is contained in:
Cooldude2606
2018-11-23 17:01:22 +00:00
parent 60ccb9d970
commit 2042da5ca4
4 changed files with 13 additions and 10 deletions

View File

@@ -1,9 +1,4 @@
-- defines for groups
Group{
name='Root',
disallow={}
}
Group{
name='Admin',
disallow={

View File

@@ -26,6 +26,8 @@ local Group = {
if loaded_modules['ExpGamingCore.Server@^4.0.0'] then require('ExpGamingCore.Server@^4.0.0').add_module_to_interface('Group','ExpGamingCore.Group') end
end,
on_post = function(self)
-- creats a root role that the server can use
self{name='Root',disallow={}}
-- loads the groups in config
require(module_path..'/config',{Group=self})
end

View File

@@ -1,6 +1,10 @@
Role.add_flag('is_default') -- this must be included in atleast one role
Role.add_flag('is_root',function(player,state) if player.character then player.character.destructible = not state end end) -- not required but setting true will allow everythin for that role
Role.add_flag('is_antiroot',function(player,state) if player.character then player.character.destructible = not state end end) -- not required but setting true will disallow everythin for that role
Role.add_flag('is_root',function(player,state)
if state then game.print('--- !!!ALERT!!! --- '..player.name..' has been given a role with ROOT ACCESS --- !!!ALERT!!! ---') end
if player.character then player.character.destructible = not state end
end) -- the SERVER role will have root but you may assign this to other roles
-- the two above and used internaly and should NOT have their names changed and should NOT be removed but the state function MAY be changed
Role.add_flag('is_antiroot',function(player,state) if player.character then player.character.destructible = not state end end) -- not required but setting true will disallow everything for that role
Role.add_flag('is_admin',function(player,state) player.admin = state end) -- highly recomented but not required
Role.add_flag('is_spectator',function(player,state) player.spectator = state end)
Role.add_flag('is_jail',function(player,state) if player.character then player.character.active = not state end end)

View File

@@ -33,15 +33,17 @@ local Role = {
if loaded_modules['ExpGamingCore.Sync@^4.0.0'] then require(module_path..'/src/sync',{self=self,RoleGlobal=RoleGlobal}) end
end,
on_post=function(self)
-- creates a server role with root access
self.meta.server = self{name='SERVER',group='Root',is_root=true,allow={}}
-- loads the roles in config
require(module_path..'/config',{Role=self})
self.order[0] = 'SERVER'
-- joins role allows into a chain
local previous
for index,role_name in pairs(self.order) do
local role = self.get(role_name)
if not role then error('Invalid role name in order listing: '..role_name) return end
if role.is_default then self.meta.default = role end
if role.is_root then self.meta.root = role end
if role.is_timed then self.meta.times[role.name] = {index,role.time*3600} end
if not self.meta.groups[role.group.name] then self.meta.groups[role.group.name] = {lowest=index,highest=index} end
if self.meta.groups[role.group.name].highest > index then self.meta.groups[role.group.name].highest = index end
@@ -82,7 +84,7 @@ function Role.define(obj)
if not type_error(obj.name,'string','Role creation is invalid: role.name is not a string') then return end
if not is_type(obj.short_hand,'string') then obj.short_hand = obj.name:sub(1,3) end
if not is_type(obj.tag,'string') then obj.tag = '['..obj.short_hand..']' end
if not type_error(obj.colour,'table','Role creation is invalid: role.colour is not a table') then return end
if not is_type(obj.colour,'table') then obj.colour = {r=255,b=255,g=255} end
if not type_error(obj.allow,'table','Role creation is invalid: role.allow is not a table') then return end
obj.group = Group.get(obj.group)
if not type_error(obj.group,'table','Role creation is invalid: role.group is invalid') then return end
@@ -103,7 +105,7 @@ end
-- @treturn table the group which was found or nil
function Role.get(mixed)
local player = game and Game.get_player(mixed)
if player == SERVER then return {Role.meta.root} end
if player == SERVER then return {Role.meta.server} end
if player then
local rtn = {}
if not global.players[player.index] then return Role.meta.default and {Role.meta.default} or {} end