mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-16 21:46:03 +01:00
fix(server/player): updating admin & group roles on character activate
This commit is contained in:
@@ -341,16 +341,35 @@ local function createCharacterTable(info)
|
||||
|
||||
local roles = self.discord.roles
|
||||
if roles then
|
||||
local hasAdmin = false
|
||||
for i=1, #Config.adminDiscordRoles do
|
||||
local role = Config.adminDiscordRoles[i]
|
||||
if lib.table.contains(roles, role) then
|
||||
self.addGroup("admin")
|
||||
hasAdmin = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
for group, role in pairs(Config.groupRoles) do
|
||||
if lib.table.contains(roles, role) then
|
||||
if hasAdmin then
|
||||
self.addGroup("admin")
|
||||
elseif self.groups["admin"] then
|
||||
self.removeGroup("admin")
|
||||
end
|
||||
|
||||
local function hasRole(groupRoles)
|
||||
for i=1, #groupRoles do
|
||||
local role = groupRoles[i]
|
||||
if lib.table.contains(roles, role) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for group, groupRoles in pairs(Config.groupRoles) do
|
||||
if hasRole(groupRoles) then
|
||||
self.addGroup(group)
|
||||
elseif self.groups[group] then
|
||||
self.removeGroup(group)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user