From 8da246bc6a033bbdaab8ec70d581bb77afd5b70a Mon Sep 17 00:00:00 2001 From: mindkind Date: Sat, 9 Dec 2023 16:48:01 -0500 Subject: [PATCH 1/2] Update server.lua Fix components and tint missing Fix components and tint missing --- bridge/inventory/server.lua | 63 +++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 35 deletions(-) diff --git a/bridge/inventory/server.lua b/bridge/inventory/server.lua index 5390aa3..d025c48 100644 --- a/bridge/inventory/server.lua +++ b/bridge/inventory/server.lua @@ -1,47 +1,30 @@ Inventory = {} --- Framework -function GetPlayerFromId(source) - if GetResourceState('es_extended') == 'started' then - return ESX.GetPlayerFromId(source) - elseif GetResourceState('qb-core') == 'started' then - return QBCore.Functions.GetPlayer(source) - end -end - -function getInventory(player) - if GetResourceState('es_extended') == 'started' then - return player.getInventory() - elseif GetResourceState('qb-core') == 'started' then - return player.PlayerData.items - end -end - -if GetResourceState('ox_inventory') == 'started' then +if GetResourceState('ox_inventory') == 'started' then Inventory.GetWeapon = function(source, name) local data = exports.ox_inventory:GetCurrentWeapon(source) - if data then + if data then return 1, data else return 0 end end - Inventory.AddWeapon = function(source, data) + Inventory.AddWeapon = function(source, data) exports.ox_inventory:AddItem(source, data.weapon, 1, data.metadata, data.slot) end - Inventory.RemoveWeapon = function(source, data) + Inventory.RemoveWeapon = function(source, data) exports.ox_inventory:RemoveItem(source, data.weapon, 1, data.metadata, data.slot) end Inventory.CreateWeaponData = function(source, data, weaponData) - for k, v in pairs(weaponData) do + for k,v in pairs(weaponData) do data[k] = v end return data end -elseif GetResourceState('qb-inventory') == 'started' then +elseif GetResourceState('qb-inventory') == 'started' then Inventory.PlayerWeapons = {} Inventory.GetWeapon = function(source, name) @@ -57,37 +40,41 @@ elseif GetResourceState('qb-inventory') == 'started' then return 0 end - Inventory.AddWeapon = function(source, data) + Inventory.AddWeapon = function(source, data) local Player = QBCore.Functions.GetPlayer(source) Player.Functions.AddItem(data.name, 1, data.slot, data.info) end - Inventory.RemoveWeapon = function(source, data) + Inventory.RemoveWeapon = function(source, data) local Player = QBCore.Functions.GetPlayer(source) Player.Functions.RemoveItem(data.name, 1, data.slot) end Inventory.CreateWeaponData = function(source, data, weaponData) - for k, v in pairs(weaponData) do + for k,v in pairs(weaponData) do data[k] = v end return data end - + RegisterNetEvent('pickle_weaponthrowing:SetCurrentWeapon', function(weaponData) local source = source Inventory.PlayerWeapons[source] = weaponData - end) + end) + elseif GetResourceState('qs-inventory') == 'started' then Inventory.PlayerWeapons = {} Inventory.GetWeapon = function(source, name) - local data = exports['qs-inventory']:GetCurrentWeapon(source) - if data then - return 1, data - else - return 0 + local data = Inventory.PlayerWeapons[source] + + if data then + local item = exports['qs-inventory']:GetItemBySlot(source, data.slot) + if item and item.name:lower() == name:lower() then + return 1, item + end end + return 0 end Inventory.AddWeapon = function(source, data) @@ -98,10 +85,16 @@ elseif GetResourceState('qs-inventory') == 'started' then exports['qs-inventory']:RemoveItem(source, data.name, 1, data.slot, nil) end - Inventory.CreateWeaponData = function(source, data, weaponData) + Inventory.CreateWeaponData = function(source, data, weaponData) for k, v in pairs(weaponData) do data[k] = v end return data - end + end + + RegisterNetEvent('pickle_weaponthrowing:SetCurrentWeapon', function(weaponData) + local source = source + Inventory.PlayerWeapons[source] = weaponData + end) + end From ae62c20d2cf331d95546d6021d011719a6cd2471 Mon Sep 17 00:00:00 2001 From: mindkind Date: Mon, 11 Dec 2023 08:04:36 -0500 Subject: [PATCH 2/2] Fix for quasar inventory When restarting resource it was not detecting the gun n the hand causing the gun to get throwed without beeing removed. Also added exports['qs-inventory']:useItemSlot(source, item) so that it unuse the slot when trwoing the weapon --- bridge/inventory/server.lua | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/bridge/inventory/server.lua b/bridge/inventory/server.lua index d025c48..6783ead 100644 --- a/bridge/inventory/server.lua +++ b/bridge/inventory/server.lua @@ -63,14 +63,13 @@ elseif GetResourceState('qb-inventory') == 'started' then end) elseif GetResourceState('qs-inventory') == 'started' then - Inventory.PlayerWeapons = {} Inventory.GetWeapon = function(source, name) - local data = Inventory.PlayerWeapons[source] - + local data = exports['qs-inventory']:GetCurrentWeapon(source) if data then local item = exports['qs-inventory']:GetItemBySlot(source, data.slot) if item and item.name:lower() == name:lower() then + exports['qs-inventory']:useItemSlot(source, item) return 1, item end end @@ -91,10 +90,5 @@ elseif GetResourceState('qs-inventory') == 'started' then end return data end - - RegisterNetEvent('pickle_weaponthrowing:SetCurrentWeapon', function(weaponData) - local source = source - Inventory.PlayerWeapons[source] = weaponData - end) - + end