mirror of
https://github.com/jimathy/jim_bridge.git
synced 2026-08-17 05:56:02 +01:00
Tgiann Inv support added
This commit is contained in:
@@ -27,14 +27,15 @@ OXLibExport, QBXExport, QBExport, ESXExport, OXCoreExport =
|
|||||||
Exports.ESXExport or "",
|
Exports.ESXExport or "",
|
||||||
Exports.OXCoreExport or ""
|
Exports.OXCoreExport or ""
|
||||||
|
|
||||||
OXInv, QBInv, PSInv, QSInv, CoreInv, CodeMInv, OrigenInv =
|
OXInv, QBInv, PSInv, QSInv, CoreInv, CodeMInv, OrigenInv, TgiannInv =
|
||||||
Exports.OXInv or "",
|
Exports.OXInv or "",
|
||||||
Exports.QBInv or "",
|
Exports.QBInv or "",
|
||||||
Exports.PSInv or "",
|
Exports.PSInv or "",
|
||||||
Exports.QSInv or "",
|
Exports.QSInv or "",
|
||||||
Exports.CoreInv or "",
|
Exports.CoreInv or "",
|
||||||
Exports.CodeMInv or "",
|
Exports.CodeMInv or "",
|
||||||
Exports.OrigenInv or ""
|
Exports.OrigenInv or "",
|
||||||
|
Exports.TgiannInv or ""
|
||||||
|
|
||||||
RSGExport, RSGInv =
|
RSGExport, RSGInv =
|
||||||
Exports.RSGExport or "",
|
Exports.RSGExport or "",
|
||||||
|
|||||||
@@ -125,6 +125,14 @@ function getPlayerInv(src)
|
|||||||
grabInv = exports[CodeMInv]:getUserInventory()
|
grabInv = exports[CodeMInv]:getUserInventory()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
elseif isStarted(TgiannInv) then
|
||||||
|
foundInv = TgiannInv
|
||||||
|
if src then
|
||||||
|
grabInv = exports[TgiannInv]:GetPlayerItems(src)
|
||||||
|
else
|
||||||
|
grabInv = exports[TgiannInv]:GetPlayerItems()
|
||||||
|
end
|
||||||
|
|
||||||
elseif isStarted(QBInv) then
|
elseif isStarted(QBInv) then
|
||||||
foundInv = QBInv
|
foundInv = QBInv
|
||||||
if src then
|
if src then
|
||||||
|
|||||||
@@ -64,18 +64,28 @@ function invImg(item)
|
|||||||
if item ~= "" and Items[item] then
|
if item ~= "" and Items[item] then
|
||||||
if isStarted(OXInv) then
|
if isStarted(OXInv) then
|
||||||
imgLink = "nui://"..OXInv.."/web/images/"..(Items[item].image or "")
|
imgLink = "nui://"..OXInv.."/web/images/"..(Items[item].image or "")
|
||||||
|
|
||||||
elseif isStarted(QSInv) then
|
elseif isStarted(QSInv) then
|
||||||
imgLink = "nui://"..QSInv.."/html/images/"..(Items[item].image or "")
|
imgLink = "nui://"..QSInv.."/html/images/"..(Items[item].image or "")
|
||||||
|
|
||||||
elseif isStarted(CoreInv) then
|
elseif isStarted(CoreInv) then
|
||||||
imgLink = "nui://"..CoreInv.."/html/img/"..(Items[item].image or "")
|
imgLink = "nui://"..CoreInv.."/html/img/"..(Items[item].image or "")
|
||||||
|
|
||||||
elseif isStarted(CodeMInv) then
|
elseif isStarted(CodeMInv) then
|
||||||
imgLink = "nui://"..CodeMInv.."/html/itemimages/"..(Items[item].image or "")
|
imgLink = "nui://"..CodeMInv.."/html/itemimages/"..(Items[item].image or "")
|
||||||
|
|
||||||
elseif isStarted(OrigenInv) then
|
elseif isStarted(OrigenInv) then
|
||||||
imgLink = "nui://"..OrigenInv.."/html/img/"..(Items[item].image or "")
|
imgLink = "nui://"..OrigenInv.."/html/img/"..(Items[item].image or "")
|
||||||
|
|
||||||
elseif isStarted(QBInv) then
|
elseif isStarted(QBInv) then
|
||||||
imgLink = "nui://"..QBInv.."/html/images/"..(Items[item].image or "")
|
imgLink = "nui://"..QBInv.."/html/images/"..(Items[item].image or "")
|
||||||
|
|
||||||
|
elseif isStarted(TgiannInv) then
|
||||||
|
imgLink = "nui://inventory_images/images/"..(Items[item].image or "")
|
||||||
|
|
||||||
elseif isStarted(RSGInv) then
|
elseif isStarted(RSGInv) then
|
||||||
imgLink = "nui://"..RSGInv.."/html/images/"..(Items[item].image or "")
|
imgLink = "nui://"..RSGInv.."/html/images/"..(Items[item].image or "")
|
||||||
|
|
||||||
else
|
else
|
||||||
print("^4ERROR^7: ^2No Inventory detected for invImg - Check starter.lua")
|
print("^4ERROR^7: ^2No Inventory detected for invImg - Check starter.lua")
|
||||||
end
|
end
|
||||||
@@ -219,6 +229,9 @@ RegisterNetEvent(getScript()..":server:toggleItem", function(give, item, amount,
|
|||||||
elseif isStarted(CodeMInv) then invName = CodeMInv
|
elseif isStarted(CodeMInv) then invName = CodeMInv
|
||||||
exports[CodeMInv]:RemoveItem(src, item, remamount)
|
exports[CodeMInv]:RemoveItem(src, item, remamount)
|
||||||
|
|
||||||
|
elseif isStarted(TgiannInv) then invName = TgiannInv
|
||||||
|
exports[TgiannInv]:RemoveItem(src, item, remamount)
|
||||||
|
|
||||||
elseif isStarted(QBInv) then invName = QBInv
|
elseif isStarted(QBInv) then invName = QBInv
|
||||||
while remamount > 0 do
|
while remamount > 0 do
|
||||||
if Core.Functions.GetPlayer(src).Functions.RemoveItem(item, 1, slot) then
|
if Core.Functions.GetPlayer(src).Functions.RemoveItem(item, 1, slot) then
|
||||||
@@ -296,6 +309,9 @@ RegisterNetEvent(getScript()..":server:toggleItem", function(give, item, amount,
|
|||||||
elseif isStarted(OrigenInv) then invName = OrigenInv
|
elseif isStarted(OrigenInv) then invName = OrigenInv
|
||||||
exports[OrigenInv]:addItem(src, item, amountToAdd, info, slot)
|
exports[OrigenInv]:addItem(src, item, amountToAdd, info, slot)
|
||||||
|
|
||||||
|
elseif isStarted(TgiannInv) then invName = TgiannInv
|
||||||
|
exports[TgiannInv]:AddItem(src, item, amountToAdd, slot, info)
|
||||||
|
|
||||||
elseif isStarted(QBInv) then invName = QBInv
|
elseif isStarted(QBInv) then invName = QBInv
|
||||||
if Core.Functions.GetPlayer(src).Functions.AddItem(item, amountToAdd, nil, info) then
|
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)
|
TriggerClientEvent((isStarted(QBInv) and QBInvNew and "qb-" or "").."inventory:client:ItemBox", src, Items[item], "add", amountToAdd)
|
||||||
@@ -467,6 +483,16 @@ function getDurability(item)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if isStarted(TgiannInv) then
|
||||||
|
local itemcheck = exports[TgiannInv]:GetPlayerItems()
|
||||||
|
for _, v in pairs(itemcheck) do
|
||||||
|
if v.name == item and v.slot <= lowestSlot then
|
||||||
|
lowestSlot = v.slot
|
||||||
|
durability = v.metadata.durability
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- For ESX default inventory (es_extended)
|
-- For ESX default inventory (es_extended)
|
||||||
if ESX and isStarted(ESXExport) then
|
if ESX and isStarted(ESXExport) then
|
||||||
local xPlayer = ESX.GetPlayerData() or {}
|
local xPlayer = ESX.GetPlayerData() or {}
|
||||||
@@ -524,6 +550,9 @@ RegisterNetEvent(getScript()..":server:setMetaData", function(data)
|
|||||||
|
|
||||||
elseif isStarted(OrigenInv) then
|
elseif isStarted(OrigenInv) then
|
||||||
exports[OrigenInv]:setMetadata(src, data.slot, data.metadata)
|
exports[OrigenInv]:setMetadata(src, data.slot, data.metadata)
|
||||||
|
|
||||||
|
elseif isStarted(TgiannInv) then
|
||||||
|
exports[TgiannInv]:UpdateItemMetadata(src, data.item, data.slot, data.metadata)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -633,6 +662,11 @@ function canCarry(itemTable, src)
|
|||||||
resultTable[k] = exports[OrigenInv]:canCarryItem(src, k, v)
|
resultTable[k] = exports[OrigenInv]:canCarryItem(src, k, v)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
elseif isStarted(TgiannInv) then
|
||||||
|
for k, v in pairs(itemTable) do
|
||||||
|
resultTable[k] = exports[TgiannInv]:CanCarryItem(source, k, v)
|
||||||
|
end
|
||||||
|
|
||||||
elseif isStarted(QBInv) then
|
elseif isStarted(QBInv) 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)
|
||||||
|
|||||||
@@ -78,6 +78,11 @@ function sendPhoneMail(data)
|
|||||||
TriggerServerEvent(getScript()..":jpr:SendMail", mailData)
|
TriggerServerEvent(getScript()..":jpr:SendMail", mailData)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
{ name = "ef-phone",
|
||||||
|
send = function(mailData)
|
||||||
|
TriggerServerEvent('qb-phone:server:sendNewMail', mailData)
|
||||||
|
end,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local activePhone = nil
|
local activePhone = nil
|
||||||
|
|||||||
@@ -160,6 +160,9 @@ function openShop(data)
|
|||||||
elseif isStarted(QSInv) then
|
elseif isStarted(QSInv) then
|
||||||
TriggerServerEvent("inventory:server:OpenInventory", "shop", data.items.label, data.items)
|
TriggerServerEvent("inventory:server:OpenInventory", "shop", data.items.label, data.items)
|
||||||
|
|
||||||
|
elseif isStarted(TgiannInv) then
|
||||||
|
TriggerServerEvent(getScript()..':server:OpenShopTgiann', data.shop)
|
||||||
|
|
||||||
elseif isStarted(QBInv) then
|
elseif isStarted(QBInv) then
|
||||||
if QBInvNew then
|
if QBInvNew then
|
||||||
TriggerServerEvent(getScript()..':server:OpenShopNewQB', data.shop)
|
TriggerServerEvent(getScript()..':server:OpenShopNewQB', data.shop)
|
||||||
@@ -168,17 +171,20 @@ function openShop(data)
|
|||||||
end
|
end
|
||||||
|
|
||||||
elseif isStarted(RSGInv) then
|
elseif isStarted(RSGInv) then
|
||||||
TriggerServerEvent(getScript()..':server:OpenShopNewRSG', data.shop)
|
TriggerServerEvent(getScript()..':server:OpenShopRSG', data.shop)
|
||||||
end
|
end
|
||||||
lookEnt(data.coords)
|
lookEnt(data.coords)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Server event handler for opening a shop using the new QB inventory system.
|
|
||||||
RegisterNetEvent(getScript()..':server:OpenShopNewQB', function(data)
|
RegisterNetEvent(getScript()..':server:OpenShopNewQB', function(data)
|
||||||
exports[QBInv]:OpenShop(source, data)
|
exports[QBInv]:OpenShop(source, data)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNetEvent(getScript()..':server:OpenShopNewRSG', function(data)
|
RegisterNetEvent(getScript()..':server:OpenShopTgiann', function(data)
|
||||||
|
exports[TgiannInv]:OpenShop(source, data)
|
||||||
|
end)
|
||||||
|
|
||||||
|
RegisterNetEvent(getScript()..':server:OpenShopRSG', function(data)
|
||||||
exports[RSGInv]:OpenShop(source, data)
|
exports[RSGInv]:OpenShop(source, data)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -201,6 +207,11 @@ function registerShop(name, label, items, society)
|
|||||||
inventory = items,
|
inventory = items,
|
||||||
society = society,
|
society = society,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
elseif isStarted(TgiannInv) then
|
||||||
|
debugPrint("^6Bridge^7: ^2Registering ^3Tgiann ^2Store^7:", name, label)
|
||||||
|
exports[TgiannInv]:RegisterShop(name, items)
|
||||||
|
|
||||||
elseif isStarted(QBInv) and QBInvNew then
|
elseif isStarted(QBInv) and QBInvNew then
|
||||||
debugPrint("^6Bridge^7: ^2Registering ^3QB ^2Store^7:", name, label)
|
debugPrint("^6Bridge^7: ^2Registering ^3QB ^2Store^7:", name, label)
|
||||||
exports[QBInv]:CreateShop({
|
exports[QBInv]:CreateShop({
|
||||||
|
|||||||
@@ -151,6 +151,14 @@ function openStash(data)
|
|||||||
elseif isStarted(OrigenInv) then
|
elseif isStarted(OrigenInv) then
|
||||||
exports[OrigenInv]:openInventory('stash', data.stash, { label = data.label })
|
exports[OrigenInv]:openInventory('stash', data.stash, { label = data.label })
|
||||||
|
|
||||||
|
elseif isStarted(TgiannInv) then
|
||||||
|
TriggerServerEvent(getScript()..':server:OpenStashTgiann', {
|
||||||
|
stashName = data.stash,
|
||||||
|
label = data.label,
|
||||||
|
maxweight = data.maxWeight or 600000,
|
||||||
|
slots = data.slots or 40
|
||||||
|
})
|
||||||
|
|
||||||
elseif isStarted(QBInv) then
|
elseif isStarted(QBInv) then
|
||||||
if QBInvNew then
|
if QBInvNew then
|
||||||
TriggerServerEvent(getScript()..':server:OpenStashQB', {
|
TriggerServerEvent(getScript()..':server:OpenStashQB', {
|
||||||
@@ -181,7 +189,10 @@ function openStash(data)
|
|||||||
lookEnt(data.coords)
|
lookEnt(data.coords)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Register an event for opening QB stashes.
|
RegisterNetEvent(getScript()..':server:OpenStashTgiann', function(data)
|
||||||
|
exports[TgiannInv]:OpenInventory(source, 'stash', data.stashName, data)
|
||||||
|
end)
|
||||||
|
|
||||||
RegisterNetEvent(getScript()..':server:OpenStashQB', function(data)
|
RegisterNetEvent(getScript()..':server:OpenStashQB', function(data)
|
||||||
exports[QBInv]:OpenInventory(source, data.stashName, data)
|
exports[QBInv]:OpenInventory(source, data.stashName, data)
|
||||||
end)
|
end)
|
||||||
@@ -234,6 +245,10 @@ function getStash(stashName)
|
|||||||
stashResource = OrigenInv
|
stashResource = OrigenInv
|
||||||
stashItems = exports[OrigenInv]:getInventory(stashName)
|
stashItems = exports[OrigenInv]:getInventory(stashName)
|
||||||
|
|
||||||
|
elseif isStarted(TgiannInv) then
|
||||||
|
stashResource = TgiannInv
|
||||||
|
stashItems = exports[TgiannInv]:GetSecondaryInventoryItems("stash", stashName)
|
||||||
|
|
||||||
elseif isStarted(PSInv) then
|
elseif isStarted(PSInv) then
|
||||||
stashResource = PSInv
|
stashResource = PSInv
|
||||||
local result = MySQL.scalar.await('SELECT items FROM stashitems WHERE stash = ?', { stashName })
|
local result = MySQL.scalar.await('SELECT items FROM stashitems WHERE stash = ?', { stashName })
|
||||||
@@ -330,7 +345,7 @@ function stashRemoveItem(stashItems, stashName, items)
|
|||||||
|
|
||||||
elseif isStarted(CoreInv) then
|
elseif isStarted(CoreInv) then
|
||||||
for k, v in pairs(items) do
|
for k, v in pairs(items) do
|
||||||
exports[CoreInv]:removeItemExact(stashName, k, v)
|
exports[CoreInv]:removeItemExact(stashName[1], k, v)
|
||||||
debugPrint("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..CoreInv, k, v)
|
debugPrint("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..CoreInv, k, v)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -348,15 +363,22 @@ function stashRemoveItem(stashItems, stashName, items)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
exports[CodeMInv]:UpdateStash(stashName, stashItems)
|
exports[CodeMInv]:UpdateStash(stashName[1], stashItems)
|
||||||
debugPrint("^6Bridge^7: ^3saveStash^7: ^2Saving ^3CodeM^2 stash ^7'^6"..stashName.."^7'")
|
debugPrint("^6Bridge^7: ^3saveStash^7: ^2Saving ^3CodeM^2 stash ^7'^6"..stashName.."^7'")
|
||||||
|
|
||||||
elseif isStarted(OrigenInv) then
|
elseif isStarted(OrigenInv) then
|
||||||
for k, v in pairs(items) do
|
for k, v in pairs(items) do
|
||||||
exports[OrigenInv]:RemoveFromStash(stashName, k, v)
|
exports[OrigenInv]:RemoveFromStash(stashName[1], k, v)
|
||||||
debugPrint("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..OrigenInv, k, v)
|
debugPrint("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..OrigenInv, k, v)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
elseif isStarted(TgiannInv) then
|
||||||
|
for k, v in pairs(items) do
|
||||||
|
local itemData = exports["tgiann-inventory"]:GetItemByNameFromSecondaryInventory("stash", stashName[1], k)
|
||||||
|
exports[TgiannInv]:RemoveItemFromSecondaryInventory("stash", stashName[1], k, v, itemData.slot, nil)
|
||||||
|
debugPrint("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..TgiannInv, k, v)
|
||||||
|
end
|
||||||
|
|
||||||
elseif isStarted(PSInv) then
|
elseif isStarted(PSInv) then
|
||||||
for k, v in pairs(items) do
|
for k, v in pairs(items) do
|
||||||
for l in pairs(stashItems) do
|
for l in pairs(stashItems) do
|
||||||
@@ -409,6 +431,16 @@ function stashRemoveItem(stashItems, stashName, items)
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
elseif isStarted(RSGInv) then
|
||||||
|
for k, v in pairs(items) do
|
||||||
|
exports[RSGInv]:RemoveItem(stashName[1], k, v, false, 'crafting')
|
||||||
|
debugPrint("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..RSGInv, k, v)
|
||||||
|
end
|
||||||
|
debugPrint("^6Bridge^7: ^3saveStash^7: ^2Saving ^3QB^2 stash ^7'^6"..stashName[1].."^7'")
|
||||||
|
MySQL.Async.insert('INSERT INTO inventories (identifier, items) VALUES (:stash, :items) ON DUPLICATE KEY UPDATE items = :items', {
|
||||||
|
['stash'] = stashName[1],
|
||||||
|
['items'] = json.encode(stashItems)
|
||||||
|
})
|
||||||
else
|
else
|
||||||
print("^4ERROR^7: ^2No Inventory detected ^7- ^2Check ^3starter^1.^2lua^7")
|
print("^4ERROR^7: ^2No Inventory detected ^7- ^2Check ^3starter^1.^2lua^7")
|
||||||
end
|
end
|
||||||
@@ -433,7 +465,7 @@ RegisterNetEvent(getScript()..":server:stashRemoveItem", stashRemoveItem)
|
|||||||
--- local hasAll, details = stashhasItem(currentStashItems, { iron = 2, wood = 5 })
|
--- local hasAll, details = stashhasItem(currentStashItems, { iron = 2, wood = 5 })
|
||||||
--- ```
|
--- ```
|
||||||
function stashhasItem(stashItems, items, amount)
|
function stashhasItem(stashItems, items, amount)
|
||||||
local invs = { OXInv, QSInv, CoreInv, CodeMInv, OrigenInv, QBInv, PSInv }
|
local invs = { OXInv, QSInv, CoreInv, CodeMInv, OrigenInv, TgiannInv, QBInv, PSInv, RSGInv }
|
||||||
local foundInv = ""
|
local foundInv = ""
|
||||||
for _, inv in ipairs(invs) do
|
for _, inv in ipairs(invs) do
|
||||||
if isStarted(inv) then
|
if isStarted(inv) then
|
||||||
|
|||||||
@@ -70,6 +70,10 @@ function registerStash(name, label, slots, weight, owner, coords)
|
|||||||
elseif isStarted(OrigenInv) then
|
elseif isStarted(OrigenInv) then
|
||||||
debugPrint("^6Bridge^7: ^2Registering ^3OrigenInv ^2Stash^7:", name, label)
|
debugPrint("^6Bridge^7: ^2Registering ^3OrigenInv ^2Stash^7:", name, label)
|
||||||
exports["origen_inventory"]:registerStash(name, label, slots or 50, weight or 4000000)
|
exports["origen_inventory"]:registerStash(name, label, slots or 50, weight or 4000000)
|
||||||
|
|
||||||
|
elseif isStarted(TgiannInv) then
|
||||||
|
debugPrint("^6Bridge^7: ^2Registering ^3TgiannInv ^2Stash^7:", name, label)
|
||||||
|
exports[TgiannInv]:RegisterStash(name, label, slots or 50, weight or 4000000)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ Exports = {
|
|||||||
CoreInv = "core_inventory",
|
CoreInv = "core_inventory",
|
||||||
CodeMInv = "codem-inventory",
|
CodeMInv = "codem-inventory",
|
||||||
OrigenInv = "origen_inventory",
|
OrigenInv = "origen_inventory",
|
||||||
|
TgiannInv = "tgiann-inventory",
|
||||||
|
|
||||||
OXLibExport = "ox_lib",
|
OXLibExport = "ox_lib",
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user