Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 23 additions & 36 deletions bridge/inventory/server.lua
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -57,37 +40,40 @@ 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 = 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
return 0
end

Inventory.AddWeapon = function(source, data)
Expand All @@ -98,10 +84,11 @@ 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

end