From f1ae24d0fe4b3ddc1cf40c1698f41c5c09453a6c Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Fri, 16 Feb 2024 22:42:13 +0000 Subject: [PATCH] separate create dui event --- crafting.lua | 2 +- functions.lua | 31 ++++++++++++++++++------------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/crafting.lua b/crafting.lua index e111938..06c9ceb 100644 --- a/crafting.lua +++ b/crafting.lua @@ -478,7 +478,7 @@ function stashRemoveItem(stashItems, stashName, items) local amount = amount and elseif GetResourceState(OrigenInv):find("start") then for k, v in pairs(items) do - exports[OrigenInv]:RemoveFromStash(stashName, nil, k, v) + exports[OrigenInv]:RemoveFromStash(stashName, k, v) if Config.System.Debug then print("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..OrigenInv, k, v) end end diff --git a/functions.lua b/functions.lua index fc3cbd6..3948b04 100644 --- a/functions.lua +++ b/functions.lua @@ -40,12 +40,13 @@ function loadPtfxDict(ptFxName) end end function unloadPtfxDict(dict) if Config.System.Debug then print("^6Bridge^7: ^2Removing Ptfx Dictionary^7: '^6"..dict.."^7'") end RemoveNamedPtfxAsset(dict) end + function loadTextureDict(dict) if not HasStreamedTextureDictLoaded(dict) then if Config.System.Debug then print("^6Bridge^7: ^2Loading Texture Dictionary^7: '^6"..dict.."^7'") end - while not HasStreamedTextureDictLoaded(dict) do RequestNamedPtfxAsset(dict) Wait(5) end + while not HasStreamedTextureDictLoaded(dict) do RequestStreamedTextureDict(dict) Wait(5) end end end @@ -230,6 +231,7 @@ function ensureNetToVeh(vehNetID) end local previewTxd = not IsDuplicityVersion() and CreateRuntimeTxd(GetCurrentResourceName()..'previewTxd') or nil +local customDUIList = {} function makeBlip(data) local blip = AddBlipForCoord(vec3(data.coords.x, data.coords.y, data.coords.z)) SetBlipAsShortRange(blip, true) @@ -243,12 +245,9 @@ function makeBlip(data) EndTextCommandSetBlipName(blip) if GetResourceState("blip_info"):find("start") or GetResourceState("blip-info"):find("start") or GetResourceState("blipinfo"):find("start") then if data.preview then - local txname = tostring('preview'..keyGen()..keyGen()) + local txname = tostring(data.name..'preview'..string.gsub(data.coords.z, "%.", "")) if data.preview:find("http") then - local newTxt = CreateDui(data.preview, 512, 256) - local duihandle = GetDuiHandle(newTxt) - while not GetDuiHandle(newTxt) do Wait(0) end - CreateRuntimeTextureFromDuiHandle(previewTxd, txname, duihandle) + createNewDui(txname, data.preview, { 512, 256 }) else CreateRuntimeTextureFromImage(previewTxd, txname, data.preview) end @@ -260,6 +259,16 @@ function makeBlip(data) return blip end +function createNewDui(name, http, size) + if not customDUIList[name] then + local newTxt = CreateDui(http, size[1], size[2]) + local duihandle = GetDuiHandle(newTxt) + while not GetDuiHandle(newTxt) do Wait(0) end + CreateRuntimeTextureFromDuiHandle(previewTxd, name, duihandle) + customDUIList[name] = true + else return end +end + function makeEntityBlip(data) AddBlipForEntity(data.entity) local blip = GetBlipFromEntity(data.entity) @@ -274,12 +283,9 @@ function makeEntityBlip(data) EndTextCommandSetBlipName(blip) if GetResourceState("blip_info"):find("start") or GetResourceState("blip-info"):find("start") or GetResourceState("blipinfo"):find("start") then if data.preview then - local txname = tostring('preview'..keyGen()..keyGen()) + local txname = data.name..'preview' if data.preview:find("http") then - local newTxt = CreateDui(data.preview, 512, 256) - local duihandle = GetDuiHandle(newTxt) - while not GetDuiHandle(newTxt) do Wait(0) end - CreateRuntimeTextureFromDuiHandle(previewTxd, txname, duihandle) + createNewDui(txname, data.preview, { 512, 256 }) else CreateRuntimeTextureFromImage(previewTxd, txname, data.preview) end @@ -747,7 +753,7 @@ function dupeWarn(src, item, amount) end function getDurability(item) - local lowestSlot = 100 + local lowestSlot = 100 -- anything above your players max slots local durability = nil if GetResourceState(QBInv):find("start") then local itemcheck = Core.Functions.GetPlayerData().items @@ -775,7 +781,6 @@ end RegisterNetEvent(GetCurrentResourceName()..":server:setMetaData", function(data) local src = source if GetResourceState(QBInv):find("start") then - print(src, data.item, 1, data.slot) local Player = Core.Functions.GetPlayer(src) Player.PlayerData.items[data.slot].info = data.metadata