mirror of
https://github.com/jimathy/jim_bridge.git
synced 2026-08-17 05:56:02 +01:00
Compare commits
39 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
15bea85bfb | ||
|
|
f889080bc0 | ||
|
|
7d62358558 | ||
|
|
f7a7e89c56 | ||
|
|
5f6720d37b | ||
|
|
e541201a08 | ||
|
|
2bf04f69cf | ||
|
|
8479aea1b0 | ||
|
|
d17a1da5b2 | ||
|
|
f1ff06c098 | ||
|
|
df785043e8 | ||
|
|
5ae4799a5f | ||
|
|
8cf4a6bd23 | ||
|
|
3e067c8492 | ||
|
|
6847639c65 | ||
|
|
0592c3ebc8 | ||
|
|
2ca1cbd110 | ||
|
|
8642733b78 | ||
|
|
5a4293182c | ||
|
|
6075878038 | ||
|
|
7eaeac886f | ||
|
|
fe27a1ca1c | ||
|
|
0caea0b473 | ||
|
|
370c77433b | ||
|
|
ac85d35097 | ||
|
|
85c3e06910 | ||
|
|
7d0736bfc2 | ||
|
|
b0b011ac56 | ||
|
|
23091c2e73 | ||
|
|
ef2ba3ea7a | ||
|
|
df60f3b2b1 | ||
|
|
4cc001d2f0 | ||
|
|
e2bb32d9de | ||
|
|
725125a274 | ||
|
|
dcf2018ec6 | ||
|
|
e5316f45aa | ||
|
|
02c202d075 | ||
|
|
9e9fb14f55 | ||
|
|
63c2d5d83d |
@@ -21,6 +21,7 @@ But I want this script to grow with help of others who know more about other cor
|
||||
---
|
||||
|
||||
The installation of this script is simple
|
||||
- REMOVE `-main` from the folder name, like any other github hosted script
|
||||
- it just needs to start before any script that requires it
|
||||
- it can start before core scripts if you want
|
||||
- for `qb-core` I personally place this script in `resources > [standalone]`
|
||||
|
||||
407
crafting.lua
407
crafting.lua
@@ -43,26 +43,22 @@ function craftingMenu(data) local hasjob = false
|
||||
if Recipes[i].job then hasjob = false
|
||||
for l, b in pairs(Recipes[i].job) do
|
||||
hasjob = hasJob(l, nil, b)
|
||||
if hasJob == true then break end
|
||||
if hasjob == true then break end
|
||||
end
|
||||
end
|
||||
local setheader, settext = "", ""
|
||||
local disable = false
|
||||
local checktable = {}
|
||||
if Recipes[i].job and hasjob == false then else
|
||||
local itemTable = {}
|
||||
for l, b in pairs(Recipes[i][tostring(k)]) do
|
||||
if not Items[l] then print("^3Error^7: ^2Script can't find ingredient item in Shared Items - ^1"..l.."^7") return end
|
||||
settext = settext..(settext ~= "" and br or "")..Items[l].label..(b > 1 and " x"..b or "")
|
||||
if data.stashName then checktable[l] = stashhasItem(stashItems, l, b)
|
||||
else checktable[l] = hasItem(l, b) end
|
||||
settext = settext..(settext ~= "" and br or "")..(Items[l] and Items[l].label or "error - "..l)..(b > 1 and " x"..b or "")
|
||||
itemTable[l] = b
|
||||
Wait(0)
|
||||
end
|
||||
for _, v in pairs(checktable) do
|
||||
if not v then
|
||||
disable = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if Config.System.Debug then print("^6Bridge^7: ^2Checking"..(data.stashName and " ^7'^6"..data.stashName.."^7'" or "").." ^2ingredients^7 - ^6"..k.."^7") end
|
||||
if data.stashName then disable = not stashhasItem(stashItems, itemTable)
|
||||
else disable = not hasItem(itemTable) end
|
||||
|
||||
setheader = Items[tostring(k)].label..(Recipes[i]["amount"] > 1 and " x"..Recipes[i]["amount"] or "")..(not disable and " ✔️" or "")
|
||||
Menu[#Menu + 1] = {
|
||||
isMenuHeader = disable,
|
||||
@@ -97,17 +93,20 @@ function multiCraft(data) local Menu = {}
|
||||
}
|
||||
for k in pairsByKeys(success) do
|
||||
local settext = ""
|
||||
local itemTable = {}
|
||||
for l, b in pairs(data.craft[data.item]) do
|
||||
if data.stashName then
|
||||
success[k] = stashhasItem(stashItems, l, (b * k))
|
||||
else
|
||||
success[k] = hasItem(l, (b * k))
|
||||
end
|
||||
itemTable[l] = (b * k)
|
||||
settext = settext..(settext ~= "" and br or "")..Items[l].label..(b*k > 1 and "- x"..b*k or "")
|
||||
Wait(0)
|
||||
end
|
||||
local disable = false
|
||||
if Config.System.Debug then print("^6Bridge^7: ^2Checking "..(data.stashName and "^7'^6"..data.stashName.."^7'" or "inventory").."^7x^5"..k.." ^2ingredients^7 - ^6"..data.item.."^7") end
|
||||
if data.stashName then disable = not stashhasItem(stashItems, itemTable)
|
||||
else disable = not hasItem(itemTable) end
|
||||
|
||||
Menu[#Menu + 1] = {
|
||||
isMenuHeader = not success[k],
|
||||
isMenuHeader = disable,
|
||||
arrow = not disable,
|
||||
header = "Craft - x"..k * data.craft.amount,
|
||||
txt = settext,
|
||||
onSelect = function ()
|
||||
@@ -140,40 +139,42 @@ function makeItem(data)
|
||||
startTempCam(cam)
|
||||
|
||||
for i = 1, amount do
|
||||
for _, v in pairs(data.craft) do
|
||||
if type(v) == "table" then
|
||||
for l, b in pairs(v) do
|
||||
if crafting and progressBar({
|
||||
label = "Using "..b.." "..Items[l].label,
|
||||
time = 1000,
|
||||
cancel = true,
|
||||
dict = 'pickup_object',
|
||||
anim = "putdown_low",
|
||||
flag = 48,
|
||||
icon = l,
|
||||
}) then
|
||||
--TriggerEvent('inventory:client:ItemBox', Items[l], "use", b) -- Show item box for each item
|
||||
else
|
||||
crafted = false
|
||||
crafting = false
|
||||
break
|
||||
for k, v in pairs(data.craft) do
|
||||
if k ~= "amount" and k ~= "job" then
|
||||
if type(v) == "table" then
|
||||
for l, b in pairs(v) do
|
||||
if crafting and progressBar({
|
||||
label = "Using "..b.." "..Items[l].label,
|
||||
time = 1000,
|
||||
cancel = true,
|
||||
dict = 'pickup_object',
|
||||
anim = "putdown_low",
|
||||
flag = 48,
|
||||
icon = l,
|
||||
}) then
|
||||
--TriggerEvent('inventory:client:ItemBox', Items[l], "use", b) -- Show item box for each item
|
||||
else
|
||||
crafted = false
|
||||
crafting = false
|
||||
break
|
||||
end
|
||||
Wait(200)
|
||||
end
|
||||
Wait(200)
|
||||
end
|
||||
if crafted then
|
||||
if crafting and progressBar({
|
||||
label = bartext..Items[data.item].label,
|
||||
time = bartime,
|
||||
cancel = true,
|
||||
dict = animDict,
|
||||
anim = anim,
|
||||
flag = 8,
|
||||
icon = data.item,
|
||||
}) then
|
||||
TriggerServerEvent(GetCurrentResourceName()..":Crafting:GetItem", data.item, data.craft, data.stashName)
|
||||
else
|
||||
crafting = false
|
||||
break
|
||||
if crafted then
|
||||
if crafting and progressBar({
|
||||
label = bartext..Items[data.item].label,
|
||||
time = bartime,
|
||||
cancel = true,
|
||||
dict = animDict,
|
||||
anim = anim,
|
||||
flag = 8,
|
||||
icon = data.item,
|
||||
}) then
|
||||
TriggerServerEvent(GetCurrentResourceName()..":Crafting:GetItem", data.item, data.craft, data.stashName)
|
||||
else
|
||||
crafting = false
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -225,149 +226,84 @@ function openShop(data)
|
||||
end
|
||||
|
||||
-- Client & Server side
|
||||
function hasItem(items, amount, src) local amount, count = amount and amount or 1, 0
|
||||
if src then
|
||||
if GetResourceState(OXInv):find("start") then
|
||||
local item = exports[OXInv]:GetItem(src, items)
|
||||
local amount = (amount or 1)
|
||||
if item.count >= amount then
|
||||
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^5FOUND^7 ^3"..item.count.."^7/^3"..amount.." "..tostring(items)) end
|
||||
return true
|
||||
else if Config.System.Debug then
|
||||
print("^6Bridge^7: ^3HasItem^7: ^2"..tostring(items).." ^1NOT FOUND^7") end
|
||||
return false
|
||||
end
|
||||
function hasItem(items, amount, src) local amount = amount and amount or 1
|
||||
local grabInv = nil
|
||||
local foundInv = ""
|
||||
if type(items) ~= "table" then items = { [items] = amount and amount or 1, } end
|
||||
if GetResourceState(OXInv):find("start") then
|
||||
foundInv = OXInv
|
||||
if src then grabInv = exports.ox_inventory:GetInventoryItems(src)
|
||||
else grabInv = exports[OXInv]:GetPlayerItems()
|
||||
end
|
||||
|
||||
elseif GetResourceState(QSInv):find("start") then
|
||||
for _, itemData in pairs(exports[QSInv]:GetInventory(src)) do
|
||||
if itemData and (itemData.name == items) then
|
||||
--if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^2Item^7: '^3"..tostring(items).."^7' ^2Slot^7: ^3"..itemData.slot.." ^7x(^3"..tostring(itemData.amount).."^7)") end
|
||||
count += (itemData.amount or 1)
|
||||
end
|
||||
end
|
||||
if count >= amount then
|
||||
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^5FOUND^7 ^3"..count.."^7/^3"..amount.." "..tostring(items)) end
|
||||
return true
|
||||
else
|
||||
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^2"..tostring(items).." ^1NOT FOUND^7") end
|
||||
return false
|
||||
end
|
||||
|
||||
elseif GetResourceState(CoreInv):find("start") then
|
||||
local item = exports[CoreInv]:getItems('primary-'..src, items)
|
||||
|
||||
if item.amount >= amount then
|
||||
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^5FOUND^7 ^3"..item.amount.."^7/^3"..amount.." "..tostring(items)) end
|
||||
return true
|
||||
else if Config.System.Debug then
|
||||
print("^6Bridge^7: ^3HasItem^7: ^2"..tostring(items).." ^1NOT FOUND^7") end
|
||||
return false
|
||||
end
|
||||
|
||||
elseif GetResourceState(CodeMInv):find("start") then
|
||||
local success = exports["codem-inventory"]:CheckItemValid(src, items, amount)
|
||||
if success then
|
||||
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^5FOUND^7 ^3"..amount.." "..tostring(items)) end
|
||||
return true
|
||||
end
|
||||
|
||||
elseif GetResourceState(CodeMInv):find("start") then
|
||||
for _, itemData in pairs(exports[CodeMInv]:GetUserInventory(src)) do
|
||||
if itemData and (itemData.name == items) then
|
||||
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^2Item^7: '^3"..tostring(items).."^7' ^2Slot^7: ^3"..itemData.slot.." ^7x(^3"..tostring(itemData.amount).."^7)") end
|
||||
count += (itemData.amount or 1)
|
||||
end
|
||||
end
|
||||
if count >= amount then
|
||||
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^5FOUND^7 ^3"..count.."^7/^3"..amount.." "..tostring(items)) end
|
||||
return true
|
||||
else
|
||||
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^2"..tostring(items).." ^1NOT FOUND^7") end
|
||||
return false
|
||||
end
|
||||
elseif GetResourceState(QSInv):find("start") then
|
||||
foundInv = QSInv
|
||||
if src then grabInv = exports[QSInv]:GetInventory(src)
|
||||
else grabInv = exports[QSInv]:getUserInventory()
|
||||
end
|
||||
|
||||
elseif GetResourceState(OrigenInv):find("start") then
|
||||
foundInv = OrigenInv
|
||||
if src then
|
||||
grabInv = exports[OrigenInv]:getPlayerInventory(src)
|
||||
else
|
||||
for _, itemData in pairs(Core.Functions.GetPlayer(src).PlayerData.items) do
|
||||
if itemData and (itemData.name == items) then
|
||||
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^2Item^7: '^3"..tostring(items).."^7' ^2Slot^7: ^3"..itemData.slot.." ^7x(^3"..tostring(itemData.amount).."^7)") end
|
||||
count += (itemData.amount or 1)
|
||||
end
|
||||
end
|
||||
if count >= amount then
|
||||
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^5FOUND^7 ^3"..count.."^7/^3"..amount.." "..tostring(items)) end
|
||||
return true
|
||||
else
|
||||
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^2"..tostring(items).." ^1NOT FOUND^7") end
|
||||
return false
|
||||
end
|
||||
grabInv = exports[OrigenInv]:getPlayerInventory()
|
||||
end
|
||||
|
||||
elseif GetResourceState(CoreInv):find("start") then
|
||||
foundInv = CoreInv
|
||||
if src then
|
||||
if GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then
|
||||
grabInv = Core.Functions.GetPlayer(src).PlayerData.items
|
||||
elseif GetResourceState(ESXExport):find("start") then
|
||||
local Player = ESX.GetPlayerFromId(src)
|
||||
grabInv = Player.getInventory(false)
|
||||
end
|
||||
else
|
||||
local p = promise.new()
|
||||
Core.Functions.TriggerCallback('core_inventory:server:getInventory', function(cb) p:resolve(cb) end)
|
||||
local result = Citizen.Await(p)
|
||||
if type(result) == "string" then result = json.decode(result) end
|
||||
grabInv = result
|
||||
end
|
||||
|
||||
elseif GetResourceState(CodeMInv):find("start") then
|
||||
foundInv = CodeMInv
|
||||
if src then grabInv = exports[CodeMInv]:GetUserInventory(src)
|
||||
else grabInv = exports[CodeMInv]:GetClientPlayerInventory()
|
||||
end
|
||||
|
||||
elseif GetResourceState(QBInv):find("start") then
|
||||
foundInv = QBInv
|
||||
if src then grabInv = Core.Functions.GetPlayer(src).PlayerData.items
|
||||
else grabInv = Core.Functions.GetPlayerData().items
|
||||
end
|
||||
|
||||
else
|
||||
if GetResourceState(OXInv):find("start") then
|
||||
local count = tonumber(exports[OXInv]:Search('count', items))
|
||||
local amount = (amount or 1)
|
||||
if count >= amount then if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^5FOUND^7 ^3"..count.."^7/^3"..amount.." "..tostring(items)) end return true
|
||||
else if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^2"..tostring(items).." ^1NOT FOUND^7") end return false end
|
||||
print("^4ERROR^7: ^2No Inventory detected ^7- ^2Check ^3exports^1.^2lua^7")
|
||||
end
|
||||
|
||||
elseif GetResourceState(QSInv):find("start") then
|
||||
for _, itemData in pairs(exports[QSInv]:getUserInventory()) do
|
||||
if itemData and (itemData.name == items) then
|
||||
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^2Item^7: '^3"..tostring(items).."^7' ^2Slot^7: ^3"..itemData.slot.." ^7x(^3"..tostring(itemData.amount).."^7)") end
|
||||
count += (itemData.amount or 1)
|
||||
if grabInv then
|
||||
local hasTable = {}
|
||||
for item, amount in pairs(items) do
|
||||
if not Items[item] then print("^4ERROR^7: ^2Script can't find ingredient item in Shared Items - ^1"..item.."^7") end
|
||||
local count = 0
|
||||
for _, itemData in pairs(grabInv) do
|
||||
if itemData and (itemData.name == item) then
|
||||
--if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^2Item^7: '^3"..tostring(item).."^7' ^2Slot^7: ^3"..itemData.slot.." ^7x(^3"..tostring(itemData.count or itemData.amount).."^7)", foundInv) end
|
||||
count += ((itemData.count or itemData.amount) or 1)
|
||||
end
|
||||
end
|
||||
if count >= amount then
|
||||
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^5FOUND^7 ^3"..count.."^7/^3"..amount.." "..tostring(items)) end
|
||||
return true
|
||||
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7[^6"..foundInv.."^7]: "..tostring(item).." ^3"..count.."^7/^3"..amount.." ^5FOUND^7") end
|
||||
hasTable[item] = { hasItem = true, count = count, }
|
||||
else
|
||||
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^2"..tostring(items).." ^1NOT FOUND^7") end
|
||||
return false
|
||||
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7[^6"..foundInv.."^7]: "..tostring(item).." ^1"..count.."^7/^3"..amount.." ^1NOT FOUND^7") end
|
||||
hasTable[item] = { hasItem = false, count = count, }
|
||||
end
|
||||
|
||||
elseif GetResourceState(CoreInv):find("start") then
|
||||
for _, itemData in pairs(exports[CoreInv]:getInventory('primary-'..GetPlayerServerId(PlayerPedId()))) do
|
||||
if itemData and (itemData.name == items) then
|
||||
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^2Item^7: '^3"..tostring(items).."^7' ^2Slot^7: ^3"..itemData.slot.." ^7x(^3"..tostring(itemData.amount).."^7)") end
|
||||
count += (itemData.amount or 1)
|
||||
end
|
||||
end
|
||||
if count >= amount then
|
||||
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^5FOUND^7 ^3"..count.."^7/^3"..amount.." "..tostring(items)) end
|
||||
return true
|
||||
else
|
||||
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^2"..tostring(items).." ^1NOT FOUND^7") end
|
||||
return false
|
||||
end
|
||||
|
||||
elseif GetResourceState(CodeMInv):find("start") then
|
||||
local success = exports[CodeMInv]:CheckItemValid(items, amount)
|
||||
if success then
|
||||
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^5FOUND^7 ^3"..amount.." "..tostring(items)) end
|
||||
return true
|
||||
end
|
||||
|
||||
elseif GetResourceState(QBInv):find("start") then
|
||||
--if tonumber(GetResourceMetadata(QBInv, 'version')) <= 1.2 then
|
||||
-- return exports[QBInv]:HasItem(items, amount)
|
||||
--else
|
||||
for _, itemData in pairs(Core.Functions.GetPlayerData().items) do
|
||||
if itemData and (itemData.name == items) then
|
||||
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^2Item^7: '^3"..tostring(items).."^7' ^2Slot^7: ^3"..itemData.slot.." ^7x(^3"..tostring(itemData.amount).."^7)") end
|
||||
count += (itemData.amount or 1)
|
||||
end
|
||||
end
|
||||
if count >= amount then
|
||||
if Config.System.Debug then
|
||||
print("^6Bridge^7: ^3HasItem^7: ^5FOUND^7 ^3"..count.."^7/^3"..amount.." "..tostring(items))
|
||||
end
|
||||
return true
|
||||
else
|
||||
if Config.System.Debug then
|
||||
print("^6Bridge^7: ^3HasItem^7: ^2"..tostring(items).." ^1NOT FOUND^7")
|
||||
end
|
||||
return false
|
||||
end
|
||||
-- end
|
||||
end
|
||||
for k, v in pairs(hasTable) do if v.hasItem == false then return false, hasTable end end
|
||||
return true, hasTable
|
||||
end
|
||||
end
|
||||
|
||||
@@ -380,7 +316,7 @@ function openStash(data)
|
||||
exports[CodeMInv]:OpenStash(data.stash, 400000, 100)
|
||||
else
|
||||
TriggerEvent("inventory:client:SetCurrentStash", data.stash)
|
||||
TriggerServerEvent("inventory:server:OpenInventory", "stash", data.stash)
|
||||
TriggerServerEvent("inventory:server:OpenInventory", "stash", data.stash, data.stashOptions)
|
||||
end
|
||||
lookEnt(data.coords)
|
||||
end
|
||||
@@ -388,16 +324,27 @@ end
|
||||
function getStash(stashName)
|
||||
local stashItems, items = {}, {}
|
||||
if GetResourceState(OXInv):find("start") then
|
||||
if Config.System.Debug then print("^6Bridge^7: ^2Retrieving ^3Stash^2 with ^7ox_inventory") end
|
||||
if Config.System.Debug then print("^6Bridge^7: ^2Retrieving ^3Stash^2 with ^7"..OXInv) end
|
||||
stashItems = exports[OXInv]:Inventory(stashName).items
|
||||
|
||||
elseif GetResourceState(QSInv):find("start") then
|
||||
if Config.System.Debug then print("^6Bridge^7: ^2Retrieving ^3Stash^2 with ^7qs-inventory") end
|
||||
if Config.System.Debug then print("^6Bridge^7: ^2Retrieving ^3Stash^2 with ^7"..QSInv) end
|
||||
stashItems = exports[QSInv]:GetStashItems(stashName)
|
||||
|
||||
elseif GetResourceState(CoreInv):find("start") then
|
||||
if Config.System.Debug then print("^6Bridge^7: ^2Retrieving ^3Stash^2 with ^7"..CoreInv) end
|
||||
stashItems = exports[CoreInv]:getInventory(stashName)
|
||||
|
||||
elseif GetResourceState(CodeMInv):find("start") then
|
||||
if Config.System.Debug then print("^6Bridge^7: ^2Retrieving ^3Stash^2 with ^7qs-inventory") end
|
||||
if Config.System.Debug then print("^6Bridge^7: ^2Retrieving ^3Stash^2 with ^7"..CodeMInv) end
|
||||
stashItems = exports[CodeMInv]:GetInventoryItems('Stash', stashName)
|
||||
|
||||
elseif GetResourceState(OrigenInv):find("start") then
|
||||
if Config.System.Debug then print("^6Bridge^7: ^2Retrieving ^3Stash^2 with ^7"..OrigenInv) end
|
||||
stashItems = exports[OrigenInv]:GetStash(stashName)
|
||||
|
||||
elseif GetResourceState(QBInv):find("start") then
|
||||
if Config.System.Debug then print("^6Bridge^7: ^2Retrieving ^3Stash^2 with ^7qb-inventory") end
|
||||
if Config.System.Debug then print("^6Bridge^7: ^2Retrieving ^3Stash^2 with ^7"..QBInv) end
|
||||
local result = MySQL.scalar.await('SELECT items FROM stashitems WHERE stash = ?', { stashName })
|
||||
if result then stashItems = json.decode(result) end
|
||||
end
|
||||
@@ -405,18 +352,18 @@ function getStash(stashName)
|
||||
for _, item in pairs(stashItems) do
|
||||
local itemInfo = Items[item.name:lower()]
|
||||
if itemInfo then
|
||||
items[item.slot] = {
|
||||
name = itemInfo["name"],
|
||||
items[#items+1] = {
|
||||
name = itemInfo["name"] ~= nil and itemInfo["slot"] or nil,
|
||||
amount = tonumber(item.amount) or tonumber(item.count),
|
||||
info = item.info ~= nil and item.info or "",
|
||||
label = itemInfo["label"],
|
||||
label = itemInfo["label"] ~= nil and itemInfo["slot"] or nil,
|
||||
description = itemInfo["description"] ~= nil and itemInfo["description"] or "",
|
||||
weight = itemInfo["weight"],
|
||||
type = itemInfo["type"],
|
||||
unique = itemInfo["unique"],
|
||||
useable = itemInfo["useable"],
|
||||
image = itemInfo["image"],
|
||||
slot = item.slot,
|
||||
weight = itemInfo["weight"] ~= nil and itemInfo["slot"] or nil,
|
||||
type = itemInfo["type"] ~= nil and itemInfo["slot"] or nil,
|
||||
unique = itemInfo["unique"] ~= nil and itemInfo["slot"] or nil,
|
||||
useable = itemInfo["useable"] ~= nil and itemInfo["slot"] or nil,
|
||||
image = itemInfo["image"] ~= nil and itemInfo["slot"] or nil,
|
||||
slot = itemInfo["slot"] ~= nil and itemInfo["slot"] or nil,
|
||||
}
|
||||
end
|
||||
end
|
||||
@@ -432,10 +379,30 @@ function stashRemoveItem(stashItems, stashName, items) local amount = amount and
|
||||
if Config.System.Debug then print("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..OXInv, k, v) end
|
||||
end
|
||||
elseif GetResourceState(QSInv):find("start") then
|
||||
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
|
||||
if Config.System.Debug then
|
||||
print("^6Bridge^7: ^2None of this item left in stash ^3Stash^7", k, v)
|
||||
end
|
||||
stashItems[l] = nil
|
||||
else
|
||||
if Config.System.Debug then
|
||||
print("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..QBInv, k, v)
|
||||
end
|
||||
exports[QSInv]:RemoveItemIntoStash(stashName, k, v, l)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
elseif GetResourceState(CoreInv):find("start") then
|
||||
for k, v in pairs(items) do
|
||||
exports[QSInv]:RemoveItemIntoStash(stashName, k, v)
|
||||
if Config.System.Debug then print("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..QSInv, k, v) end
|
||||
exports[CoreInv]:removeItemExact(stashName, k, v)
|
||||
if Config.System.Debug then print("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..CoreInv, k, v) end
|
||||
end
|
||||
|
||||
elseif GetResourceState(CodeMInv):find("start") then
|
||||
for k, v in pairs(items) do
|
||||
for l in pairs(stashItems) do
|
||||
@@ -457,6 +424,13 @@ function stashRemoveItem(stashItems, stashName, items) local amount = amount and
|
||||
if Config.System.Debug then
|
||||
print("^6Bridge^7: ^3saveStash^7: ^2Saving ^3QB^2 stash ^7'^6"..stashName.."^7'")
|
||||
end
|
||||
|
||||
elseif GetResourceState(OrigenInv):find("start") then
|
||||
for k, v in pairs(items) do
|
||||
exports[OrigenInv]:RemoveItem(stashName, k, v)
|
||||
if Config.System.Debug then print("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..OrigenInv, k, v) end
|
||||
end
|
||||
|
||||
elseif GetResourceState(QBInv):find("start") then
|
||||
for k, v in pairs(items) do
|
||||
for l in pairs(stashItems) do
|
||||
@@ -485,22 +459,25 @@ function stashRemoveItem(stashItems, stashName, items) local amount = amount and
|
||||
end
|
||||
RegisterNetEvent(GetCurrentResourceName()..":server:stashRemoveItem", stashRemoveItem)
|
||||
|
||||
function stashhasItem(stashItems, item, amount) local amount, count = amount and amount or 1, 0
|
||||
for k, itemData in pairs(stashItems) do
|
||||
if itemData and (itemData.name == item) then
|
||||
--if Config.System.Debug then
|
||||
-- print("^6Bridge^7: ^3stashHasItem^7: ^2Item^7: '^3"..tostring(item).."^7' ^2Slot^7: ^3"..itemData.slot.." ^7x(^3"..tostring(itemData.amount).."^7)")
|
||||
--end
|
||||
count += (itemData.amount or 1)
|
||||
end
|
||||
end
|
||||
if count >= amount then
|
||||
if Config.System.Debug then
|
||||
print("^6Bridge^7: ^3stashHasItem^7: ^2Items ^3"..item.." ^5FOUND^7 x^3"..count.."^7/^3"..amount.."^7") end
|
||||
return
|
||||
true
|
||||
else
|
||||
if Config.System.Debug then print("^6Bridge^7: ^3stashHasItem^7: ^2Items ^1NOT FOUND^7 "..json.encode(item)) end
|
||||
return false
|
||||
function stashhasItem(stashItems, items, amount)
|
||||
local foundInv = ""
|
||||
if type(items) ~= "table" then items = { [items] = amount and amount or 1, } end
|
||||
local hasTable = {}
|
||||
for item, amount in pairs(items) do
|
||||
local count = 0
|
||||
for _, itemData in pairs(stashItems) do
|
||||
if itemData and (itemData.name == item) then
|
||||
count += (itemData.amount or 1)
|
||||
end
|
||||
end
|
||||
if count >= amount then
|
||||
if Config.System.Debug then print("^6Bridge^7: ^3stashHasItem^7: ^5FOUND '"..item.."' ^3"..count.."^7/^3"..amount.."^7") end
|
||||
hasTable[item] = { hasItem = true, count = count, }
|
||||
else
|
||||
if Config.System.Debug then print("^6Bridge^7: ^3stashHasItem^7: ^1NOT FOUND^7 '"..item.."' ^1"..count.."^7/^3"..amount.."^7") end
|
||||
hasTable[item] = { hasItem = false, count = count, }
|
||||
end
|
||||
end
|
||||
for k, v in pairs(hasTable) do if v.hasItem == false then return false, hasTable end end
|
||||
return true, hasTable
|
||||
end
|
||||
@@ -7,8 +7,9 @@ Exports = {
|
||||
OXInv = "ox_inventory",
|
||||
QBInv = "qb-inventory",
|
||||
QSInv = "qs-inventory",
|
||||
CoreInv = "core-inventory",
|
||||
CoreInv = "core_inventory",
|
||||
CodeMInv = "codem-inventory",
|
||||
OrigenInv = "origen_inventory",
|
||||
|
||||
OXLibExport = "ox_lib",
|
||||
|
||||
|
||||
112
functions.lua
112
functions.lua
@@ -11,7 +11,7 @@ end
|
||||
local time = 100
|
||||
function loadModel(model)
|
||||
if not HasModelLoaded(model) then if Config.System.Debug then print("^6Bridge^7: ^2Loading Model^7: '^6"..model.."^7'") end
|
||||
while not HasModelLoaded(model) do if time > 0 then time = time - 1 RequestModel(model)
|
||||
while not HasModelLoaded(model) do if time > 0 then time -= 1 RequestModel(model)
|
||||
else time = 1000 print("^6Bridge^7: ^3LoadModel^7: ^2Timed out loading model ^7'^6"..model.."^7'") break end
|
||||
Wait(10) end
|
||||
end
|
||||
@@ -29,7 +29,7 @@ function pairsByKeys(t) local a = {} for n in pairs(t) do a[#a+1] = n end table.
|
||||
|
||||
function playAnim(animDict, animName, duration, flag, ped)
|
||||
loadAnimDict(animDict)
|
||||
TaskPlayAnim(ped and ped or PlayerPedId(), animDict, animName, 1.0, -1.0, duration or 30000, flag or 50, 1, false, false, false)
|
||||
TaskPlayAnim(ped and ped or PlayerPedId(), animDict, animName, 8.0, -8.0, duration or 30000, flag or 50, 1, false, false, false)
|
||||
end
|
||||
|
||||
function stopAnim(animDict, animName)
|
||||
@@ -154,12 +154,14 @@ function lookEnt(entity) local ped = PlayerPedId()
|
||||
end
|
||||
|
||||
function destroyProp(entity)
|
||||
if Config.System.Debug then print("^6Bridge^7: ^2Destroying Prop^7: '^6"..entity.."^7'") end
|
||||
if IsEntityAttachedToEntity(entity, PlayerPedId()) then
|
||||
SetEntityAsMissionEntity(entity)
|
||||
DetachEntity(entity, true, true)
|
||||
if entity then
|
||||
if Config.System.Debug then print("^6Bridge^7: ^2Destroying Prop^7: '^6"..entity.."^7'") end
|
||||
if IsEntityAttachedToEntity(entity, PlayerPedId()) then
|
||||
SetEntityAsMissionEntity(entity)
|
||||
DetachEntity(entity, true, true)
|
||||
end
|
||||
DeleteObject(entity)
|
||||
end
|
||||
DeleteObject(entity)
|
||||
end
|
||||
|
||||
function pushVehicle(entity)
|
||||
@@ -188,6 +190,28 @@ function pushVehicle(entity)
|
||||
end
|
||||
end
|
||||
|
||||
function ensureNetToVeh(vehNetID)
|
||||
if Config.System.Debug then print("^6Bridge^7: ^3ensureNetToVeh^7: ^2Requesting NetworkDoesNetworkIdExist^7(^6"..vehNetID.."^7)") end
|
||||
local timeout = 100
|
||||
while not NetworkDoesNetworkIdExist(vehNetID) and timeout > 0 do
|
||||
timeout -= 1
|
||||
Wait(10)
|
||||
end
|
||||
if not NetworkDoesNetworkIdExist(vehNetID) then
|
||||
return 0
|
||||
end
|
||||
timeout = 100
|
||||
local vehicle = NetToVeh(vehNetID)
|
||||
while not DoesEntityExist(vehicle) and vehicle ~= 0 and timeout > 0 do
|
||||
timeout -= 1
|
||||
Wait(10)
|
||||
end
|
||||
if not DoesEntityExist(vehicle) then
|
||||
return 0
|
||||
end
|
||||
return vehicle
|
||||
end
|
||||
|
||||
function makeBlip(data)
|
||||
local blip = AddBlipForCoord(data.coords)
|
||||
SetBlipAsShortRange(blip, true)
|
||||
@@ -489,7 +513,7 @@ function setThirst(src, thirst)
|
||||
if GetResourceState(ESXExport):find("start") then
|
||||
TriggerClientEvent('esx_status:add', src, 'thirst', thirst)
|
||||
elseif GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
local Player = Core.Functions.GetPlayer(src)
|
||||
Player.Functions.SetMetaData('thirst', thirst)
|
||||
TriggerClientEvent("hud:client:UpdateNeeds", src, thirst, Player.PlayerData.metadata.thirst)
|
||||
end
|
||||
@@ -499,7 +523,7 @@ function setHunger(src, hunger)
|
||||
if GetResourceState(ESXExport):find("start") then
|
||||
TriggerClientEvent('esx_status:add', src, 'hunger', hunger)
|
||||
elseif GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
local Player = Core.Functions.GetPlayer(src)
|
||||
Player.Functions.SetMetaData('hunger', hunger)
|
||||
TriggerClientEvent("hud:client:UpdateNeeds", src, hunger, Player.PlayerData.metadata.hunger)
|
||||
end
|
||||
@@ -549,8 +573,9 @@ end
|
||||
|
||||
RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give, item, amount, newsrc)
|
||||
local src = newsrc or source
|
||||
local addremove = (tostring(give) == "true" and "addItem" or "removeItem")
|
||||
if Config.System.Debug then
|
||||
print("^6Bridge^7: ^3toggleItem ^2triggered^7: ^6"..(tostring(give) == "true" and "addItem" or "removeItem").."^7 - ['^8"..tostring(item).."^7'] x"..(tostring(amount) or "1"))
|
||||
print("^6Bridge^7: ^3toggleItem ^2triggered^7: ^6"..addremove.."^7 - '"..tostring(item).."' x"..(tostring(amount) or "1"))
|
||||
end
|
||||
local remamount = (amount and amount or 1)
|
||||
if item == nil then return end
|
||||
@@ -559,23 +584,37 @@ RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give,
|
||||
if GetResourceState(OXInv):find("start") then
|
||||
local success = exports[OXInv]:RemoveItem(src, item, (amount and amount or 1), nil)
|
||||
if Config.System.Debug then
|
||||
print("^6Bridge^7: ^1Removing ^2from Player^7(^2"..src.."^7) '^6"..Items[item].label.."^7(^2x^6"..((amount and amount or "1")).."^7) - '"..OXInv)
|
||||
print("^6Bridge^7: ^3"..addremove.."^7[^6"..OXInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7")
|
||||
end
|
||||
|
||||
elseif GetResourceState(QSInv):find("start") then
|
||||
local success = exports[QSInv]:RemoveItem(src, item, amount)
|
||||
if Config.System.Debug then
|
||||
print("^6Bridge^7: ^1Removing ^2from Player^7(^2"..src.."^7) '^6"..Items[item].label.."^7(^2x^6"..((amount and amount or "1")).."^7) - '"..QSInv)
|
||||
print("^6Bridge^7: ^3"..addremove.."^7[^6"..QSInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7")
|
||||
end
|
||||
|
||||
elseif GetResourceState(CoreInv):find("start") then
|
||||
if GetResourceState(QBExport):find("start") then
|
||||
Core.Functions.GetPlayer(src).Functions.RemoveItem(item, amount, nil)
|
||||
elseif GetResourceState(ESXExport):find("start") then
|
||||
ESX.GetPlayerFromId(src).removeInventoryItem(item, count)
|
||||
end
|
||||
elseif GetResourceState(CoreInv):find("start") then
|
||||
local success = exports[CoreInv]:removeItemExact('primary-'..src, item, amount)
|
||||
if Config.System.Debug then
|
||||
print("^6Bridge^7: ^1Removing ^2from Player^7(^2"..src.."^7) '^6"..Items[item].label.."^7(^2x^6"..((amount and amount or "1")).."^7) - '"..CoreInv)
|
||||
print("^6Bridge^7: ^3"..addremove.."^7[^6"..CoreInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7")
|
||||
end
|
||||
elseif GetResourceState(CodeMInv):find("start") then
|
||||
|
||||
elseif GetResourceState(OrigenInv):find("start") then
|
||||
local success = exports[OrigenInv]:RemoveItem(src, item, amount)
|
||||
if Config.System.Debug then
|
||||
print("^6Bridge^7: ^3"..addremove.."^7[^6"..OrigenInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7")
|
||||
end
|
||||
|
||||
elseif GetResourceState(CodeMInv):find("start") then
|
||||
local success = exports[CodeMInv]:RemoveItem(src, item, amount)
|
||||
if Config.System.Debug then
|
||||
print("^6Bridge^7: ^1Removing ^2from Player^7(^2"..src.."^7) '^6"..Items[item].label.."^7(^2x^6"..((amount and amount or "1")).."^7) - '"..CodeMInv)
|
||||
print("^6Bridge^7: ^3"..addremove.."^7[^6"..CodeMInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7")
|
||||
end
|
||||
|
||||
elseif GetResourceState(QBInv):find("start") then
|
||||
while remamount > 0 do
|
||||
if Core.Functions.GetPlayer(src).Functions.RemoveItem(item, 1) then end
|
||||
@@ -585,10 +624,10 @@ RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give,
|
||||
TriggerClientEvent('inventory:client:ItemBox', src, Items[item], "remove", (amount and amount or 1))
|
||||
end
|
||||
if Config.System.Debug then
|
||||
print("^6Bridge^7: ^1Removing ^2from Player^7(^2"..src.."^7) '^6"..Items[item].label.."^7(^2x^6"..((amount and amount or "1")).."^7) - '"..QBInv)
|
||||
print("^6Bridge^7: ^3"..addremove.."^7[^6"..QBInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7")
|
||||
end
|
||||
else
|
||||
print("^4Error^7: ^2No Inventory detected ^7- ^2Check ^3exports^1.^2lua^7")
|
||||
print("^4ERROR^7: ^2No Inventory detected ^7- ^2Check ^3exports^1.^2lua^7")
|
||||
end
|
||||
else
|
||||
dupeWarn(src, item) -- if not boot the player
|
||||
@@ -598,23 +637,37 @@ RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give,
|
||||
if GetResourceState(OXInv):find("start") then
|
||||
local success = exports[OXInv]:AddItem(src, item, amount or 1, nil)
|
||||
if Config.System.Debug then
|
||||
print("^6Bridge^7: ^4Giving ^2Player^7(^2"..src.."^7) '^6"..Items[item].label.."^7(^2x^6"..((amount and amount or "1")).."^7) ^7"..OXInv)
|
||||
print("^6Bridge^7: ^3"..addremove.."^7[^6"..OXInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7")
|
||||
end
|
||||
|
||||
elseif GetResourceState(QSInv):find("start") then
|
||||
local success = exports[QSInv]:AddItem(src, item, amount)
|
||||
if Config.System.Debug then
|
||||
print("^6Bridge^7: ^4Giving ^2Player^7(^2"..src.."^7) '^6"..Items[item].label.."^7(^2x^6"..((amount and amount or "1")).."^7) ^7"..QSInv)
|
||||
print("^6Bridge^7: ^3"..addremove.."^7[^6"..QSInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7")
|
||||
end
|
||||
|
||||
elseif GetResourceState(CoreInv):find("start") then
|
||||
local success = exports[CoreInv]:addItem('primary-'..src, item, amount)
|
||||
if Config.System.Debug then
|
||||
print("^6Bridge^7: ^4Giving ^2Player^7(^2"..src.."^7) '^6"..Items[item].label.."^7(^2x^6"..((amount and amount or "1")).."^7) ^7"..CoreInv)
|
||||
if GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then
|
||||
Core.Functions.GetPlayer(src).Functions.AddItem(item, amount, nil, nil)
|
||||
elseif GetResourceState(ESXExport):find("start") then
|
||||
ESX.GetPlayerFromId(src).addInventoryItem(item, amount)
|
||||
end
|
||||
if Config.System.Debug then
|
||||
print("^6Bridge^7: ^3"..addremove.."^7[^6"..CoreInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7")
|
||||
end
|
||||
|
||||
elseif GetResourceState(CodeMInv):find("start") then
|
||||
local success = exports[CodeMInv]:AddItem(src, item, amount)
|
||||
if Config.System.Debug then
|
||||
print("^6Bridge^7: ^4Giving ^2Player^7(^2"..src.."^7) '^6"..Items[item].label.."^7(^2x^6"..((amount and amount or "1")).."^7) ^7"..CodeMInv)
|
||||
print("^6Bridge^7: ^3"..addremove.."^7[^6"..CodeMInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7")
|
||||
end
|
||||
|
||||
elseif GetResourceState(OrigenInv):find("start") then
|
||||
local success = exports[OrigenInv]:AddItem(src, item, amount)
|
||||
if Config.System.Debug then
|
||||
print("^6Bridge^7: ^3"..addremove.."^7[^6"..OrigenInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7")
|
||||
end
|
||||
|
||||
elseif GetResourceState(QBInv):find("start") then
|
||||
if Core.Functions.GetPlayer(src).Functions.AddItem(item, amount or 1) then
|
||||
--if Config.Crafting.showItemBox then
|
||||
@@ -622,10 +675,11 @@ RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give,
|
||||
--end
|
||||
end
|
||||
if Config.System.Debug then
|
||||
print("^6Bridge^7: ^4Giving ^2Player^7(^2"..src.."^7) '^6"..Items[item].label.."^7(^2x^6"..((amount and amount or "1")).."^7) ^7"..QBInv)
|
||||
print("^6Bridge^7: ^3"..addremove.."^7[^6"..QBInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7")
|
||||
end
|
||||
|
||||
else
|
||||
print("^4Error^7: ^2No Inventory detected ^7- ^2Check ^3exports^1.^2lua^7")
|
||||
print("^4ERROR^7: ^2No Inventory detected ^7- ^2Check ^3exports^1.^2lua^7")
|
||||
end
|
||||
end
|
||||
end)
|
||||
@@ -660,12 +714,12 @@ local function CheckVersion()
|
||||
PerformHttpRequest('https://raw.githubusercontent.com/jimathy/'..GetCurrentResourceName()..'/master/version.txt', function(err, freeVersion, headers)
|
||||
if not freeVersion then print("^1Currently unable to run a version check for ^7'^3"..GetCurrentResourceName().."^7' ("..currentVersion.."^7)") return end
|
||||
local currentVersion = "^3"..GetResourceMetadata(GetCurrentResourceName(), 'version'):gsub("%.", "^7.^3").."^7"
|
||||
freeVersion = "^3"..freeVersion:sub(1, -2):gsub("%.", "^7.^3").."^7"
|
||||
freeVersion = "^3"..freeVersion:sub(1, -2):gsub("%.", "^7.^3"):gsub("%\r", "").."^7"
|
||||
print("^6Version Check^7: ^2Running^7: "..currentVersion.." ^2Latest^7: "..freeVersion)
|
||||
print(freeVersion == currentVersion and "^7'^3"..GetCurrentResourceName().."^7' - ^6You are running the latest version.^7 ("..currentVersion..")" or "^7'^3"..GetCurrentResourceName().."^7' - ^1You are currently running an outdated version^7, ^1please update^7!")
|
||||
end)
|
||||
else
|
||||
newestVersion = "^3"..newestVersion:sub(1, -2):gsub("%.", "^7.^3").."^7"
|
||||
newestVersion = "^3"..newestVersion:sub(1, -2):gsub("%.", "^7.^3"):gsub("%\r", "").."^7"
|
||||
print("^6Version Check^7: ^2Running^7: "..currentVersion.." ^2Latest^7: "..newestVersion)
|
||||
print(newestVersion == currentVersion and '^6You are running the latest version.^7 ('..currentVersion..')' or "^1You are currently running an outdated version^7, ^1please update^7!")
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
name "Jim_Bridge"
|
||||
author "Jimathy"
|
||||
version "1.0.2"
|
||||
version "1.0.7"
|
||||
description "Framework Bridge By Jimathy"
|
||||
fx_version "cerulean"
|
||||
game "gta5"
|
||||
@@ -11,4 +11,4 @@ files {
|
||||
'functions.lua',
|
||||
'wrapper.lua',
|
||||
'crafting.lua',
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.0.2
|
||||
1.0.7
|
||||
|
||||
80
wrapper.lua
80
wrapper.lua
@@ -1,5 +1,8 @@
|
||||
Items, Vehicles, Jobs, Gangs, Core, ESX = {}, nil, nil, nil, nil, nil
|
||||
|
||||
if GetResourceState("ps-inventory"):find("start") then Exports.QBInv = "ps-inventory" end
|
||||
if GetResourceState("lj-inventory"):find("start") then Exports.QBInv = "lj-inventory" end
|
||||
|
||||
OXLibExport = Exports and Exports.OXLibExport or ""
|
||||
|
||||
QBXExport = Exports and Exports.QBXExport or ""
|
||||
@@ -12,6 +15,7 @@ QBInv = Exports and Exports.QBInv or ""
|
||||
QSInv = Exports and Exports.QSInv or ""
|
||||
CoreInv = Exports and Exports.CoreInv or ""
|
||||
CodeMInv = Exports and Exports.CodeMInv or ""
|
||||
OrigenInv = Exports and Exports.OrigenInv or ""
|
||||
|
||||
QBMenuExport = Exports and Exports.QBMenuExport or ""
|
||||
|
||||
@@ -23,7 +27,7 @@ function CheckBridgeVersion()
|
||||
local currentVersion = "^3"..GetResourceMetadata("jim_bridge", 'version'):gsub("%.", "^7.^3").."^7"
|
||||
PerformHttpRequest('https://raw.githubusercontent.com/jimathy/jim_bridge/master/version.txt', function(err, newestVersion, headers)
|
||||
if not newestVersion then print("^1Currently unable to run a version check for ^7'^3jim_bridge^7' ("..currentVersion.."^7)") return end
|
||||
newestVersion = "^3"..newestVersion:sub(1, -2):gsub("%.", "^7.^3").."^7"
|
||||
newestVersion = "^3"..newestVersion:sub(1, -2):gsub("%.", "^7.^3"):gsub("%\r", "").."^7"
|
||||
print(newestVersion == currentVersion and "^7'^3jim_bridge^7' - ^6You are running the latest version.^7 ("..currentVersion..")" or "^7'^3jim_bridge^7' - ^1You are currently running an outdated version^7, ^1please update^7!")
|
||||
end)
|
||||
end
|
||||
@@ -223,16 +227,19 @@ end
|
||||
|
||||
function openMenu(Menu, data)
|
||||
if Config.System.Menu == "ox" then
|
||||
if data.onBack then
|
||||
local index = nil
|
||||
if data.onBack and not data.onSelected then
|
||||
table.insert(Menu, 1, { icon = "fas fa-circle-arrow-left",
|
||||
title = "Return",
|
||||
onSelect = data.onBack,
|
||||
label = "Return"
|
||||
})
|
||||
end
|
||||
for k in pairs(Menu) do
|
||||
if not Menu[k].title then
|
||||
if Menu[k].header ~= nil and Menu[k].header ~= "" then
|
||||
Menu[k].title = Menu[k].header
|
||||
Menu[k].label = Menu[k].header
|
||||
if Menu[k].txt then Menu[k].description = Menu[k].txt else Menu[k].description = "" end
|
||||
else
|
||||
Menu[k].title = Menu[k].txt
|
||||
@@ -246,8 +253,22 @@ function openMenu(Menu, data)
|
||||
Menu[k].disabled = true
|
||||
end
|
||||
end
|
||||
lib.registerContext({id = 'Menu', title = data.header..br..br..(data.headertxt and data.headertxt or ""), position = 'top-right', options = Menu, canClose = data.canClose and data.canClose or nil, onExit = data.onExit and data.onExit or nil, })
|
||||
lib.showContext("Menu")
|
||||
local menuID = 'Menu'
|
||||
(data.onSelected and lib.registerMenu or lib.registerContext)({
|
||||
id = menuID,
|
||||
title = data.header..br..br..(data.headertxt and data.headertxt or ""),
|
||||
position = 'top-right',
|
||||
options = Menu,
|
||||
canClose = data.canClose and data.canClose or nil,
|
||||
onClose = (data.onBack and data.onBack) or (data.onExit and data.onExit) or nil,
|
||||
onExit = data.onExit and data.onExit or nil,
|
||||
onSelected = data.onSelected and (function(selected) index = selected end) or nil,
|
||||
}, (data.onSelected and (function(x, y, args) Menu[x].onSelect() end) or nil))
|
||||
if data.onSelected then
|
||||
lib.showMenu(menuID, 1)
|
||||
else
|
||||
lib.showContext(menuID)
|
||||
end
|
||||
elseif Config.System.Menu == "qb" then
|
||||
if data.onBack then
|
||||
table.insert(Menu, 1, { icon = "fas fa-circle-arrow-left",
|
||||
@@ -750,7 +771,7 @@ function createInput(title, opts)
|
||||
isRequired = opts[i].isRequired,
|
||||
label = opts[i].label or opts[i].text,
|
||||
name = opts[i].name,
|
||||
default = opts[i].options[1].value,
|
||||
default = opts[i].default or opts[i].options[1].value,
|
||||
options = opts[i].options,
|
||||
}
|
||||
end
|
||||
@@ -767,6 +788,7 @@ function createInput(title, opts)
|
||||
options[i] = {
|
||||
type = "input",
|
||||
label = opts[i].text ..(opts[i].txt and " - "..opts[i].txt or ""),
|
||||
default = opts[i].default,
|
||||
isRequired = opts[i].isRequired,
|
||||
}
|
||||
end
|
||||
@@ -923,24 +945,49 @@ end
|
||||
function getVehicleProperties(vehicle)
|
||||
local properties = {}
|
||||
if vehicle == nil then return nil end
|
||||
if GetResourceState(OXLibExport):find("start") then
|
||||
properties = lib.getVehicleProperties(vehicle)
|
||||
elseif GetResourceState(QBExport):find("start") then
|
||||
if GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then
|
||||
properties = Core.Functions.GetVehicleProperties(vehicle)
|
||||
if Config.System.Debug then print("^6Bridge^7: ^2Getting Vehicle Properties ^7[^6"..QBExport.."^7] - [^3"..vehicle.."^7] - [^3"..GetEntityModel(vehicle).."^7/^3"..properties.model.."^7] - [^3"..properties.plate.."^7]") end
|
||||
elseif GetResourceState(OXLibExport):find("start") then
|
||||
properties = lib.getVehicleProperties(vehicle)
|
||||
if Config.System.Debug then print("^6Bridge^7: ^2Getting Vehicle Properties ^7[^6"..OXLibExport.."^7] - [^3"..vehicle.."^7] - [^3"..GetEntityModel(vehicle).."^7/^3"..properties.model.."^7] - [^3"..properties.plate.."^7]") end
|
||||
end
|
||||
return properties
|
||||
end
|
||||
|
||||
function setVehicleProperties(vehicle, props)
|
||||
if not DoesEntityExist(vehicle) then
|
||||
print(("Unable to set vehicle properties for '%s' (entity does not exist)"):
|
||||
format(vehicle))
|
||||
local oldProps = getVehicleProperties(vehicle)
|
||||
if checkDifferences(vehicle, props) then
|
||||
--if Config.System.Debug then debugDifferences(vehicle, props) end
|
||||
if not DoesEntityExist(vehicle) then
|
||||
print(("Unable to set vehicle properties for '%s' (entity does not exist)"):
|
||||
format(vehicle))
|
||||
end
|
||||
if GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then
|
||||
Core.Functions.SetVehicleProperties(vehicle, props)
|
||||
if Config.System.Debug then print("^6Bridge^7: ^2Setting Vehicle Properties ^7[^6"..QBExport.."^7] - [^3"..vehicle.."^7] - [^3"..GetEntityModel(vehicle).."^7/^3"..props.model.."^7] - [^3"..props.plate.."^7]") end
|
||||
else
|
||||
TriggerServerEvent(GetCurrentResourceName()..":ox:setVehicleProperties", VehToNet(vehicle), props)
|
||||
end
|
||||
else
|
||||
if Config.System.Debug then print("^6Bridge^7: ^2No Changes Found ^7 [^3"..vehicle.."^7] - [^3"..GetEntityModel(vehicle).."^7/^3"..props.model.."^7] - [^3"..props.plate.."^7]") end
|
||||
end
|
||||
if GetResourceState(OXLibExport):find("start") then
|
||||
TriggerServerEvent(GetCurrentResourceName()..":ox:setVehicleProperties", VehToNet(vehicle), props)
|
||||
elseif GetResourceState(QBExport):find("start") then
|
||||
Core.Functions.SetVehicleProperties(vehicle, props)
|
||||
end
|
||||
|
||||
function checkDifferences(vehicle, newProps)
|
||||
local oldProps = getVehicleProperties(vehicle)
|
||||
if Config.System.Debug then print("^6Bridge^7: ^2Finding differences in ^3Vehicle Properties^7") end
|
||||
local allow = false
|
||||
for k in pairs(oldProps) do
|
||||
if json.encode(oldProps[k]) ~= json.encode(newProps[k]) then
|
||||
allow = true
|
||||
if Config.System.Debug then
|
||||
print("^6Bridge^7: ^5Old ^7[^3"..k.."^7] - "..json.encode(oldProps[k], { indent = true }))
|
||||
print("^6Bridge^7: ^5New ^7[^3"..k.."^7] - "..json.encode(newProps[k], { indent = true }))
|
||||
end
|
||||
end
|
||||
end
|
||||
return allow
|
||||
end
|
||||
|
||||
RegisterNetEvent(GetCurrentResourceName()..":ox:setVehicleProperties", function(netId, props)
|
||||
@@ -953,6 +1000,7 @@ AddStateBagChangeHandler(GetCurrentResourceName()..':setVehicleProperties', '',
|
||||
if not value or not GetEntityFromStateBagName then return end
|
||||
local entity = GetEntityFromStateBagName(bagName)
|
||||
local networked = not bagName:find('localEntity')
|
||||
if Config.System.Debug then print("^6Bridge^7: ^2Setting Vehicle Properties ^7[^6"..OXLibExport.."^7] - [^3"..entity.."^7] - [^3"..GetEntityModel(entity).."^7] - [^3"..value.plate.."^7]") end
|
||||
|
||||
if networked and NetworkGetEntityOwner(entity) ~= cache.playerId then return end
|
||||
|
||||
@@ -1213,6 +1261,8 @@ function invImg(item)
|
||||
imgLink = "nui://"..QSInv.."/html/images/"..(Items[item].image or "")
|
||||
elseif GetResourceState(CoreInv and CoreInv or ""):find("start") then
|
||||
imgLink = "nui://"..CoreInv.."/html/img/"..(Items[item].image or "")
|
||||
elseif GetResourceState(OrigenInv and OrigenInv or ""):find("start") then
|
||||
imgLink = "nui://"..OrigenInv.."/html/img/"..(Items[item].image or "")
|
||||
elseif GetResourceState(QBInv and QBInv or ""):find("start") then
|
||||
imgLink = "nui://"..QBInv.."/html/images/"..(Items[item].image or "")
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user