mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-17 05:56:01 +01:00
update: license functions
This commit is contained in:
@@ -158,17 +158,7 @@ end
|
|||||||
function NDCore.Functions.EditPlayerLicense(characterId, identifier, newData)
|
function NDCore.Functions.EditPlayerLicense(characterId, identifier, newData)
|
||||||
local player = NDCore.fetchCharacter(characterId)
|
local player = NDCore.fetchCharacter(characterId)
|
||||||
if not player then return end
|
if not player then return end
|
||||||
|
player.updateLicense(identifier, newData)
|
||||||
local licenses = player.metadata.licenses
|
|
||||||
if licenses then
|
|
||||||
local license, key = NDCore.Functions.FindLicenseByIdentifier(licenses, identifier)
|
|
||||||
for k, v in pairs(newData) do
|
|
||||||
license[k] = v
|
|
||||||
end
|
|
||||||
licenses[key] = license
|
|
||||||
player.setMetadata("licenses", licenses)
|
|
||||||
end
|
|
||||||
return licenses or {}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set the players job and job rank.
|
-- Set the players job and job rank.
|
||||||
|
|||||||
@@ -173,6 +173,25 @@ local function createCharacterTable(info)
|
|||||||
self.triggerEvent("ND:updateCharacter", self)
|
self.triggerEvent("ND:updateCharacter", self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function self.getLicense(identifier)
|
||||||
|
local licenses = self.metadata.licenses or {}
|
||||||
|
for i=1, #licenses do
|
||||||
|
local data = licenses[i]
|
||||||
|
if data.identifier == identifier then
|
||||||
|
return data, i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function self.updateLicense(identifier, newData)
|
||||||
|
local data, i = self.getLicense(identifier)
|
||||||
|
if not data then return end
|
||||||
|
for k, v in pairs(newData) do
|
||||||
|
data[k] = v
|
||||||
|
end
|
||||||
|
self.save()
|
||||||
|
end
|
||||||
|
|
||||||
---@param coords vector3|vector4
|
---@param coords vector3|vector4
|
||||||
---@return boolean
|
---@return boolean
|
||||||
function self.setCoords(coords)
|
function self.setCoords(coords)
|
||||||
|
|||||||
Reference in New Issue
Block a user