mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-17 05:56:01 +01:00
fix(CharacterSelection/js): Removed duplicated code
This commit is contained in:
@@ -5,12 +5,12 @@ NDCore = exports["ND_Core"]:GetCoreObject()
|
||||
function validateDepartment(player, department)
|
||||
local departmentExists = config.departments[department]
|
||||
if departmentExists then
|
||||
local discordUserId = string.gsub(NDCore.Functions.GetPlayerIdentifierFromType("discord", player), "discord:", "")
|
||||
local roles = NDCore.Functions.GetUserDiscordInfo(discordUserId).roles
|
||||
local discordUserId = NDCore.Functions.GetPlayerIdentifierFromType("discord", player):gsub("discord:", "")
|
||||
local discordInfo = NDCore.Functions.GetUserDiscordInfo(discordUserId)
|
||||
|
||||
-- validate that the player actually has the role that they selected on the client.
|
||||
for _, roleId in pairs(departmentExists) do
|
||||
if roles[roleId] or roleId == 0 or roleId == "0" then
|
||||
if roleId == 0 or roleId == "0" or (discordInfo and discordInfo.roles[roleId]) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
@@ -53,6 +53,7 @@ AddEventHandler("ND_CharacterSelection:checkPerms", function()
|
||||
local discordUserId = NDCore.Functions.GetPlayerIdentifierFromType("discord", player):gsub("discord:", "")
|
||||
local allowedRoles = {}
|
||||
local discordInfo = NDCore.Functions.GetUserDiscordInfo(discordUserId)
|
||||
|
||||
-- Check if the players discord roles will grant them permission to the department.
|
||||
for dept, roleTable in pairs(config.departments) do
|
||||
for _, roleId in pairs(roleTable) do
|
||||
@@ -61,6 +62,5 @@ AddEventHandler("ND_CharacterSelection:checkPerms", function()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
TriggerClientEvent("ND_CharacterSelection:permsChecked", player, allowedRoles)
|
||||
end)
|
||||
end)
|
||||
Reference in New Issue
Block a user