Skip to content

Commit

Permalink
feat(framework): nd_core integration (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andyyy7666 authored Jan 28, 2024
1 parent bf2c752 commit 95f305e
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
48 changes: 48 additions & 0 deletions client/framework/nd.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
local NDCore = exports["ND_Core"]

local playerGroups = NDCore:getPlayer()?.groups or {}

AddEventHandler("ND:characterLoaded", function(data)
playerGroups = data.groups
end)

RegisterNetEvent("ND:updateCharacter", function(data)
if source == '' then return end
playerGroups = data.groups or {}
end)

local utils = require 'client.utils'

---@diagnostic disable-next-line: duplicate-set-field
function utils.hasPlayerGotGroup(filter)
local _type = type(filter)

if _type == 'string' then
local group = playerGroups[filter]

if group then
return true
end
elseif _type == 'table' then
local tabletype = table.type(filter)

if tabletype == 'hash' then
for name, grade in pairs(filter) do
local playerGrade = playerGroups[name]?.rank

if playerGrade and grade <= playerGrade then
return true
end
end
elseif tabletype == 'array' then
for i = 1, #filter do
local name = filter[i]
local group = playerGroups[name]

if group then
return true
end
end
end
end
end
1 change: 1 addition & 0 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ files {
'client/state.lua',
'client/debug.lua',
'client/defaults.lua',
'client/framework/nd.lua',
'client/framework/ox.lua',
'client/framework/esx.lua',
'client/framework/qb.lua',
Expand Down

0 comments on commit 95f305e

Please sign in to comment.