Skip to content

Commit

Permalink
fix(nd): license check and loading correctness (#1559)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andyyy7666 authored Dec 17, 2023
1 parent 4201bae commit e9535a1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions modules/bridge/nd/client.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local NDCore = lib.load('@ND_Core.init')
if not lib.checkDependency('ND_Core', '2.0.0', true) then return end

if lib.checkDependency('ND_Core', '2.0.0', true) then return end
lib.load('@ND_Core.init')

RegisterNetEvent("ND:characterUnloaded", client.onLogout)

Expand Down
15 changes: 8 additions & 7 deletions modules/bridge/nd/server.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
local NDCore = lib.load('@ND_Core.init')
if not lib.checkDependency('ND_Core', '2.0.0', true) then return end

if lib.checkDependency('ND_Core', '2.0.0', true) then return end
local Inventory = require 'modules.inventory.server'
lib.load('@ND_Core.init')

AddEventHandler("ND:characterUnloaded", server.playerDropped)

local Inventory = require 'modules.inventory.server'

local function reorderGroups(groups)
groups = groups or {}
for group, info in pairs(groups) do
Expand Down Expand Up @@ -71,10 +70,12 @@ end

---@diagnostic disable-next-line: duplicate-set-field
function server.hasLicense(inv, license)
local character = NDCore.getPlayer(inv.id)
if not character or not character.data.licences then return end
local player = NDCore.getPlayer(inv.id)
if not player then return end

for _, characterLicense in pairs(character.data.licences) do
local licenses = player.getMetadata("licenses") or {}
for i=1, #licenses do
local characterLicense = licenses[i]
if characterLicense.type == license and characterLicense.status == "valid" then
return characterLicense.type
end
Expand Down

0 comments on commit e9535a1

Please sign in to comment.