mirror of
https://github.com/jimathy/jim_bridge.git
synced 2026-08-17 05:56:02 +01:00
Prefer export checks over QBInvNew
Small changes for JPRInv too
This commit is contained in:
@@ -69,6 +69,9 @@ local InvFunc = {
|
|||||||
function(data)
|
function(data)
|
||||||
exports[OXInv]:openInventory('shop', { type = data.shop })
|
exports[OXInv]:openInventory('shop', { type = data.shop })
|
||||||
end,
|
end,
|
||||||
|
serverOpenShop = function(shopName)
|
||||||
|
--
|
||||||
|
end,
|
||||||
registerShop =
|
registerShop =
|
||||||
function(name, label, items, society)
|
function(name, label, items, society)
|
||||||
exports[OXInv]:RegisterShop(name, {
|
exports[OXInv]:RegisterShop(name, {
|
||||||
@@ -168,6 +171,9 @@ local InvFunc = {
|
|||||||
function(data)
|
function(data)
|
||||||
TriggerServerEvent("inventory:server:OpenInventory", "shop", data.items.label, data.items)
|
TriggerServerEvent("inventory:server:OpenInventory", "shop", data.items.label, data.items)
|
||||||
end,
|
end,
|
||||||
|
serverOpenShop = function(shopName)
|
||||||
|
--
|
||||||
|
end,
|
||||||
registerShop =
|
registerShop =
|
||||||
function(name, label, items, society)
|
function(name, label, items, society)
|
||||||
--
|
--
|
||||||
@@ -258,6 +264,10 @@ local InvFunc = {
|
|||||||
function(data)
|
function(data)
|
||||||
--
|
--
|
||||||
end,
|
end,
|
||||||
|
serverOpenShop =
|
||||||
|
function(shopName)
|
||||||
|
--
|
||||||
|
end,
|
||||||
registerShop =
|
registerShop =
|
||||||
function(name, label, items, society)
|
function(name, label, items, society)
|
||||||
--
|
--
|
||||||
@@ -344,6 +354,10 @@ local InvFunc = {
|
|||||||
function(data)
|
function(data)
|
||||||
--
|
--
|
||||||
end,
|
end,
|
||||||
|
serverOpenShop =
|
||||||
|
function(shopName)
|
||||||
|
--
|
||||||
|
end,
|
||||||
registerShop =
|
registerShop =
|
||||||
function(name, label, items, society)
|
function(name, label, items, society)
|
||||||
--
|
--
|
||||||
@@ -442,6 +456,10 @@ local InvFunc = {
|
|||||||
function(data)
|
function(data)
|
||||||
TriggerEvent("codem-inventory:openshop", data.shop)
|
TriggerEvent("codem-inventory:openshop", data.shop)
|
||||||
end,
|
end,
|
||||||
|
serverOpenShop =
|
||||||
|
function(shopName)
|
||||||
|
--
|
||||||
|
end,
|
||||||
registerShop =
|
registerShop =
|
||||||
function(name, label, items, society)
|
function(name, label, items, society)
|
||||||
--
|
--
|
||||||
@@ -537,6 +555,10 @@ local InvFunc = {
|
|||||||
function(data)
|
function(data)
|
||||||
TriggerServerEvent(getScript()..':server:openServerShop', data.shop)
|
TriggerServerEvent(getScript()..':server:openServerShop', data.shop)
|
||||||
end,
|
end,
|
||||||
|
serverOpenShop =
|
||||||
|
function(shopName)
|
||||||
|
exports[TgiannInv]:OpenShop(source, shopName)
|
||||||
|
end,
|
||||||
registerShop =
|
registerShop =
|
||||||
function(name, label, items, society)
|
function(name, label, items, society)
|
||||||
exports[TgiannInv]:RegisterShop(name, items)
|
exports[TgiannInv]:RegisterShop(name, items)
|
||||||
@@ -666,6 +688,12 @@ local InvFunc = {
|
|||||||
TriggerServerEvent(getScript()..':server:openServerShop', data.shop)
|
TriggerServerEvent(getScript()..':server:openServerShop', data.shop)
|
||||||
TriggerServerEvent("inventory:server:OpenInventory", "shop", data.items.label, data.items)
|
TriggerServerEvent("inventory:server:OpenInventory", "shop", data.items.label, data.items)
|
||||||
end,
|
end,
|
||||||
|
serverOpenShop =
|
||||||
|
function(shopName)
|
||||||
|
if checkExportExists(JPRInv, "OpenShop") then
|
||||||
|
exports[JPRInv]:OpenShop(source, shopName)
|
||||||
|
end
|
||||||
|
end,
|
||||||
registerShop =
|
registerShop =
|
||||||
function(name, label, items, society)
|
function(name, label, items, society)
|
||||||
exports[JPRInv]:CreateShop({
|
exports[JPRInv]:CreateShop({
|
||||||
@@ -701,11 +729,11 @@ local InvFunc = {
|
|||||||
end,
|
end,
|
||||||
getStash =
|
getStash =
|
||||||
function(stashName)
|
function(stashName)
|
||||||
local result = MySQL.scalar.await('SELECT items FROM stashitems WHERE stash = ?', { stashName })
|
if checkExportExists(JPRInv, "GetStashItems") then
|
||||||
if result then
|
return exports[JPRInv]:GetStashItems(stashName) or {}
|
||||||
return json.decode(result)
|
|
||||||
else
|
else
|
||||||
return {}
|
local result = MySQL.scalar.await('SELECT items FROM stashitems WHERE stash = ?', { stashName })
|
||||||
|
return result and json.decode(result) or {}
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
stashAddItem =
|
stashAddItem =
|
||||||
@@ -778,7 +806,7 @@ local InvFunc = {
|
|||||||
canCarry =
|
canCarry =
|
||||||
function(itemTable, src)
|
function(itemTable, src)
|
||||||
local resultTable = {}
|
local resultTable = {}
|
||||||
if QBInvNew then
|
if checkExportExists(QBInv, "CanAddItem") then
|
||||||
for k, v in pairs(itemTable) do
|
for k, v in pairs(itemTable) do
|
||||||
resultTable[k] = exports[QBInv]:CanAddItem(src, k, v)
|
resultTable[k] = exports[QBInv]:CanAddItem(src, k, v)
|
||||||
end
|
end
|
||||||
@@ -827,6 +855,12 @@ local InvFunc = {
|
|||||||
TriggerServerEvent(getScript()..':server:openServerShop', data.shop)
|
TriggerServerEvent(getScript()..':server:openServerShop', data.shop)
|
||||||
TriggerServerEvent("inventory:server:OpenInventory", "shop", data.items.label, data.items)
|
TriggerServerEvent("inventory:server:OpenInventory", "shop", data.items.label, data.items)
|
||||||
end,
|
end,
|
||||||
|
serverOpenShop =
|
||||||
|
function(shopName)
|
||||||
|
if checkExportExists(QBInv, "OpenShop") then
|
||||||
|
exports[QBInv]:OpenShop(source, shopName)
|
||||||
|
end
|
||||||
|
end,
|
||||||
registerShop =
|
registerShop =
|
||||||
function(name, label, items, society)
|
function(name, label, items, society)
|
||||||
if checkExportExists(QBInv, "CreateShop") then
|
if checkExportExists(QBInv, "CreateShop") then
|
||||||
@@ -859,7 +893,7 @@ local InvFunc = {
|
|||||||
end,
|
end,
|
||||||
clearStash =
|
clearStash =
|
||||||
function(stashId)
|
function(stashId)
|
||||||
if QBInvNew then
|
if checkExportExists(QBInv, "ClearStash") then
|
||||||
exports[QBInv]:ClearStash(stashId)
|
exports[QBInv]:ClearStash(stashId)
|
||||||
else
|
else
|
||||||
MySQL.Async.insert('INSERT INTO stashitems (stash, items) VALUES (:stash, :items) ON DUPLICATE KEY UPDATE items = :items', {
|
MySQL.Async.insert('INSERT INTO stashitems (stash, items) VALUES (:stash, :items) ON DUPLICATE KEY UPDATE items = :items', {
|
||||||
@@ -888,7 +922,7 @@ local InvFunc = {
|
|||||||
end,
|
end,
|
||||||
stashRemoveItem =
|
stashRemoveItem =
|
||||||
function(stashItems, stashName, items)
|
function(stashItems, stashName, items)
|
||||||
if QBInvNew then
|
if checkExportExists(QBInv, "RemoveItem") then
|
||||||
for k, v in pairs(items) do
|
for k, v in pairs(items) do
|
||||||
exports[QBInv]:RemoveItem(stashName, k, v, false, 'crafting')
|
exports[QBInv]:RemoveItem(stashName, k, v, false, 'crafting')
|
||||||
debugPrint("^6Bridge^7: ^2Removing ^3"..QBInv.." ^2Stash item^7:", k, v)
|
debugPrint("^6Bridge^7: ^2Removing ^3"..QBInv.." ^2Stash item^7:", k, v)
|
||||||
@@ -1011,6 +1045,12 @@ local InvFunc = {
|
|||||||
TriggerServerEvent(getScript()..':server:openServerShop', data.shop)
|
TriggerServerEvent(getScript()..':server:openServerShop', data.shop)
|
||||||
TriggerServerEvent("inventory:server:OpenInventory", "shop", data.items.label, data.items)
|
TriggerServerEvent("inventory:server:OpenInventory", "shop", data.items.label, data.items)
|
||||||
end,
|
end,
|
||||||
|
serverOpenShop =
|
||||||
|
function(shopName)
|
||||||
|
if checkExportExists(PSInv, "OpenShop") then
|
||||||
|
exports[PSInv]:OpenShop(source, shopName)
|
||||||
|
end
|
||||||
|
end,
|
||||||
registerShop =
|
registerShop =
|
||||||
function(name, label, items, society)
|
function(name, label, items, society)
|
||||||
if checkExportExists(PSInv, "CreateShop") then
|
if checkExportExists(PSInv, "CreateShop") then
|
||||||
@@ -1165,6 +1205,10 @@ local InvFunc = {
|
|||||||
function(data)
|
function(data)
|
||||||
TriggerServerEvent(getScript()..':server:openServerShop', data.shop)
|
TriggerServerEvent(getScript()..':server:openServerShop', data.shop)
|
||||||
end,
|
end,
|
||||||
|
serverOpenShop =
|
||||||
|
function(shopName)
|
||||||
|
exports[RSGInv]:OpenShop(source, shopName)
|
||||||
|
end,
|
||||||
registerShop =
|
registerShop =
|
||||||
function(name, label, items, society)
|
function(name, label, items, society)
|
||||||
exports[RSGInv]:CreateShop({
|
exports[RSGInv]:CreateShop({
|
||||||
@@ -2508,18 +2552,12 @@ function openShop(data)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
RegisterNetEvent(getScript()..':server:openServerShop', function(data)
|
RegisterNetEvent(getScript()..':server:openServerShop', function(shopName)
|
||||||
if isStarted(QBInv) and checkExportExists(QBInv, "OpenShop") then
|
for _, inv in ipairs(InvFunc) do
|
||||||
exports[QBInv]:OpenShop(source, data)
|
if isStarted(inv.invName) then
|
||||||
end
|
inv.serverOpenShop(shopName)
|
||||||
if isStarted(PSInv) and checkExportExists(PSInv, "OpenShop") then
|
break
|
||||||
exports[PSInv]:OpenShop(source, data)
|
end
|
||||||
end
|
|
||||||
if isStarted(TgiannInv) then
|
|
||||||
exports[TgiannInv]:OpenShop(source, data)
|
|
||||||
end
|
|
||||||
if isStarted(RSGInv) then
|
|
||||||
exports[RSGInv]:OpenShop(source, data)
|
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user