Merge pull request #19 from The-Order-Of-The-Sacred-Framework/dev
feat(GetItemBySlot, GetOwnedVehicles, OnPlayerUnload, playerDropped, RequestAnimDict )
This commit is contained in:
21 files changed
+327
-40
No files matched your search
@@ -4,6 +4,10 @@ ESX = exports["es_extended"]:getSharedObject()
|
|||||||
|
|
||||||
Framework = {}
|
Framework = {}
|
||||||
|
|
||||||
|
Framework.GetFrameworkName = function()
|
||||||
|
return 'es_extended'
|
||||||
|
end
|
||||||
|
|
||||||
Framework.GetPlayerData = function()
|
Framework.GetPlayerData = function()
|
||||||
return ESX.PlayerData
|
return ESX.PlayerData
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,6 +4,10 @@ ESX = exports["es_extended"]:getSharedObject()
|
|||||||
|
|
||||||
Framework = {}
|
Framework = {}
|
||||||
|
|
||||||
|
Framework.GetFrameworkName = function()
|
||||||
|
return 'es_extended'
|
||||||
|
end
|
||||||
|
|
||||||
-- Framework.GetPlayerIdentifier(src)
|
-- Framework.GetPlayerIdentifier(src)
|
||||||
-- Returns the citizen ID of the player.
|
-- Returns the citizen ID of the player.
|
||||||
Framework.GetPlayerIdentifier = function(src)
|
Framework.GetPlayerIdentifier = function(src)
|
||||||
@@ -196,6 +200,19 @@ Framework.RemoveItem = function(src, item, amount, slot, metadata)
|
|||||||
return xPlayer.removeInventoryItem(item, amount)
|
return xPlayer.removeInventoryItem(item, amount)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Framework.GetOwnedVehicles = function(src)
|
||||||
|
local citizenId = Framework.GetPlayerIdentifier(src)
|
||||||
|
local result = MySQL.Sync.fetchAll("SELECT vehicle, plate FROM owned_vehicles WHERE owner = '" .. citizenId .. "'")
|
||||||
|
local vehicles = {}
|
||||||
|
for i=1, #result do
|
||||||
|
local vehicle = result[i].vehicle
|
||||||
|
local plate = result[i].plate
|
||||||
|
local model = json.decode(vehicle).model
|
||||||
|
table.insert(vehicles, {vehicle = model, plate = plate})
|
||||||
|
end
|
||||||
|
return vehicles
|
||||||
|
end
|
||||||
|
|
||||||
-- Framework.RegisterUsableItem(item, cb)
|
-- Framework.RegisterUsableItem(item, cb)
|
||||||
-- Registers a usable item with a callback function.
|
-- Registers a usable item with a callback function.
|
||||||
Framework.RegisterUsableItem = function(itemName, cb)
|
Framework.RegisterUsableItem = function(itemName, cb)
|
||||||
@@ -207,6 +224,15 @@ Framework.RegisterUsableItem = function(itemName, cb)
|
|||||||
ESX.RegisterUsableItem(itemName, func)
|
ESX.RegisterUsableItem(itemName, func)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
RegisterNetEvent("esx:playerLogout", function()
|
||||||
|
TriggerEvent("community_bridge:Server:OnPlayerUnload", source)
|
||||||
|
end)
|
||||||
|
|
||||||
|
AddEventHandler("playerDropped", function()
|
||||||
|
local src = source
|
||||||
|
TriggerEvent("community_bridge:Server:OnPlayerUnload", src)
|
||||||
|
end)
|
||||||
|
|
||||||
Framework.Commands = {}
|
Framework.Commands = {}
|
||||||
Framework.Commands.Add = function(name, help, arguments, argsrequired, callback, permission, ...)
|
Framework.Commands.Add = function(name, help, arguments, argsrequired, callback, permission, ...)
|
||||||
ESX.RegisterCommand(name, permission, function(xPlayer, args, showError)
|
ESX.RegisterCommand(name, permission, function(xPlayer, args, showError)
|
||||||
|
|||||||
@@ -177,6 +177,17 @@ Framework.GetAccountBalance = function(src, _type)
|
|||||||
return player.getData(_type)
|
return player.getData(_type)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Framework.GetOwnedVehicles = function(src)
|
||||||
|
local player = NDCore:getPlayer(src)
|
||||||
|
local vehicles = NDCore:getVehicles(player.id)
|
||||||
|
local foundvehicles = {}
|
||||||
|
for i=1, #vehicles do
|
||||||
|
local veh = vehicles[i]
|
||||||
|
table.insert(foundvehicles, {vehicle = veh.properties.model, plate = veh.plate})
|
||||||
|
end
|
||||||
|
return foundvehicles
|
||||||
|
end
|
||||||
|
|
||||||
Framework.RegisterUsableItem = function(itemName, cb)
|
Framework.RegisterUsableItem = function(itemName, cb)
|
||||||
exports(itemName, function(event, item, inventory, slot, data)
|
exports(itemName, function(event, item, inventory, slot, data)
|
||||||
local slotData = exports.ox_inventory:GetSlot(inventory.id, slot)
|
local slotData = exports.ox_inventory:GetSlot(inventory.id, slot)
|
||||||
@@ -186,3 +197,12 @@ Framework.RegisterUsableItem = function(itemName, cb)
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
RegisterNetEvent("ND:characterUnloaded", function()
|
||||||
|
TriggerEvent("community_bridge:Server:OnPlayerUnload", source)
|
||||||
|
end)
|
||||||
|
|
||||||
|
AddEventHandler("playerDropped", function()
|
||||||
|
local src = source
|
||||||
|
TriggerEvent("community_bridge:Server:OnPlayerUnload", src)
|
||||||
|
end)
|
||||||
@@ -5,6 +5,10 @@ QBCore = exports['qb-core']:GetCoreObject()
|
|||||||
|
|
||||||
Framework = {}
|
Framework = {}
|
||||||
|
|
||||||
|
Framework.GetFrameworkName = function()
|
||||||
|
return 'qb-core'
|
||||||
|
end
|
||||||
|
|
||||||
Framework.GetPlayerData = function()
|
Framework.GetPlayerData = function()
|
||||||
return QBCore.Functions.GetPlayerData()
|
return QBCore.Functions.GetPlayerData()
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,6 +5,10 @@ QBCore = exports['qb-core']:GetCoreObject()
|
|||||||
|
|
||||||
Framework = {}
|
Framework = {}
|
||||||
|
|
||||||
|
Framework.GetFrameworkName = function()
|
||||||
|
return 'qb-core'
|
||||||
|
end
|
||||||
|
|
||||||
-- Framework.GetPlayerIdentifier(src)
|
-- Framework.GetPlayerIdentifier(src)
|
||||||
-- Returns the citizen ID of the player.
|
-- Returns the citizen ID of the player.
|
||||||
Framework.GetPlayerIdentifier = function(src)
|
Framework.GetPlayerIdentifier = function(src)
|
||||||
@@ -67,6 +71,26 @@ Framework.GetPlayerInventory = function(src)
|
|||||||
return repackedTable
|
return repackedTable
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Framework.GetItemBySlot = function(src, slot)
|
||||||
|
local playerItems = QBCore.Functions.GetPlayer(src).PlayerData.items
|
||||||
|
local repack = {}
|
||||||
|
for _, v in pairs(playerItems) do
|
||||||
|
if v.slot == slot then
|
||||||
|
return {
|
||||||
|
name = v.name,
|
||||||
|
label = v.label,
|
||||||
|
weight = v.weight,
|
||||||
|
count = v.amount,
|
||||||
|
metadata = v.info,
|
||||||
|
slot = v.slot,
|
||||||
|
stack = v.unique or false,
|
||||||
|
description = v.description or "none",
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return repack
|
||||||
|
end
|
||||||
|
|
||||||
-- Framework.SetMetadata(src, metadata, value)
|
-- Framework.SetMetadata(src, metadata, value)
|
||||||
-- Adds the specified metadata key and number value to the player's data.
|
-- Adds the specified metadata key and number value to the player's data.
|
||||||
Framework.SetPlayerMetadata = function(src, metadata, value)
|
Framework.SetPlayerMetadata = function(src, metadata, value)
|
||||||
@@ -246,6 +270,18 @@ Framework.SetMetadata = function(src, item, slot, metadata)
|
|||||||
return player.Functions.AddItem(item, 1, freeSlot, metadata)
|
return player.Functions.AddItem(item, 1, freeSlot, metadata)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Framework.GetOwnedVehicles = function(src)
|
||||||
|
local citizenId = Framework.GetPlayerIdentifier(src)
|
||||||
|
local result = MySQL.Sync.fetchAll("SELECT vehicle, plate FROM player_vehicles WHERE citizenid = '" .. citizenId .. "'")
|
||||||
|
local vehicles = {}
|
||||||
|
for i=1, #result do
|
||||||
|
local vehicle = result[i].vehicle
|
||||||
|
local plate = result[i].plate
|
||||||
|
table.insert(vehicles, {vehicle = vehicle, plate = plate})
|
||||||
|
end
|
||||||
|
return vehicles
|
||||||
|
end
|
||||||
|
|
||||||
-- Framework.RegisterUsableItem(item, cb)
|
-- Framework.RegisterUsableItem(item, cb)
|
||||||
-- Registers a usable item with a callback function.
|
-- Registers a usable item with a callback function.
|
||||||
Framework.RegisterUsableItem = function(itemName, cb)
|
Framework.RegisterUsableItem = function(itemName, cb)
|
||||||
@@ -257,6 +293,15 @@ Framework.RegisterUsableItem = function(itemName, cb)
|
|||||||
QBCore.Functions.CreateUseableItem(itemName, func)
|
QBCore.Functions.CreateUseableItem(itemName, func)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
RegisterNetEvent("QBCore:Server:OnPlayerUnload", function()
|
||||||
|
TriggerEvent("community_bridge:Server:OnPlayerUnload", source)
|
||||||
|
end)
|
||||||
|
|
||||||
|
AddEventHandler("playerDropped", function()
|
||||||
|
local src = source
|
||||||
|
TriggerEvent("community_bridge:Server:OnPlayerUnload", src)
|
||||||
|
end)
|
||||||
|
|
||||||
Framework.Commands = {}
|
Framework.Commands = {}
|
||||||
Framework.Commands.Add = function(name, help, arguments, argsrequired, callback, permission, ...)
|
Framework.Commands.Add = function(name, help, arguments, argsrequired, callback, permission, ...)
|
||||||
QBCore.Commands.Add(name, help, arguments, argsrequired, callback, permission, ...)
|
QBCore.Commands.Add(name, help, arguments, argsrequired, callback, permission, ...)
|
||||||
|
|||||||
@@ -4,6 +4,10 @@ QBox = exports.qbx_core
|
|||||||
|
|
||||||
Framework = {}
|
Framework = {}
|
||||||
|
|
||||||
|
Framework.GetFrameworkName = function()
|
||||||
|
return 'qbx_core'
|
||||||
|
end
|
||||||
|
|
||||||
Framework.GetPlayerData = function()
|
Framework.GetPlayerData = function()
|
||||||
return QBox.GetPlayerData()
|
return QBox.GetPlayerData()
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,6 +4,10 @@ local QBox = exports.qbx_core
|
|||||||
|
|
||||||
Framework = {}
|
Framework = {}
|
||||||
|
|
||||||
|
Framework.GetFrameworkName = function()
|
||||||
|
return 'qbx_core'
|
||||||
|
end
|
||||||
|
|
||||||
-- Framework.GetPlayerIdentifier(src)
|
-- Framework.GetPlayerIdentifier(src)
|
||||||
-- Returns the citizen ID of the player.
|
-- Returns the citizen ID of the player.
|
||||||
Framework.GetPlayerIdentifier = function(src)
|
Framework.GetPlayerIdentifier = function(src)
|
||||||
@@ -233,6 +237,27 @@ Framework.SetMetadata = function(src, item, slot, metadata)
|
|||||||
return player.Functions.AddItem(item, 1, slot, metadata)
|
return player.Functions.AddItem(item, 1, slot, metadata)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Framework.GetOwnedVehicles = function(src)
|
||||||
|
local citizenId = Framework.GetPlayerIdentifier(src)
|
||||||
|
local result = MySQL.Sync.fetchAll("SELECT vehicle, plate FROM player_vehicles WHERE citizenid = '" .. citizenId .. "'")
|
||||||
|
local vehicles = {}
|
||||||
|
for i=1, #result do
|
||||||
|
local vehicle = result[i].vehicle
|
||||||
|
local plate = result[i].plate
|
||||||
|
table.insert(vehicles, {vehicle = vehicle, plate = plate})
|
||||||
|
end
|
||||||
|
return vehicles
|
||||||
|
end
|
||||||
|
|
||||||
|
RegisterNetEvent("QBCore:Server:OnPlayerUnload", function()
|
||||||
|
TriggerEvent("community_bridge:Server:OnPlayerUnload", source)
|
||||||
|
end)
|
||||||
|
|
||||||
|
AddEventHandler("playerDropped", function()
|
||||||
|
local src = source
|
||||||
|
TriggerEvent("community_bridge:Server:OnPlayerUnload", src)
|
||||||
|
end)
|
||||||
|
|
||||||
-- Framework.RegisterUsableItem(item, cb)
|
-- Framework.RegisterUsableItem(item, cb)
|
||||||
-- Registers a usable item with a callback function.
|
-- Registers a usable item with a callback function.
|
||||||
Framework.RegisterUsableItem = function(itemName, cb)
|
Framework.RegisterUsableItem = function(itemName, cb)
|
||||||
|
|||||||
@@ -17,10 +17,14 @@ Inventory.GetItemCount = function(src, item, metadata)
|
|||||||
return Framework.GetItemCount(src, item, metadata)
|
return Framework.GetItemCount(src, item, metadata)
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.GetInventoryItems = function(src)
|
Inventory.GetPlayerInventory = function(src)
|
||||||
return Framework.GetPlayerInventory(src)
|
return Framework.GetPlayerInventory(src)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Inventory.GetItemBySlot = function(src, slot)
|
||||||
|
return Framework.GetItemBySlot(src, slot)
|
||||||
|
end
|
||||||
|
|
||||||
Inventory.SetMetadata = function(src, item, slot, metadata)
|
Inventory.SetMetadata = function(src, item, slot, metadata)
|
||||||
return Framework.SetMetadata(src, item, slot, metadata)
|
return Framework.SetMetadata(src, item, slot, metadata)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
if GetResourceState('codem-inventory') ~= 'started' then return end
|
if GetResourceState('codem-inventory') ~= 'started' then return end
|
||||||
Inventory = Inventory or {}
|
Inventory = Inventory or {}
|
||||||
|
|
||||||
|
local codem = exports['codem-inventory']
|
||||||
|
|
||||||
Inventory.GetItemInfo = function(item)
|
Inventory.GetItemInfo = function(item)
|
||||||
local itemData = exports['codem-inventory']:GetItemList()
|
local itemData = codem:GetItemList()
|
||||||
if not itemData[item] then return {} end
|
if not itemData[item] then return {} end
|
||||||
local repackedTable = {
|
local repackedTable = {
|
||||||
name = itemData.name or "Missing Name",
|
name = itemData.name or "Missing Name",
|
||||||
|
|||||||
@@ -1,20 +1,22 @@
|
|||||||
if GetResourceState('codem-inventory') ~= 'started' then return end
|
if GetResourceState('codem-inventory') ~= 'started' then return end
|
||||||
|
|
||||||
|
local codem = exports['codem-inventory']
|
||||||
|
|
||||||
Inventory = Inventory or {}
|
Inventory = Inventory or {}
|
||||||
|
|
||||||
Inventory.AddItem = function(src, item, count, slot, metadata)
|
Inventory.AddItem = function(src, item, count, slot, metadata)
|
||||||
return exports['codem-inventory']:AddItem(src, item, count, slot, metadata)
|
return codem:AddItem(src, item, count, slot, metadata)
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.RemoveItem = function(src, item, count, slot, metadata)
|
Inventory.RemoveItem = function(src, item, count, slot, metadata)
|
||||||
if metadata == nil then
|
if metadata == nil then
|
||||||
return exports['codem-inventory']:RemoveItem(src, item, count, slot)
|
return codem:RemoveItem(src, item, count, slot)
|
||||||
else
|
else
|
||||||
local items = exports['codem-inventory']:GetInventory(nil, src)
|
local items = codem:GetInventory(nil, src)
|
||||||
for _, itemInfo in pairs(items) do
|
for _, itemInfo in pairs(items) do
|
||||||
if itemInfo.name == item then
|
if itemInfo.name == item then
|
||||||
if itemInfo.info == metadata then
|
if itemInfo.info == metadata then
|
||||||
return exports['codem-inventory']:RemoveItem(src, item, count, itemInfo.slot)
|
return codem:RemoveItem(src, item, count, itemInfo.slot)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -22,7 +24,7 @@ Inventory.RemoveItem = function(src, item, count, slot, metadata)
|
|||||||
end
|
end
|
||||||
|
|
||||||
Inventory.GetItemInfo = function(item)
|
Inventory.GetItemInfo = function(item)
|
||||||
local itemData = exports['codem-inventory']:GetItemList()
|
local itemData = codem:GetItemList()
|
||||||
if not itemData[item] then return {} end
|
if not itemData[item] then return {} end
|
||||||
local repackedTable = {
|
local repackedTable = {
|
||||||
name = itemData.name or "Missing Name",
|
name = itemData.name or "Missing Name",
|
||||||
@@ -37,10 +39,10 @@ end
|
|||||||
|
|
||||||
Inventory.GetItemCount = function(src, item, metadata)
|
Inventory.GetItemCount = function(src, item, metadata)
|
||||||
if metadata == nil then
|
if metadata == nil then
|
||||||
return exports['codem-inventory']:GetItemsTotalAmount(src, item)
|
return codem:GetItemsTotalAmount(src, item)
|
||||||
else
|
else
|
||||||
local count = 0
|
local count = 0
|
||||||
local items = exports['codem-inventory']:GetInventory(nil, src)
|
local items = codem:GetInventory(nil, src)
|
||||||
for _, itemInfo in pairs(items) do
|
for _, itemInfo in pairs(items) do
|
||||||
if itemInfo.name == item and itemInfo.info == metadata then
|
if itemInfo.name == item and itemInfo.info == metadata then
|
||||||
count = count + itemInfo.amount
|
count = count + itemInfo.amount
|
||||||
@@ -50,8 +52,26 @@ Inventory.GetItemCount = function(src, item, metadata)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.GetInventoryItems = function(src)
|
Inventory.GetItemBySlot = function(src, slot)
|
||||||
local items = exports['codem-inventory']:GetInventory(nil, src)
|
local slotData = codem:GetItemBySlot(src, slot)
|
||||||
|
-- The keys are not documented, so this is a best guess
|
||||||
|
for _, v in pairs(slotData) do
|
||||||
|
return {
|
||||||
|
name = v.name,
|
||||||
|
label = v.name,
|
||||||
|
weight = v.weight,
|
||||||
|
slot = v.slot,
|
||||||
|
count = v.amount,
|
||||||
|
metadata = v.info,
|
||||||
|
stack = v.unique,
|
||||||
|
description = v.description
|
||||||
|
}
|
||||||
|
end
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
|
||||||
|
Inventory.GetPlayerInventory = function(src)
|
||||||
|
local items = codem:GetInventory(nil, src)
|
||||||
local repackedTable = {}
|
local repackedTable = {}
|
||||||
for _, v in pairs(items) do
|
for _, v in pairs(items) do
|
||||||
table.insert(repackedTable, {
|
table.insert(repackedTable, {
|
||||||
@@ -65,7 +85,7 @@ Inventory.GetInventoryItems = function(src)
|
|||||||
end
|
end
|
||||||
|
|
||||||
Inventory.SetMetadata = function(src, item, slot, metadata)
|
Inventory.SetMetadata = function(src, item, slot, metadata)
|
||||||
exports['codem-inventory']:SetItemMetadata(src, slot, metadata)
|
codem:SetItemMetadata(src, slot, metadata)
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords)
|
Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords)
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
if GetResourceState('jpr-inventory') ~= 'started' then return end
|
||||||
|
|
||||||
|
Inventory = Inventory or {}
|
||||||
|
|
||||||
|
RegisterNetEvent('community_bridge:client:jpr-inventory:openStash', function(id, data)
|
||||||
|
if source ~= 65535 then return end
|
||||||
|
TriggerEvent("inventory:client:SetCurrentStash", id)
|
||||||
|
TriggerServerEvent('inventory:server:OpenInventory', 'stash', id, { maxweight = data.weight, slots = data.slots })
|
||||||
|
end)
|
||||||
|
|
||||||
|
Inventory.GetImagePath = function(item)
|
||||||
|
local file = LoadResourceFile("jpr-inventory", string.format("html/images/%s.png", item))
|
||||||
|
local imagePath = file and string.format("nui://jpr-inventory/html/images/%s.png", item)
|
||||||
|
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
||||||
|
end
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
if GetResourceState('jpr-inventory') ~= 'started' then return end
|
||||||
|
|
||||||
|
local jpr = exports['jpr-inventory']
|
||||||
|
|
||||||
|
Inventory = Inventory or {}
|
||||||
|
|
||||||
|
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coords)
|
||||||
|
TriggerClientEvent('community_bridge:client:qb-inventory:openStash', src, id, { weight = weight, slots = slots })
|
||||||
|
end
|
||||||
|
|
||||||
|
Inventory.GetImagePath = function(item)
|
||||||
|
local file = LoadResourceFile("jpr-inventory", string.format("html/images/%s.png", item))
|
||||||
|
local imagePath = file and string.format("nui://jpr-inventory/html/images/%s.png", item)
|
||||||
|
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
||||||
|
end
|
||||||
|
|
||||||
|
Inventory.GetItemBySlot = function(src, slot)
|
||||||
|
local slotData = jpr:GetItemBySlot(src, slot)
|
||||||
|
if not slotData then return {} end
|
||||||
|
return { name = slotData.name, label = slotData.label, weight = slotData.weight, slot = slot, count = slotData.amount, metadata = slotData.info, stack = slotData.unique, description = slotData.description }
|
||||||
|
end
|
||||||
@@ -2,10 +2,10 @@ if GetResourceState('origen_inventory') ~= 'started' then return end
|
|||||||
|
|
||||||
Inventory = Inventory or {}
|
Inventory = Inventory or {}
|
||||||
|
|
||||||
local origen_inventory = exports.origen_inventory
|
local origin = exports.origen_inventory
|
||||||
|
|
||||||
Inventory.GetItemInfo = function(item)
|
Inventory.GetItemInfo = function(item)
|
||||||
local itemData = origen_inventory:Items(item)
|
local itemData = origin:Items(item)
|
||||||
local repackedTable = {
|
local repackedTable = {
|
||||||
name = itemData.name or "Missing Name",
|
name = itemData.name or "Missing Name",
|
||||||
label = itemData.label or "Missing Label",
|
label = itemData.label or "Missing Label",
|
||||||
|
|||||||
@@ -5,14 +5,11 @@ Inventory = Inventory or {}
|
|||||||
local origen_inventory = exports.origen_inventory
|
local origen_inventory = exports.origen_inventory
|
||||||
|
|
||||||
Inventory.AddItem = function(src, item, count, slot, metadata)
|
Inventory.AddItem = function(src, item, count, slot, metadata)
|
||||||
if not origen_inventory:CanCarryItem(src, item, count) then
|
return origen_inventory:AddItem(src, item, count, metadata, slot, true)
|
||||||
return Bridge.notify.SendNotify(src, "Inventory Full", "error", 5000)
|
|
||||||
end
|
|
||||||
return origen_inventory:AddItem(src, item, count, nil, nil, metadata)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.RemoveItem = function(src, item, count, slot, metadata)
|
Inventory.RemoveItem = function(src, item, count, slot, metadata)
|
||||||
return origen_inventory:RemoveItem(src, item, count, metadata)
|
return origen_inventory:removeItem(src, item, count, metadata, slot, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.GetItemInfo = function(item)
|
Inventory.GetItemInfo = function(item)
|
||||||
@@ -35,8 +32,8 @@ Inventory.GetItemCount = function(src, item, metadata)
|
|||||||
local items = origen_inventory:GetInventory(src)
|
local items = origen_inventory:GetInventory(src)
|
||||||
local count = 0
|
local count = 0
|
||||||
for _, itemInfo in pairs(items) do
|
for _, itemInfo in pairs(items) do
|
||||||
if itemInfo.name == item and itemInfo.info == metadata then
|
if itemInfo.name == item and itemInfo.info == metadata or itemInfo.metadata == metadata then
|
||||||
count = count + itemInfo.amount
|
count = count + itemInfo.count
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return count
|
return count
|
||||||
@@ -46,17 +43,38 @@ end
|
|||||||
Inventory.GetPlayerInventory = function(src)
|
Inventory.GetPlayerInventory = function(src)
|
||||||
local playerItems = origen_inventory:GetInventory(src)
|
local playerItems = origen_inventory:GetInventory(src)
|
||||||
local repackedTable = {}
|
local repackedTable = {}
|
||||||
for _, v in pairs(playerItems) do
|
for _, v in pairs(playerItems.inventory) do
|
||||||
|
print(json.encode(v, { indent = true }))
|
||||||
table.insert(repackedTable, {
|
table.insert(repackedTable, {
|
||||||
name = v.name,
|
name = v.name,
|
||||||
count = v.amount,
|
count = v.count,
|
||||||
metadata = v.info,
|
metadata = v.metadata,
|
||||||
slot = v.slot,
|
slot = v.slot,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
return repackedTable
|
return repackedTable
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Inventory.GetItemBySlot = function(src, slot)
|
||||||
|
-- This inventory got rid of almost all the great exports they had =(
|
||||||
|
local slotData = Inventory.GetInventoryItems(src)
|
||||||
|
for _, item in pairs(slotData) do
|
||||||
|
if item.slot == slot then
|
||||||
|
return {
|
||||||
|
name = item.name,
|
||||||
|
label = item.name,
|
||||||
|
weight = item.weight,
|
||||||
|
slot = slot,
|
||||||
|
count = item.amount,
|
||||||
|
metadata = item.metadata,
|
||||||
|
stack = item.unique or false,
|
||||||
|
description = item.description
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
|
||||||
Inventory.CanCarryItem = function(src, item, count)
|
Inventory.CanCarryItem = function(src, item, count)
|
||||||
return origen_inventory:CanCarryItems(src, item, count)
|
return origen_inventory:CanCarryItems(src, item, count)
|
||||||
end
|
end
|
||||||
@@ -70,7 +88,8 @@ Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coo
|
|||||||
end
|
end
|
||||||
|
|
||||||
Inventory.SetMetadata = function(src, item, slot, metadata)
|
Inventory.SetMetadata = function(src, item, slot, metadata)
|
||||||
origen_inventory:SetItemMetadata(src, item, slot, metadata)
|
Inventory.RemoveItem (src, item, 1, slot, nil)
|
||||||
|
Inventory.AddItem(src, item, 1, slot, metadata)
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.GetImagePath = function(item)
|
Inventory.GetImagePath = function(item)
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ Inventory.GetItem = function(src, item, metadata)
|
|||||||
return ox_inventory:GetItem(src, item, metadata, false)
|
return ox_inventory:GetItem(src, item, metadata, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Inventory.GetItemBySlot = function(src, slot)
|
||||||
|
return ox_inventory:GetSlot(src, slot)
|
||||||
|
end
|
||||||
|
|
||||||
Inventory.GetItemCount = function(src, item, metadata)
|
Inventory.GetItemCount = function(src, item, metadata)
|
||||||
return ox_inventory:GetItemCount(src, item, metadata, false)
|
return ox_inventory:GetItemCount(src, item, metadata, false)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
if GetResourceState('ps-inventory') ~= 'started' then return end
|
if GetResourceState('ps-inventory') ~= 'started' then return end
|
||||||
|
|
||||||
|
local sloth = exports['ps-inventory']
|
||||||
|
|
||||||
Inventory = Inventory or {}
|
Inventory = Inventory or {}
|
||||||
|
|
||||||
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
|
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
|
||||||
@@ -15,3 +17,9 @@ Inventory.GetImagePath = function(item)
|
|||||||
local imagePath = file and string.format("nui://ps-inventory/html/images/%s.png", item)
|
local imagePath = file and string.format("nui://ps-inventory/html/images/%s.png", item)
|
||||||
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Inventory.GetItemBySlot = function(src, slot)
|
||||||
|
local slotData = sloth:GetItemBySlot(src, slot)
|
||||||
|
if not slotData then return {} end
|
||||||
|
return {name = slotData.name, label = slotData.name, weight = slotData.weight, slot = slot, count = slotData.amount, metadata = slotData.info, stack = slotData.unique, description = slotData.description}
|
||||||
|
end
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
if GetResourceState('qb-inventory') ~= 'started' then return end
|
if GetResourceState('qb-inventory') ~= 'started' then return end
|
||||||
|
|
||||||
|
local qbInventory = exports['qb-inventory']
|
||||||
|
|
||||||
Inventory = Inventory or {}
|
Inventory = Inventory or {}
|
||||||
|
|
||||||
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
|
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
|
||||||
@@ -15,3 +17,18 @@ Inventory.GetImagePath = function(item)
|
|||||||
local imagePath = file and string.format("nui://qb-inventory/html/images/%s.png", item)
|
local imagePath = file and string.format("nui://qb-inventory/html/images/%s.png", item)
|
||||||
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Inventory.GetItemBySlot(src, slot)
|
||||||
|
local slotData = qbInventory:GetItemBySlot(src, slot)
|
||||||
|
if not slotData then return {} end
|
||||||
|
return {
|
||||||
|
name = slotData.name,
|
||||||
|
label = slotData.name,
|
||||||
|
weight = slotData.weight,
|
||||||
|
slot = slotData.slot,
|
||||||
|
count = slotData.amount,
|
||||||
|
metadata = slotData.info,
|
||||||
|
stack = slotData.unique,
|
||||||
|
description = slotData.description
|
||||||
|
}
|
||||||
|
end
|
||||||
@@ -1,13 +1,14 @@
|
|||||||
if GetResourceState('qs-inventory') ~= 'started' then return end
|
if GetResourceState('qs-inventory') ~= 'started' then return end
|
||||||
|
local quasar = exports["qs-inventory"]
|
||||||
|
|
||||||
Inventory = Inventory or {}
|
Inventory = Inventory or {}
|
||||||
|
|
||||||
Inventory.OpenStash = function(id)
|
Inventory.OpenStash = function(id)
|
||||||
exports['qs-inventory']:RegisterStash(id, 50, 50000)
|
quasar:RegisterStash(id, 50, 50000)
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.GetItemInfo = function(item)
|
Inventory.GetItemInfo = function(item)
|
||||||
local itemData = exports['qs-inventory']:GetItemList()
|
local itemData = quasar:GetItemList()
|
||||||
if not itemData[item] then return {} end
|
if not itemData[item] then return {} end
|
||||||
local repackedTable = {
|
local repackedTable = {
|
||||||
name = itemData.name or "Missing Name",
|
name = itemData.name or "Missing Name",
|
||||||
|
|||||||
@@ -1,22 +1,24 @@
|
|||||||
if GetResourceState('qs-inventory') ~= 'started' then return end
|
if GetResourceState('qs-inventory') ~= 'started' then return end
|
||||||
|
|
||||||
|
local quasar = exports['qs-inventory']
|
||||||
|
|
||||||
Inventory = Inventory or {}
|
Inventory = Inventory or {}
|
||||||
|
|
||||||
Inventory.AddItem = function(src, item, count, slot, metadata)
|
Inventory.AddItem = function(src, item, count, slot, metadata)
|
||||||
if not exports['qs-inventory']:CanCarryItem(src, item, count) then return false end
|
if not quasar:CanCarryItem(src, item, count) then return false end
|
||||||
return exports['qs-inventory']:AddItem(src, item, count, slot, metadata)
|
return quasar:AddItem(src, item, count, slot, metadata)
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.RemoveItem = function(src, item, count, slot, metadata)
|
Inventory.RemoveItem = function(src, item, count, slot, metadata)
|
||||||
return exports['qs-inventory']:RemoveItem(src, item, count, slot, metadata)
|
return quasar:RemoveItem(src, item, count, slot, metadata)
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.GetItemCount = function(src, item, metadata)
|
Inventory.GetItemCount = function(src, item, metadata)
|
||||||
return exports['qs-inventory']:GetItemTotalAmount(src, item)
|
return quasar:GetItemTotalAmount(src, item)
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.GetPlayerInventory = function(src)
|
Inventory.GetPlayerInventory = function(src)
|
||||||
local playerItems = exports['qs-inventory']:GetInventory(src)
|
local playerItems = quasar:GetInventory(src)
|
||||||
local repackedTable = {}
|
local repackedTable = {}
|
||||||
for _, v in pairs(playerItems) do
|
for _, v in pairs(playerItems) do
|
||||||
table.insert(repackedTable, {
|
table.insert(repackedTable, {
|
||||||
@@ -29,8 +31,27 @@ Inventory.GetPlayerInventory = function(src)
|
|||||||
return repackedTable
|
return repackedTable
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Inventory.GetItemBySlot = function(src, slot)
|
||||||
|
local playerItems = quasar:GetInventory(src)
|
||||||
|
for _, item in pairs(playerItems) do
|
||||||
|
if item.slot == slot then
|
||||||
|
return {
|
||||||
|
name = item.name,
|
||||||
|
label = item.label,
|
||||||
|
weight = item.weight,
|
||||||
|
slot = slot,
|
||||||
|
count = item.amount,
|
||||||
|
metadata = item.info,
|
||||||
|
stack = item.unique or false,
|
||||||
|
description = item.description
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
Inventory.CanCarryItem = function(src, item, count)
|
Inventory.CanCarryItem = function(src, item, count)
|
||||||
return exports['qs-inventory']:CanCarryItem(src, item, count)
|
return quasar:CanCarryItem(src, item, count)
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
|
Inventory.RegisterStash = function(id, label, slots, weight, owner, groups, coords)
|
||||||
@@ -43,7 +64,7 @@ Inventory.OpenStash = function(src, id, label, slots, weight, owner, groups, coo
|
|||||||
end
|
end
|
||||||
|
|
||||||
Inventory.GetItemInfo = function(item)
|
Inventory.GetItemInfo = function(item)
|
||||||
local itemData = exports['qs-inventory']:GetItemList()
|
local itemData = quasar:GetItemList()
|
||||||
if not itemData[item] then return {} end
|
if not itemData[item] then return {} end
|
||||||
local repackedTable = {
|
local repackedTable = {
|
||||||
name = itemData.name or "Missing Name",
|
name = itemData.name or "Missing Name",
|
||||||
@@ -57,7 +78,7 @@ Inventory.GetItemInfo = function(item)
|
|||||||
end
|
end
|
||||||
|
|
||||||
Inventory.SetMetadata = function(src, item, slot, metadata)
|
Inventory.SetMetadata = function(src, item, slot, metadata)
|
||||||
return exports['qs-inventory']:SetItemMetadata(src, slot, metadata)
|
return quasar:SetItemMetadata(src, slot, metadata)
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.GetImagePath = function(item)
|
Inventory.GetImagePath = function(item)
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
if GetResourceState('tgiann-inventory') ~= 'started' then return end
|
if GetResourceState('tgiann-inventory') ~= 'started' then return end
|
||||||
|
|
||||||
local tgiann = exports["tgiann-inventory"]
|
local tgiann = exports["tgiann-inventory"]
|
||||||
|
|
||||||
Inventory = Inventory or {}
|
Inventory = Inventory or {}
|
||||||
|
|
||||||
Inventory.AddItem = function(src, item, count, slot, metadata)
|
Inventory.AddItem = function(src, item, count, slot, metadata)
|
||||||
if not tgiann:CanCarryItem(src, item, count) then return false end
|
if not tgiann:CanCarryItem(src, item, count) then return false end
|
||||||
local action = tgiann:AddItem(src, item, count, metadata)
|
return tgiann:AddItem(src, item, count, slot, metadata, false)
|
||||||
return (action.itemAddRemoveLog == 'added')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.RemoveItem = function(src, item, count, slot, metadata)
|
Inventory.RemoveItem = function(src, item, count, slot, metadata)
|
||||||
return tgiann:RemoveItem(src, item, count, nil, metadata)
|
return tgiann:RemoveItem(src, item, count, slot, metadata)
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.GetItem = function(src, item, metadata)
|
Inventory.GetItem = function(src, item, metadata)
|
||||||
@@ -25,8 +25,15 @@ Inventory.GetItemCount = function(src, item, metadata)
|
|||||||
return _item.amount or 0
|
return _item.amount or 0
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.GetInventoryItems = function(src)
|
Inventory.GetPlayerInventory = function(src)
|
||||||
return tgiann:GetPlayerItems(src)
|
local inventory = tgiann:GetPlayerItems(src)
|
||||||
|
local items = {}
|
||||||
|
for _, v in pairs(inventory) do
|
||||||
|
if tonumber(_) then
|
||||||
|
table.insert(items, {name = v.name, label = v.name, weight = 0, description = v.description, slot = v.slot, count = v.amount, metadata = v.info})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return items
|
||||||
end
|
end
|
||||||
|
|
||||||
Inventory.CanCarryItem = function(src, item, count)
|
Inventory.CanCarryItem = function(src, item, count)
|
||||||
@@ -37,6 +44,12 @@ Inventory.RegisterStash = function(id, label, slots, weight, owner)
|
|||||||
return tgiann:CreateCustomStashWithItem(id, {})
|
return tgiann:CreateCustomStashWithItem(id, {})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Inventory.GetItemBySlot = function(src, slot)
|
||||||
|
local item = tgiann:GetItemBySlot(src, slot)
|
||||||
|
if not item then return {} end
|
||||||
|
return {name = item.name, label = item.label, weight = item.weight, slot = slot, count = item.amount, metadata = item.info, stack = item.unique or false, description = item.description}
|
||||||
|
end
|
||||||
|
|
||||||
Inventory.GetItemInfo = function(item)
|
Inventory.GetItemInfo = function(item)
|
||||||
local itemData = tgiann:GetItemList()
|
local itemData = tgiann:GetItemList()
|
||||||
if not itemData[item] then return {} end
|
if not itemData[item] then return {} end
|
||||||
|
|||||||
@@ -176,6 +176,16 @@ Utility.NotifyText = function(text)
|
|||||||
DrawNotification(false, true)
|
DrawNotification(false, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Utility.RequestAnimDict = function(dict)
|
||||||
|
RequestAnimDict(dict)
|
||||||
|
local count = 0
|
||||||
|
while not HasAnimDictLoaded(dict) and count < 30000 do
|
||||||
|
Wait(0)
|
||||||
|
count = count + 1
|
||||||
|
end
|
||||||
|
return HasAnimDictLoaded(dict)
|
||||||
|
end
|
||||||
|
|
||||||
Utility.TeleportPlayer = function(coords, conditionFunction, afterTeleportFunction)
|
Utility.TeleportPlayer = function(coords, conditionFunction, afterTeleportFunction)
|
||||||
if conditionFunction ~= nil then
|
if conditionFunction ~= nil then
|
||||||
if not conditionFunction() then
|
if not conditionFunction() then
|
||||||
|
|||||||
Reference in new issue
Block a user