mirror of
https://github.com/jimathy/jim_bridge.git
synced 2026-08-17 05:56:02 +01:00
Merge branch 'jimathy:main' into main
This commit is contained in:
@@ -10,7 +10,7 @@ OXLibExport, QBXExport, QBExport, ESXExport, OXCoreExport =
|
||||
Exports.ESXExport or "",
|
||||
Exports.OXCoreExport or ""
|
||||
|
||||
OXInv, QBInv, PSInv, QSInv, CoreInv, CodeMInv, OrigenInv, TgiannInv =
|
||||
OXInv, QBInv, PSInv, QSInv, CoreInv, CodeMInv, OrigenInv, TgiannInv, JPRInv =
|
||||
Exports.OXInv or "",
|
||||
Exports.QBInv or "",
|
||||
Exports.PSInv or "",
|
||||
@@ -18,7 +18,8 @@ OXInv, QBInv, PSInv, QSInv, CoreInv, CodeMInv, OrigenInv, TgiannInv =
|
||||
Exports.CoreInv or "",
|
||||
Exports.CodeMInv or "",
|
||||
Exports.OrigenInv or "",
|
||||
Exports.TgiannInv or ""
|
||||
Exports.TgiannInv or "",
|
||||
Exports.JPRInv or ""
|
||||
|
||||
RSGExport, RSGInv = Exports.RSGExport or "", Exports.RSGInv or ""
|
||||
QBMenuExport = Exports.QBMenuExport or ""
|
||||
|
||||
@@ -88,6 +88,7 @@ function craftingMenu(data)
|
||||
|
||||
-- Check if the player can carry the required items (server callback).
|
||||
local canCarryTable = triggerCallback(getScript()..':server:canCarry', tempCarryTable)
|
||||
|
||||
-- Process each recipe to create menu entries.
|
||||
for i = 1, #Recipes do
|
||||
if not Recipes[i]["amount"] then Recipes[i]["amount"] = 1 end
|
||||
@@ -106,10 +107,13 @@ function craftingMenu(data)
|
||||
local metaTable = {}
|
||||
-- Build ingredient details.
|
||||
for l, b in pairs(Recipes[i][tostring(k)]) do
|
||||
settext = settext..(settext ~= "" and br or "")..(Items[l] and Items[l].label or "error - "..l)..(b > 1 and " x"..b or "")
|
||||
local label = Items[l] and Items[l].label or "error - "..l
|
||||
local hasItem = checkStashItem(data.stashName, { [l] = b })
|
||||
local missingMark = not hasItem and " ❌" or " "
|
||||
settext = settext..(settext ~= "" and br or "").."[ x"..b.." ] - "..label..(b > 1 and " x"..b or "")..missingMark
|
||||
|
||||
metaTable[Items[l] and Items[l].label or "error - "..l] = b
|
||||
itemTable[l] = b
|
||||
--Wait(0)
|
||||
end
|
||||
|
||||
while not canCarryTable do Wait(0) end
|
||||
@@ -117,17 +121,17 @@ function craftingMenu(data)
|
||||
setheader = ((metadata and metadata.label) or (Items[tostring(k)] and Items[tostring(k)].label) or "error - "..tostring(k))
|
||||
..(Recipes[i]["amount"] > 1 and " x"..Recipes[i]["amount"] or "")
|
||||
|
||||
local statusEmoji = disable and " ❌" or not canCarryTable[k] and " 📦" or " ✔️"
|
||||
local statusEmoji = disable and " " or not canCarryTable[k] and " 📦" or " ✔️"
|
||||
local isNew = (Recipes[i]["hasCrafted"] ~= nil and craftedItems[k] == nil) and "✨ " or ""
|
||||
setheader = isNew .. setheader .. statusEmoji
|
||||
|
||||
Menu[#Menu + 1] = {
|
||||
arrow = not disable and canCarryTable[k],
|
||||
arrow = isOx() and (not disable and canCarryTable[k]),
|
||||
isMenuHeader = disable or not canCarryTable[k],
|
||||
icon = invImg((metadata and metadata.image) or tostring(k)),
|
||||
image = invImg((metadata and metadata.image) or tostring(k)),
|
||||
header = setheader,
|
||||
txt = (isStarted(QBMenuExport) or disable) and settext or nil,
|
||||
txt = settext or nil,
|
||||
metadata = metaTable,
|
||||
onSelect = (not disable and canCarryTable[k]) and function()
|
||||
local transdata = {
|
||||
|
||||
@@ -493,7 +493,7 @@ end
|
||||
--- end
|
||||
--- ```
|
||||
function ensureNetToVeh(vehNetID)
|
||||
debugPrint("^6Bridge^7: ^3ensureNetToVeh^7: ^2Requesting NetworkDoesNetworkIdExist^7(^6"..vehNetID.."^7)")
|
||||
--debugPrint("^6Bridge^7: ^3ensureNetToVeh^7: ^2Requesting NetworkDoesNetworkIdExist^7(^6"..vehNetID.."^7)")
|
||||
local timeout = 100
|
||||
while not NetworkDoesNetworkIdExist(vehNetID) and timeout > 0 do
|
||||
timeout -= 1
|
||||
@@ -521,7 +521,7 @@ end
|
||||
--- end
|
||||
--- ```
|
||||
function ensureNetToEnt(entNetID)
|
||||
debugPrint("^6Bridge^7: ^3ensureNetToEnt^7: ^2Requesting NetworkDoesNetworkIdExist^7(^6"..entNetID.."^7)")
|
||||
--debugPrint("^6Bridge^7: ^3ensureNetToEnt^7: ^2Requesting NetworkDoesNetworkIdExist^7(^6"..entNetID.."^7)")
|
||||
local timeout = 100
|
||||
while not NetworkDoesNetworkIdExist(entNetID) and timeout > 0 do
|
||||
timeout -= 1
|
||||
|
||||
@@ -50,7 +50,7 @@ function hasItem(items, amount, src)
|
||||
|
||||
local count = 0
|
||||
for _, itemData in pairs(grabInv) do
|
||||
jsonPrint(itemData)
|
||||
--jsonPrint(itemData)
|
||||
if itemData and itemData.name == item then
|
||||
count += (itemData.amount or itemData.count or 1)
|
||||
end
|
||||
@@ -138,6 +138,14 @@ function getPlayerInv(src)
|
||||
grabInv = exports[TgiannInv]:GetPlayerItems()
|
||||
end
|
||||
|
||||
elseif isStarted(JPRInv) then
|
||||
foundInv = JPRInv
|
||||
if src then
|
||||
grabInv = Core.Functions.GetPlayer(src).PlayerData.items
|
||||
else
|
||||
grabInv = Core.Functions.GetPlayerData().items
|
||||
end
|
||||
|
||||
elseif isStarted(QBInv) then
|
||||
foundInv = QBInv
|
||||
if src then
|
||||
@@ -148,8 +156,11 @@ function getPlayerInv(src)
|
||||
|
||||
elseif isStarted(PSInv) then
|
||||
foundInv = PSInv
|
||||
if src then grabInv = Core.Functions.GetPlayer(src).PlayerData.items
|
||||
else grabInv = Core.Functions.GetPlayerData().items end
|
||||
if src then
|
||||
grabInv = Core.Functions.GetPlayer(src).PlayerData.items
|
||||
else
|
||||
grabInv = Core.Functions.GetPlayerData().items
|
||||
end
|
||||
|
||||
elseif ESX and isStarted(ESXExport) then
|
||||
foundInv = ESX
|
||||
@@ -179,41 +190,6 @@ function isInventoryOpen()
|
||||
|
||||
return IsNuiFocused()
|
||||
|
||||
--if isStarted(OXInv) then
|
||||
-- return LocalPlayer.state.invBusy
|
||||
|
||||
--elseif isStarted(QSInv) then
|
||||
-- return exports[QSInv]:inInventory()
|
||||
|
||||
--elseif isStarted(OrigenInv) then
|
||||
-- return exports[OrigenInv]:IsInventoryOpen()
|
||||
|
||||
--elseif isStarted(CoreInv) then
|
||||
-- return exports[CoreInv]:isInventoryOpen()
|
||||
|
||||
--elseif isStarted(CodeMInv) then
|
||||
-- return false
|
||||
-- -- CodeM doesn't have a function to check if the inventory is open
|
||||
-- -- No idea what it uses, so it just skips the check
|
||||
|
||||
--elseif isStarted(TgiannInv) then
|
||||
-- return IsNuiFocused()
|
||||
|
||||
--elseif isStarted(QBInv) then
|
||||
-- return LocalPlayer.state.inv_busy
|
||||
|
||||
--elseif isStarted(PSInv) then
|
||||
-- return LocalPlayer.state.inv_busy
|
||||
|
||||
--elseif ESX and isStarted(ESXExport) then
|
||||
-- return false
|
||||
|
||||
--elseif isStarted(RSGInv) then
|
||||
-- return LocalPlayer.state.inv_busy
|
||||
|
||||
--end
|
||||
|
||||
|
||||
end
|
||||
|
||||
-------------------------------------------------------------
|
||||
@@ -248,12 +224,14 @@ function invImg(item)
|
||||
elseif isStarted(OrigenInv) then
|
||||
imgLink = "nui://"..OrigenInv.."/html/img/"..(Items[item].image or "")
|
||||
|
||||
elseif isStarted(JPRInv) then
|
||||
imgLink = "nui://"..JPRInv.."/html/images/"..(Items[item].image or "")
|
||||
|
||||
elseif isStarted(QBInv) then
|
||||
imgLink = "nui://"..QBInv.."/html/images/"..(Items[item].image or "")
|
||||
|
||||
elseif isStarted(PSInv) then
|
||||
imgLink = "nui://"..PSInv.."/html/images/"..(Items[item].image or "")
|
||||
|
||||
elseif isStarted(TgiannInv) then
|
||||
imgLink = "nui://inventory_images/images/"..(Items[item].image or "")
|
||||
|
||||
|
||||
@@ -186,6 +186,20 @@ RegisterNetEvent(getScript()..":server:toggleItem", function(give, item, amount,
|
||||
invName = TgiannInv
|
||||
exports[TgiannInv]:RemoveItem(src, item, remamount)
|
||||
|
||||
elseif isStarted(JPRInv) then
|
||||
invName = JPRInv
|
||||
while remamount > 0 do
|
||||
if Core.Functions.GetPlayer(src).Functions.RemoveItem(item, 1, slot) then
|
||||
remamount -= 1
|
||||
else
|
||||
print("^1Error removing "..item.." Amount left: "..remamount)
|
||||
break
|
||||
end
|
||||
end
|
||||
if Config.Crafting ~= nil and Config.Crafting.showItemBox then
|
||||
TriggerClientEvent("inventory:client:ItemBox", src, Items[item], "remove", amount or 1)
|
||||
end
|
||||
|
||||
elseif isStarted(QBInv) then
|
||||
invName = QBInv
|
||||
while remamount > 0 do
|
||||
@@ -270,6 +284,13 @@ RegisterNetEvent(getScript()..":server:toggleItem", function(give, item, amount,
|
||||
elseif isStarted(TgiannInv) then invName = TgiannInv
|
||||
exports[TgiannInv]:AddItem(src, item, amountToAdd, slot, info)
|
||||
|
||||
elseif isStarted(JPRInv) then invName = JPRInv
|
||||
if Core.Functions.GetPlayer(src).Functions.AddItem(item, amountToAdd, nil, info) then
|
||||
if Config.Crafting ~= nil and Config.Crafting.showItemBox then
|
||||
TriggerClientEvent("ps-inventory:client:ItemBox", src, Items[item], "add", amountToAdd)
|
||||
end
|
||||
end
|
||||
|
||||
elseif isStarted(QBInv) then invName = QBInv
|
||||
if Core.Functions.GetPlayer(src).Functions.AddItem(item, amountToAdd, nil, info) then
|
||||
TriggerClientEvent((isStarted(QBInv) and QBInvNew and "qb-" or "").."inventory:client:ItemBox", src, Items[item], "add", amountToAdd)
|
||||
@@ -379,7 +400,7 @@ end
|
||||
function getDurability(item)
|
||||
local lowestSlot = 100
|
||||
local durability = nil
|
||||
if isStarted(QBInv) or isStarted(PSInv) or isStarted(RSGInv) then
|
||||
if isStarted(QBInv) or isStarted(PSInv) or isStarted(RSGInv) or isStarted(JPRInv) then
|
||||
local itemcheck = Core.Functions.GetPlayerData().items
|
||||
for k, v in pairs(itemcheck) do
|
||||
if v.name == item then
|
||||
@@ -488,7 +509,7 @@ end
|
||||
--- ```
|
||||
RegisterNetEvent(getScript()..":server:setMetaData", function(data)
|
||||
local src = source
|
||||
if isStarted(QBInv) or isStarted(PSInv) or isStarted(RSGInv) then
|
||||
if isStarted(QBInv) or isStarted(PSInv) or isStarted(RSGInv) or isStarted(JPRInv) then
|
||||
debugPrint(src, data.item, 1, data.slot)
|
||||
local Player = Core.Functions.GetPlayer(src)
|
||||
Player.PlayerData.items[data.slot].info = data.metadata
|
||||
@@ -626,6 +647,22 @@ function canCarry(itemTable, src)
|
||||
resultTable[k] = exports[TgiannInv]:CanCarryItem(source, k, v)
|
||||
end
|
||||
|
||||
elseif isStarted(JPRInv) then
|
||||
local items = getPlayerInv(src)
|
||||
local totalWeight = 0
|
||||
if not items then return false end
|
||||
for _, item in pairs(items) do
|
||||
totalWeight += (item.weight * item.amount)
|
||||
end
|
||||
for k, v in pairs(itemTable) do
|
||||
local itemInfo = Items[k]
|
||||
if not itemInfo then
|
||||
resultTable[k] = true
|
||||
else
|
||||
resultTable[k] = (totalWeight + (itemInfo.weight * v)) <= InventoryWeight
|
||||
end
|
||||
end
|
||||
|
||||
elseif isStarted(QBInv) then
|
||||
if QBInvNew then
|
||||
for k, v in pairs(itemTable) do
|
||||
|
||||
@@ -231,3 +231,16 @@ function useDoor(data)
|
||||
DoScreenFadeIn(1000)
|
||||
Wait(100)
|
||||
end
|
||||
|
||||
|
||||
function openBossMenu(isGang, group)
|
||||
if isStarted("qb-management") then
|
||||
if isGang then
|
||||
TriggerEvent("qb-gangmenu:client:OpenMenu")
|
||||
else
|
||||
TriggerEvent("qb-bossmenu:client:OpenMenu")
|
||||
end
|
||||
elseif isStarted("qbx_management") then
|
||||
exports["qbx_management"]:OpenBossMenu(isGang and "gang" or "job")
|
||||
end
|
||||
end
|
||||
@@ -43,9 +43,10 @@ function progressBar(data)
|
||||
local result = nil
|
||||
if data.cam then startTempCam(data.cam) end
|
||||
if Config.System.ProgressBar == "ox" then
|
||||
if exports[OXLibExport]:progressBar({
|
||||
local options = {
|
||||
duration = debugMode and 1000 or data.time,
|
||||
label = data.label,
|
||||
position = data.position or "bottom",
|
||||
useWhileDead = data.dead or false,
|
||||
canCancel = data.cancel and data.cancel or true,
|
||||
anim = {
|
||||
@@ -55,12 +56,41 @@ function progressBar(data)
|
||||
scenario = data.task
|
||||
},
|
||||
disable = {
|
||||
combat = true
|
||||
combat = data.combat or true,
|
||||
move = data.movement or false,
|
||||
car = data.carMovement or false,
|
||||
mouse = data.mouse or false
|
||||
},
|
||||
}) then
|
||||
result = true
|
||||
else
|
||||
result = false
|
||||
}
|
||||
if data.prop and data.prop.model then
|
||||
options.prop = {
|
||||
model = data.prop.model,
|
||||
pos = data.prop.pos or vec3(0, 0, 0),
|
||||
rot = data.prop.rot or vec3(0, 0, 0),
|
||||
bone = data.prop.bone or 0
|
||||
}
|
||||
end
|
||||
if data.propTwo and data.propTwo.model then
|
||||
options.propTwo = {
|
||||
model = data.propTwo.model,
|
||||
pos = data.propTwo.pos or vec3(0, 0, 0),
|
||||
rot = data.propTwo.rot or vec3(0, 0, 0),
|
||||
bone = data.propTwo.bone or 0
|
||||
}
|
||||
end
|
||||
if data.progressType == "circle" then
|
||||
if exports[OXLibExport]:progressCircle(options) then
|
||||
result = true
|
||||
else
|
||||
result = false
|
||||
end
|
||||
end
|
||||
if not data.progressType or data.progressType == "bar" then
|
||||
if exports[OXLibExport]:progressBar(options) then
|
||||
result = true
|
||||
else
|
||||
result = false
|
||||
end
|
||||
end
|
||||
|
||||
elseif Config.System.ProgressBar == "qb" then
|
||||
@@ -179,7 +209,9 @@ function progressBar(data)
|
||||
inProgress = false
|
||||
end
|
||||
|
||||
while result == nil do Wait(10) end
|
||||
while result == nil do
|
||||
Wait(10)
|
||||
end
|
||||
|
||||
-- Cleanup
|
||||
FreezeEntityPosition(ped, false)
|
||||
@@ -256,7 +288,7 @@ function stopProgressBar()
|
||||
exports[OXLibExport]:cancelProgress()
|
||||
elseif Config.System.ProgressBar == "qb" then
|
||||
TriggerEvent("progressbar:client:cancel")
|
||||
elseif Config.System.ProgressBar == "gta" then
|
||||
elseif Config.System.ProgressBar == "gta" or Config.System.ProgressBar == "red" then
|
||||
inProgress = false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -109,19 +109,18 @@ end)
|
||||
--- setThirst(playerId, 80)
|
||||
--- ```
|
||||
function setThirst(src, thirst)
|
||||
|
||||
debugPrint("^4Debug^7: ^2Adding thirst^7: ^3"..thirst.." ^2to player^7: ^3"..src.."^7")
|
||||
if isStarted(ESXExport) then
|
||||
TriggerClientEvent('esx_status:add', src, 'thirst', thirst)
|
||||
|
||||
elseif isStarted(QBExport) or isStarted(QBXExport) then
|
||||
elseif isStarted(QBExport) or isStarted(QBXExport) or isStarted(RSGExport) then
|
||||
local Player = Core.Functions.GetPlayer(src)
|
||||
Player.Functions.SetMetaData('thirst', thirst)
|
||||
TriggerClientEvent("hud:client:UpdateNeeds", src, thirst, Player.PlayerData.metadata.thirst)
|
||||
TriggerClientEvent("hud:client:UpdateNeeds", src, Player.PlayerData.metadata.hunger, thirst)
|
||||
|
||||
elseif isStarted(RSGExport) then
|
||||
local Player = Core.Functions.GetPlayer(src)
|
||||
Player.Functions.SetMetaData('thirst', thirst)
|
||||
TriggerClientEvent("hud:client:UpdateNeeds", src, thirst, Player.PlayerData.metadata.thirst)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--- Sets the player's hunger level.
|
||||
@@ -134,18 +133,16 @@ end
|
||||
--- setHunger(playerId, 60)
|
||||
--- ```
|
||||
function setHunger(src, hunger)
|
||||
|
||||
debugPrint("^4Debug^7: ^2Adding hunger^7: ^3"..hunger.." ^2to player^7: ^3"..src.."^7")
|
||||
if isStarted(ESXExport) then
|
||||
TriggerClientEvent('esx_status:add', src, 'hunger', hunger)
|
||||
|
||||
elseif isStarted(QBExport) or isStarted(QBXExport) then
|
||||
elseif isStarted(QBExport) or isStarted(QBXExport) or isStarted(RSGExport) then
|
||||
local Player = Core.Functions.GetPlayer(src)
|
||||
Player.Functions.SetMetaData('hunger', hunger)
|
||||
TriggerClientEvent("hud:client:UpdateNeeds", src, hunger, Player.PlayerData.metadata.hunger)
|
||||
TriggerClientEvent("hud:client:UpdateNeeds", src, hunger, Player.PlayerData.metadata.thirst)
|
||||
|
||||
elseif isStarted(RSGExport) then
|
||||
local Player = Core.Functions.GetPlayer(src)
|
||||
Player.Functions.SetMetaData('hunger', hunger)
|
||||
TriggerClientEvent("hud:client:UpdateNeeds", src, hunger, Player.PlayerData.metadata.hunger)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -151,6 +151,22 @@ function openStash(data)
|
||||
slots = data.slots or 40
|
||||
})
|
||||
|
||||
elseif isStarted(JPRInv) then
|
||||
if QBInvNew then
|
||||
TriggerServerEvent(getScript()..':server:openServerStash', {
|
||||
stashName = data.stash,
|
||||
label = data.label,
|
||||
maxweight = data.maxWeight or 600000,
|
||||
slots = data.slots or 40
|
||||
})
|
||||
else
|
||||
TriggerEvent("inventory:client:SetCurrentStash", data.stash)
|
||||
TriggerServerEvent("inventory:server:OpenInventory", "stash", data.stash, {
|
||||
slots = data.slots or 50,
|
||||
maxWeight = data.maxWeight or 600000
|
||||
})
|
||||
end
|
||||
|
||||
elseif isStarted(QBInv) then
|
||||
if QBInvNew then
|
||||
TriggerServerEvent(getScript()..':server:openServerStash', {
|
||||
@@ -211,6 +227,9 @@ RegisterNetEvent(getScript()..":server:openServerStash", function(data)
|
||||
if isStarted(TgiannInv) then
|
||||
exports[TgiannInv]:OpenInventory(source, 'stash', data.stashName, data)
|
||||
end
|
||||
if isStarted(JPRInv) then
|
||||
exports[JPRInv]:OpenInventory(source, data.stashName, data)
|
||||
end
|
||||
if isStarted(QBInv) then
|
||||
exports[QBInv]:OpenInventory(source, data.stashName, data)
|
||||
end
|
||||
@@ -223,7 +242,18 @@ RegisterNetEvent(getScript()..":server:openServerStash", function(data)
|
||||
end)
|
||||
|
||||
function clearStash(stashId)
|
||||
if isStarted(QBInv) then
|
||||
if isStarted(JPRInv) then
|
||||
debugPrint("^5Bridge^7: ^2Cleared ^3"..JPRInv.."^2 Stash^7", stashId)
|
||||
if QBInvNew then
|
||||
exports[JPRInv]:ClearStash(stashId)
|
||||
else
|
||||
MySQL.Async.insert('INSERT INTO stashitems (stash, items) VALUES (:stash, :items) ON DUPLICATE KEY UPDATE items = :items', {
|
||||
['stash'] = stashId,
|
||||
['items'] = json.encode({})
|
||||
})
|
||||
end
|
||||
|
||||
elseif isStarted(QBInv) then
|
||||
debugPrint("^5Bridge^7: ^2Cleared ^3"..QBInv.."^2 Stash^7", stashId)
|
||||
if QBInvNew then
|
||||
exports[QBInv]:ClearStash(stashId)
|
||||
@@ -241,7 +271,7 @@ function clearStash(stashId)
|
||||
elseif isStarted(PSInv) then
|
||||
debugPrint("^5Bridge^7: ^2Cleared ^3"..PSInv.."^2 Stash^7", stashId)
|
||||
if QBInvNew then
|
||||
exports[QBInv]:ClearStash(stashId)
|
||||
exports[PSInv]:ClearStash(stashId)
|
||||
else
|
||||
MySQL.Async.insert('INSERT INTO stashitems (stash, items) VALUES (:stash, :items) ON DUPLICATE KEY UPDATE items = :items', {
|
||||
['stash'] = stashId,
|
||||
@@ -249,6 +279,7 @@ function clearStash(stashId)
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
elseif isStarted(QSInv) then
|
||||
debugPrint("^5Bridge^7: ^2Cleared ^3"..QSInv.."^2 Stash^7", stashId)
|
||||
exports[QSInv]:ClearOtherInventory('stash', stashId)
|
||||
@@ -331,6 +362,11 @@ function getStash(stashName)
|
||||
local result = MySQL.scalar.await('SELECT items FROM stashitems WHERE stash = ?', { stashName })
|
||||
if result then stashItems = json.decode(result) end
|
||||
|
||||
elseif isStarted(JPRInv) then
|
||||
stashResource = JPRInv
|
||||
local result = MySQL.scalar.await('SELECT items FROM stashitems WHERE stash = ?', { stashName })
|
||||
if result then stashItems = json.decode(result) end
|
||||
|
||||
elseif isStarted(QBInv) then
|
||||
stashResource = QBInv
|
||||
if QBInvNew then
|
||||
@@ -449,6 +485,29 @@ function stashRemoveItem(stashItems, stashName, items)
|
||||
debugPrint("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..TgiannInv, k, v)
|
||||
end
|
||||
|
||||
elseif isStarted(JPRInv) then
|
||||
if not stashItems or not next(stashItems) then
|
||||
stashItems = getStash(stashName[1])
|
||||
end
|
||||
for k, v in pairs(items) do
|
||||
for l in pairs(stashItems) do
|
||||
if stashItems[l].name == k then
|
||||
if (stashItems[l].amount - v) <= 0 then
|
||||
debugPrint("^6Bridge^7: ^2None of this item left in stash ^3Stash^7", k, v)
|
||||
stashItems[l] = nil
|
||||
else
|
||||
debugPrint("^6Bridge^7: ^2Removing item from ^3Stash^2 with "..JPRInv, k, v)
|
||||
stashItems[l].amount -= v
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
debugPrint("^6Bridge^7: ^3saveStash^7: ^2Saving ^3JPR^2 stash '^6"..stashName[1].."^7'")
|
||||
MySQL.Async.insert('INSERT INTO stashitems (stash, items) VALUES (:stash, :items) ON DUPLICATE KEY UPDATE items = :items', {
|
||||
['stash'] = stashName[1],
|
||||
['items'] = json.encode(stashItems)
|
||||
})
|
||||
|
||||
elseif isStarted(QBInv) then
|
||||
if QBInvNew then
|
||||
for k, v in pairs(items) do
|
||||
@@ -531,7 +590,7 @@ RegisterNetEvent(getScript()..":server:stashRemoveItem", stashRemoveItem)
|
||||
--- local hasAll, details = stashhasItem(currentStashItems, { iron = 2, wood = 5 })
|
||||
--- ```
|
||||
function stashhasItem(stashItems, items, amount)
|
||||
local invs = { OXInv, QSInv, CoreInv, CodeMInv, OrigenInv, TgiannInv, QBInv, PSInv, RSGInv }
|
||||
local invs = { OXInv, QSInv, CoreInv, CodeMInv, OrigenInv, TgiannInv, JPRInv, QBInv, PSInv, RSGInv }
|
||||
local foundInv = ""
|
||||
for _, inv in ipairs(invs) do
|
||||
if isStarted(inv) then
|
||||
|
||||
Reference in New Issue
Block a user