mirror of
https://github.com/jimathy/jim_bridge.git
synced 2026-08-17 05:56:02 +01:00
Compare commits
28 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc96bcde34 | ||
|
|
ab61e40567 | ||
|
|
e17e2fb865 | ||
|
|
a6bd82a41c | ||
|
|
fac495c0ef | ||
|
|
15bea85bfb | ||
|
|
f889080bc0 | ||
|
|
7d62358558 | ||
|
|
f7a7e89c56 | ||
|
|
5f6720d37b | ||
|
|
e541201a08 | ||
|
|
2bf04f69cf | ||
|
|
8479aea1b0 | ||
|
|
d17a1da5b2 | ||
|
|
f1ff06c098 | ||
|
|
df785043e8 | ||
|
|
5ae4799a5f | ||
|
|
8cf4a6bd23 | ||
|
|
3e067c8492 | ||
|
|
6847639c65 | ||
|
|
0592c3ebc8 | ||
|
|
2ca1cbd110 | ||
|
|
8642733b78 | ||
|
|
5a4293182c | ||
|
|
6075878038 | ||
|
|
7eaeac886f | ||
|
|
fe27a1ca1c | ||
|
|
0caea0b473 |
170
crafting.lua
170
crafting.lua
@@ -43,7 +43,7 @@ function craftingMenu(data) local hasjob = false
|
|||||||
if Recipes[i].job then hasjob = false
|
if Recipes[i].job then hasjob = false
|
||||||
for l, b in pairs(Recipes[i].job) do
|
for l, b in pairs(Recipes[i].job) do
|
||||||
hasjob = hasJob(l, nil, b)
|
hasjob = hasJob(l, nil, b)
|
||||||
if hasJob == true then break end
|
if hasjob == true then break end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local setheader, settext = "", ""
|
local setheader, settext = "", ""
|
||||||
@@ -139,40 +139,42 @@ function makeItem(data)
|
|||||||
startTempCam(cam)
|
startTempCam(cam)
|
||||||
|
|
||||||
for i = 1, amount do
|
for i = 1, amount do
|
||||||
for _, v in pairs(data.craft) do
|
for k, v in pairs(data.craft) do
|
||||||
if type(v) == "table" then
|
if k ~= "amount" and k ~= "job" then
|
||||||
for l, b in pairs(v) do
|
if type(v) == "table" then
|
||||||
if crafting and progressBar({
|
for l, b in pairs(v) do
|
||||||
label = "Using "..b.." "..Items[l].label,
|
if crafting and progressBar({
|
||||||
time = 1000,
|
label = "Using "..b.." "..Items[l].label,
|
||||||
cancel = true,
|
time = 1000,
|
||||||
dict = 'pickup_object',
|
cancel = true,
|
||||||
anim = "putdown_low",
|
dict = 'pickup_object',
|
||||||
flag = 48,
|
anim = "putdown_low",
|
||||||
icon = l,
|
flag = 48,
|
||||||
}) then
|
icon = l,
|
||||||
--TriggerEvent('inventory:client:ItemBox', Items[l], "use", b) -- Show item box for each item
|
}) then
|
||||||
else
|
--TriggerEvent('inventory:client:ItemBox', Items[l], "use", b) -- Show item box for each item
|
||||||
crafted = false
|
else
|
||||||
crafting = false
|
crafted = false
|
||||||
break
|
crafting = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
Wait(200)
|
||||||
end
|
end
|
||||||
Wait(200)
|
if crafted then
|
||||||
end
|
if crafting and progressBar({
|
||||||
if crafted then
|
label = bartext..Items[data.item].label,
|
||||||
if crafting and progressBar({
|
time = bartime,
|
||||||
label = bartext..Items[data.item].label,
|
cancel = true,
|
||||||
time = bartime,
|
dict = animDict,
|
||||||
cancel = true,
|
anim = anim,
|
||||||
dict = animDict,
|
flag = 8,
|
||||||
anim = anim,
|
icon = data.item,
|
||||||
flag = 8,
|
}) then
|
||||||
icon = data.item,
|
TriggerServerEvent(GetCurrentResourceName()..":Crafting:GetItem", data.item, data.craft, data.stashName)
|
||||||
}) then
|
else
|
||||||
TriggerServerEvent(GetCurrentResourceName()..":Crafting:GetItem", data.item, data.craft, data.stashName)
|
crafting = false
|
||||||
else
|
break
|
||||||
crafting = false
|
end
|
||||||
break
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -240,10 +242,29 @@ function hasItem(items, amount, src) local amount = amount and amount or 1
|
|||||||
else grabInv = exports[QSInv]:getUserInventory()
|
else grabInv = exports[QSInv]:getUserInventory()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
elseif GetResourceState(OrigenInv):find("start") then
|
||||||
|
foundInv = OrigenInv
|
||||||
|
if src then
|
||||||
|
grabInv = exports[OrigenInv]:getPlayerInventory(src)
|
||||||
|
else
|
||||||
|
grabInv = exports[OrigenInv]:getPlayerInventory()
|
||||||
|
end
|
||||||
|
|
||||||
elseif GetResourceState(CoreInv):find("start") then
|
elseif GetResourceState(CoreInv):find("start") then
|
||||||
foundInv = CoreInv
|
foundInv = CoreInv
|
||||||
if src then grabInv = exports['core_inventory']:getInventory('primary-'..src)
|
if src then
|
||||||
else grabInv = exports[CoreInv]:getInventory('primary-'..GetPlayerServerId(PlayerPedId()))
|
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
|
end
|
||||||
|
|
||||||
elseif GetResourceState(CodeMInv):find("start") then
|
elseif GetResourceState(CodeMInv):find("start") then
|
||||||
@@ -300,38 +321,44 @@ function openStash(data)
|
|||||||
lookEnt(data.coords)
|
lookEnt(data.coords)
|
||||||
end
|
end
|
||||||
|
|
||||||
function getStash(stashName)
|
function getStash(stashName) local stashResource = ""
|
||||||
local stashItems, items = {}, {}
|
local stashItems, items = {}, {}
|
||||||
if GetResourceState(OXInv):find("start") then
|
if GetResourceState(OXInv):find("start") then stashResource = OXInv
|
||||||
if Config.System.Debug then print("^6Bridge^7: ^2Retrieving ^3Stash^2 with ^7ox_inventory") end
|
|
||||||
stashItems = exports[OXInv]:Inventory(stashName).items
|
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
|
elseif GetResourceState(QSInv):find("start") then stashResource = QSInv
|
||||||
stashItems = exports[QSInv]:GetStashItems(stashName)
|
stashItems = exports[QSInv]:GetStashItems(stashName)
|
||||||
elseif GetResourceState(CodeMInv):find("start") then
|
|
||||||
if Config.System.Debug then print("^6Bridge^7: ^2Retrieving ^3Stash^2 with ^7qs-inventory") end
|
elseif GetResourceState(CoreInv):find("start") then stashResource = CoreInv
|
||||||
|
stashItems = exports[CoreInv]:getInventory(stashName)
|
||||||
|
|
||||||
|
elseif GetResourceState(CodeMInv):find("start") then stashResource = CodeMInv
|
||||||
stashItems = exports[CodeMInv]:GetInventoryItems('Stash', stashName)
|
stashItems = exports[CodeMInv]:GetInventoryItems('Stash', stashName)
|
||||||
elseif GetResourceState(QBInv):find("start") then
|
|
||||||
if Config.System.Debug then print("^6Bridge^7: ^2Retrieving ^3Stash^2 with ^7qb-inventory") end
|
elseif GetResourceState(OrigenInv):find("start") then stashResource = OrigenInv
|
||||||
|
stashItems = exports[OrigenInv]:GetStash(stashName)
|
||||||
|
|
||||||
|
elseif GetResourceState(QBInv):find("start") then stashResource = QBInv
|
||||||
local result = MySQL.scalar.await('SELECT items FROM stashitems WHERE stash = ?', { stashName })
|
local result = MySQL.scalar.await('SELECT items FROM stashitems WHERE stash = ?', { stashName })
|
||||||
if result then stashItems = json.decode(result) end
|
if result then stashItems = json.decode(result) end
|
||||||
end
|
end
|
||||||
|
if Config.System.Debug then print("^6Bridge^7: ^2Retrieving ^3Stash^2 with ^7"..stashResource) end
|
||||||
if stashItems then
|
if stashItems then
|
||||||
for _, item in pairs(stashItems) do
|
for _, item in pairs(stashItems) do
|
||||||
local itemInfo = Items[item.name:lower()]
|
local itemInfo = Items[item.name:lower()]
|
||||||
if itemInfo then
|
if itemInfo then
|
||||||
items[item.slot] = {
|
items[#items+1] = {
|
||||||
name = itemInfo["name"],
|
name = itemInfo.name or nil,
|
||||||
amount = tonumber(item.amount) or tonumber(item.count),
|
amount = tonumber(item.amount) or tonumber(item.count),
|
||||||
info = item.info ~= nil and item.info or "",
|
info = item.info or "",
|
||||||
label = itemInfo["label"],
|
label = itemInfo.label or nil,
|
||||||
description = itemInfo["description"] ~= nil and itemInfo["description"] or "",
|
description = itemInfo.description or "",
|
||||||
weight = itemInfo["weight"],
|
weight = itemInfo.weight or nil,
|
||||||
type = itemInfo["type"],
|
type = itemInfo.type or nil,
|
||||||
unique = itemInfo["unique"],
|
unique = itemInfo.unique or nil,
|
||||||
useable = itemInfo["useable"],
|
useable = itemInfo.useable or nil,
|
||||||
image = itemInfo["image"],
|
image = itemInfo.image or nil,
|
||||||
slot = item.slot,
|
slot = itemInfo.slot or nil,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -347,10 +374,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
|
if Config.System.Debug then print("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..OXInv, k, v) end
|
||||||
end
|
end
|
||||||
elseif GetResourceState(QSInv):find("start") then
|
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
|
for k, v in pairs(items) do
|
||||||
exports[QSInv]:RemoveItemIntoStash(stashName, k, v)
|
exports[CoreInv]:removeItemExact(stashName, k, v)
|
||||||
if Config.System.Debug then print("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..QSInv, k, v) end
|
if Config.System.Debug then print("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..CoreInv, k, v) end
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif GetResourceState(CodeMInv):find("start") then
|
elseif GetResourceState(CodeMInv):find("start") 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
|
||||||
@@ -372,6 +419,13 @@ function stashRemoveItem(stashItems, stashName, items) local amount = amount and
|
|||||||
if Config.System.Debug then
|
if Config.System.Debug then
|
||||||
print("^6Bridge^7: ^3saveStash^7: ^2Saving ^3QB^2 stash ^7'^6"..stashName.."^7'")
|
print("^6Bridge^7: ^3saveStash^7: ^2Saving ^3QB^2 stash ^7'^6"..stashName.."^7'")
|
||||||
end
|
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
|
elseif GetResourceState(QBInv):find("start") 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
|
||||||
|
|||||||
@@ -7,8 +7,9 @@ Exports = {
|
|||||||
OXInv = "ox_inventory",
|
OXInv = "ox_inventory",
|
||||||
QBInv = "qb-inventory",
|
QBInv = "qb-inventory",
|
||||||
QSInv = "qs-inventory",
|
QSInv = "qs-inventory",
|
||||||
CoreInv = "core-inventory",
|
CoreInv = "core_inventory",
|
||||||
CodeMInv = "codem-inventory",
|
CodeMInv = "codem-inventory",
|
||||||
|
OrigenInv = "origen_inventory",
|
||||||
|
|
||||||
OXLibExport = "ox_lib",
|
OXLibExport = "ox_lib",
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
function playAnim(animDict, animName, duration, flag, ped)
|
||||||
loadAnimDict(animDict)
|
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
|
end
|
||||||
|
|
||||||
function stopAnim(animDict, animName)
|
function stopAnim(animDict, animName)
|
||||||
@@ -193,22 +193,12 @@ end
|
|||||||
function ensureNetToVeh(vehNetID)
|
function ensureNetToVeh(vehNetID)
|
||||||
if Config.System.Debug then print("^6Bridge^7: ^3ensureNetToVeh^7: ^2Requesting NetworkDoesNetworkIdExist^7(^6"..vehNetID.."^7)") end
|
if Config.System.Debug then print("^6Bridge^7: ^3ensureNetToVeh^7: ^2Requesting NetworkDoesNetworkIdExist^7(^6"..vehNetID.."^7)") end
|
||||||
local timeout = 100
|
local timeout = 100
|
||||||
while not NetworkDoesNetworkIdExist(vehNetID) and timeout > 0 do
|
while not NetworkDoesNetworkIdExist(vehNetID) and timeout > 0 do timeout -= 1 Wait(10) end
|
||||||
timeout -= 1
|
if not NetworkDoesNetworkIdExist(vehNetID) then return 0 end
|
||||||
Wait(10)
|
|
||||||
end
|
|
||||||
if not NetworkDoesNetworkIdExist(vehNetID) then
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
timeout = 100
|
timeout = 100
|
||||||
local vehicle = NetToVeh(vehNetID)
|
local vehicle = NetToVeh(vehNetID)
|
||||||
while not DoesEntityExist(vehicle) and vehicle ~= 0 and timeout > 0 do
|
while not DoesEntityExist(vehicle) and vehicle ~= 0 and timeout > 0 do timeout -= 1 Wait(10) end
|
||||||
timeout -= 1
|
if not DoesEntityExist(vehicle) then return 0 end
|
||||||
Wait(10)
|
|
||||||
end
|
|
||||||
if not DoesEntityExist(vehicle) then
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
return vehicle
|
return vehicle
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -513,7 +503,7 @@ function setThirst(src, thirst)
|
|||||||
if GetResourceState(ESXExport):find("start") then
|
if GetResourceState(ESXExport):find("start") then
|
||||||
TriggerClientEvent('esx_status:add', src, 'thirst', thirst)
|
TriggerClientEvent('esx_status:add', src, 'thirst', thirst)
|
||||||
elseif GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then
|
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)
|
Player.Functions.SetMetaData('thirst', thirst)
|
||||||
TriggerClientEvent("hud:client:UpdateNeeds", src, thirst, Player.PlayerData.metadata.thirst)
|
TriggerClientEvent("hud:client:UpdateNeeds", src, thirst, Player.PlayerData.metadata.thirst)
|
||||||
end
|
end
|
||||||
@@ -523,7 +513,7 @@ function setHunger(src, hunger)
|
|||||||
if GetResourceState(ESXExport):find("start") then
|
if GetResourceState(ESXExport):find("start") then
|
||||||
TriggerClientEvent('esx_status:add', src, 'hunger', hunger)
|
TriggerClientEvent('esx_status:add', src, 'hunger', hunger)
|
||||||
elseif GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then
|
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)
|
Player.Functions.SetMetaData('hunger', hunger)
|
||||||
TriggerClientEvent("hud:client:UpdateNeeds", src, hunger, Player.PlayerData.metadata.hunger)
|
TriggerClientEvent("hud:client:UpdateNeeds", src, hunger, Player.PlayerData.metadata.hunger)
|
||||||
end
|
end
|
||||||
@@ -586,21 +576,35 @@ RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give,
|
|||||||
if Config.System.Debug then
|
if Config.System.Debug then
|
||||||
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")
|
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
|
end
|
||||||
|
|
||||||
elseif GetResourceState(QSInv):find("start") then
|
elseif GetResourceState(QSInv):find("start") then
|
||||||
local success = exports[QSInv]:RemoveItem(src, item, amount)
|
local success = exports[QSInv]:RemoveItem(src, item, amount)
|
||||||
if Config.System.Debug then
|
if Config.System.Debug then
|
||||||
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")
|
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
|
end
|
||||||
elseif GetResourceState(CoreInv):find("start") then
|
|
||||||
local success = exports[CoreInv]:removeItemExact('primary-'..src, item, amount)
|
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
|
||||||
if Config.System.Debug then
|
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")
|
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
|
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)
|
local success = exports[CodeMInv]:RemoveItem(src, item, amount)
|
||||||
if Config.System.Debug then
|
if Config.System.Debug then
|
||||||
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")
|
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
|
end
|
||||||
|
|
||||||
elseif GetResourceState(QBInv):find("start") then
|
elseif GetResourceState(QBInv):find("start") then
|
||||||
while remamount > 0 do
|
while remamount > 0 do
|
||||||
if Core.Functions.GetPlayer(src).Functions.RemoveItem(item, 1) then end
|
if Core.Functions.GetPlayer(src).Functions.RemoveItem(item, 1) then end
|
||||||
@@ -625,21 +629,35 @@ RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give,
|
|||||||
if Config.System.Debug then
|
if Config.System.Debug then
|
||||||
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")
|
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
|
end
|
||||||
|
|
||||||
elseif GetResourceState(QSInv):find("start") then
|
elseif GetResourceState(QSInv):find("start") then
|
||||||
local success = exports[QSInv]:AddItem(src, item, amount)
|
local success = exports[QSInv]:AddItem(src, item, amount)
|
||||||
if Config.System.Debug then
|
if Config.System.Debug then
|
||||||
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")
|
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
|
end
|
||||||
|
|
||||||
elseif GetResourceState(CoreInv):find("start") then
|
elseif GetResourceState(CoreInv):find("start") then
|
||||||
local success = exports[CoreInv]:addItem('primary-'..src, item, amount)
|
if GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then
|
||||||
if Config.System.Debug 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")
|
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
|
end
|
||||||
|
|
||||||
elseif GetResourceState(CodeMInv):find("start") then
|
elseif GetResourceState(CodeMInv):find("start") then
|
||||||
local success = exports[CodeMInv]:AddItem(src, item, amount)
|
local success = exports[CodeMInv]:AddItem(src, item, amount)
|
||||||
if Config.System.Debug then
|
if Config.System.Debug then
|
||||||
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")
|
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
|
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
|
elseif GetResourceState(QBInv):find("start") then
|
||||||
if Core.Functions.GetPlayer(src).Functions.AddItem(item, amount or 1) then
|
if Core.Functions.GetPlayer(src).Functions.AddItem(item, amount or 1) then
|
||||||
--if Config.Crafting.showItemBox then
|
--if Config.Crafting.showItemBox then
|
||||||
@@ -649,6 +667,7 @@ RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give,
|
|||||||
if Config.System.Debug then
|
if Config.System.Debug then
|
||||||
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")
|
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
|
end
|
||||||
|
|
||||||
else
|
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
|
||||||
@@ -685,12 +704,12 @@ local function CheckVersion()
|
|||||||
PerformHttpRequest('https://raw.githubusercontent.com/jimathy/'..GetCurrentResourceName()..'/master/version.txt', function(err, freeVersion, headers)
|
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
|
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"
|
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("^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!")
|
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)
|
end)
|
||||||
else
|
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("^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!")
|
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
|
end
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
name "Jim_Bridge"
|
name "Jim_Bridge"
|
||||||
author "Jimathy"
|
author "Jimathy"
|
||||||
version "1.0.4"
|
version "1.0.8"
|
||||||
description "Framework Bridge By Jimathy"
|
description "Framework Bridge By Jimathy"
|
||||||
fx_version "cerulean"
|
fx_version "cerulean"
|
||||||
game "gta5"
|
game "gta5"
|
||||||
@@ -11,4 +11,4 @@ files {
|
|||||||
'functions.lua',
|
'functions.lua',
|
||||||
'wrapper.lua',
|
'wrapper.lua',
|
||||||
'crafting.lua',
|
'crafting.lua',
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
1.0.4
|
1.0.8
|
||||||
|
|||||||
359
wrapper.lua
359
wrapper.lua
@@ -1,29 +1,21 @@
|
|||||||
Items, Vehicles, Jobs, Gangs, Core, ESX = {}, nil, nil, nil, nil, nil
|
Items, Vehicles, Jobs, Gangs, Core, ESX = {}, nil, nil, nil, nil, nil
|
||||||
|
|
||||||
OXLibExport = Exports and Exports.OXLibExport or ""
|
Exports.QBInv = GetResourceState("ps-inventory"):find("start") and "ps-inventory" or GetResourceState("lj-inventory"):find("start") and "lj-inventory" or ""
|
||||||
|
|
||||||
QBXExport = Exports and Exports.QBXExport or ""
|
OXLibExport, QBXExport, QBExport, ESXExport, OXCoreExport = Exports.OXLibExport or "", Exports.QBXExport or "", Exports.QBExport or "", Exports.ESXExport or "", Exports.OXCoreExport or ""
|
||||||
QBExport = Exports and Exports.QBExport or ""
|
|
||||||
ESXExport = Exports and Exports.ESXExport or ""
|
|
||||||
OXCoreExport = Exports and Exports.OXCoreExport or ""
|
|
||||||
|
|
||||||
OXInv = Exports and Exports.OXInv or ""
|
OXInv, QBInv, QSInv, CoreInv, CodeMInv, OrigenInv = Exports.OXInv or "", Exports.QBInv or "", Exports.QSInv or "", Exports.CoreInv or "", Exports.CodeMInv or "", Exports.OrigenInv or ""
|
||||||
QBInv = Exports and Exports.QBInv or ""
|
|
||||||
QSInv = Exports and Exports.QSInv or ""
|
|
||||||
CoreInv = Exports and Exports.CoreInv or ""
|
|
||||||
CodeMInv = Exports and Exports.CodeMInv or ""
|
|
||||||
|
|
||||||
QBMenuExport = Exports and Exports.QBMenuExport or ""
|
QBMenuExport = Exports.QBMenuExport or ""
|
||||||
|
|
||||||
QBTargetExport = Exports and Exports.QBTargetExport or ""
|
QBTargetExport, OXTargetExport = Exports.QBTargetExport or "", Exports.OXTargetExport or ""
|
||||||
OXTargetExport = Exports and Exports.OXTargetExport or ""
|
|
||||||
|
|
||||||
function CheckBridgeVersion()
|
function CheckBridgeVersion()
|
||||||
if IsDuplicityVersion() then
|
if IsDuplicityVersion() then
|
||||||
local currentVersion = "^3"..GetResourceMetadata("jim_bridge", 'version'):gsub("%.", "^7.^3").."^7"
|
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)
|
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
|
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!")
|
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)
|
||||||
end
|
end
|
||||||
@@ -34,148 +26,146 @@ for k, v in pairs(Exports) do
|
|||||||
if GetResourceState(v):find("start") then print("^6Bridge^7: '^3"..v.."^7' ^2export found ^7") end
|
if GetResourceState(v):find("start") then print("^6Bridge^7: '^3"..v.."^7' ^2export found ^7") end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Load item lists
|
local loadItems = function() local itemResource = ""
|
||||||
if GetResourceState(OXInv):find("start") then
|
if GetResourceState(OXInv):find("start") then
|
||||||
print("^6Bridge^7: ^2Loading ^3Items^2 from ^7"..OXInv)
|
itemResource = OXInv
|
||||||
Items = exports[OXInv]:Items()
|
Items = exports[OXInv]:Items()
|
||||||
for k, v in pairs(Items) do
|
for k, v in pairs(Items) do
|
||||||
if v.client then
|
if v.client and v.client.image then
|
||||||
if v.client.image then Items[k].image = (Items[k].client.image):gsub("nui://"..OXInv.."/web/images/","")
|
Items[k].image = (v.client.image):gsub("nui://"..OXInv.."/web/images/", "")
|
||||||
else Items[k].image = k..".png" end
|
else
|
||||||
if v.client.hunger then Items[k].hunger = v.client.hunger end
|
Items[k].image = k..".png"
|
||||||
if v.client.thirst then Items[k].thirst = v.client.thirst end
|
end
|
||||||
|
Items[k].hunger = v.client and v.client.hunger or nil
|
||||||
|
Items[k].thirst = v.client and v.client.thirst or nil
|
||||||
end
|
end
|
||||||
end
|
elseif GetResourceState(QBExport):find("start") then
|
||||||
elseif GetResourceState(QBExport):find("start") then
|
itemResource = QBExport
|
||||||
print("^6Bridge^7: ^2Loading ^3Items^2 from ^7"..QBExport)
|
|
||||||
Core = Core or exports[QBExport]:GetCoreObject()
|
|
||||||
Items = Core.Shared.Items
|
|
||||||
elseif GetResourceState(ESXExport):find("start") then
|
|
||||||
print("^6Bridge^7: ^2Loading ^3Items^2 from ^7"..ESXExport)
|
|
||||||
ESX = exports[ESXExport]:getSharedObject()
|
|
||||||
Items = ESX.Items
|
|
||||||
else
|
|
||||||
print("^4ERROR^7: ^2No Core Items detected ^7- ^2Check ^3exports^1.^2lua^7")
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Load Vehicles
|
|
||||||
if GetResourceState(QBXExport):find("start") then
|
|
||||||
Core = Core or exports[QBExport]:GetCoreObject()
|
|
||||||
print("^6Bridge^7: ^2Loading ^3Vehicles^2 from ^7"..QBXExport)
|
|
||||||
Vehicles = exports[QBXExport]:GetVehiclesByHash()
|
|
||||||
elseif GetResourceState(QBExport):find("start") then
|
|
||||||
print("^6Bridge^7: ^2Loading ^3Vehicles^2 from ^7"..QBExport)
|
|
||||||
Core = Core or exports[QBExport]:GetCoreObject()
|
|
||||||
RegisterNetEvent('QBCore:Client:UpdateObject', function()
|
|
||||||
Core = Core or exports[QBExport]:GetCoreObject()
|
Core = Core or exports[QBExport]:GetCoreObject()
|
||||||
end)
|
Items = Core and Core.Shared.Items or nil
|
||||||
Vehicles = Core.Shared.Vehicles
|
elseif GetResourceState(ESXExport):find("start") then
|
||||||
elseif GetResourceState(OXCoreExport):find("start") then
|
itemResource = ESXExport
|
||||||
print("^6Bridge^7: ^2Loading ^3Vehicles^2 from ^7"..OXCoreExport)
|
ESX = exports[ESXExport]:getSharedObject()
|
||||||
for k, v in pairs(Ox.GetVehicleData()) do
|
Items = ESX and ESX.Items or nil
|
||||||
Vehicles = Vehicles or {}
|
end
|
||||||
Vehicles[k] = { model = k, price = v.price, name = v.name, brand = v.make }
|
if not Items then
|
||||||
|
print("^4ERROR^7: ^2No Core Items detected ^7- ^2Check ^3exports^1.^2lua^7")
|
||||||
|
else
|
||||||
|
print("^6Bridge^7: ^2Loading ^6"..countTable(Items).." ^3Items^2 from ^7" .. itemResource)
|
||||||
end
|
end
|
||||||
elseif GetResourceState(ESXExport):find("start") then
|
|
||||||
print("^6Bridge^7: ^2Loading ^3Vehicles^2 from ^7"..ESXExport)
|
|
||||||
CreateThread(function()
|
|
||||||
if IsDuplicityVersion() then
|
|
||||||
createCallback(GetCurrentResourceName()..":getVehiclesPrices", function(source)
|
|
||||||
Vehicles = MySQL.query.await('SELECT model, price, name FROM vehicles')
|
|
||||||
return Vehicles
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
if not IsDuplicityVersion() then
|
|
||||||
local TempVehicles = triggerCallback(GetCurrentResourceName()..":getVehiclesPrices")
|
|
||||||
for _, v in pairs(TempVehicles) do
|
|
||||||
Vehicles = Vehicles or {}
|
|
||||||
Vehicles[v.model] = { model = v.model, price = v.price, name = v.name, brand = GetMakeNameFromVehicleModel(v.model):lower():gsub("^%l", string.upper) }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
else
|
|
||||||
print("^4ERROR^7: ^2No Vehicle info detected ^7- ^2Check ^3exports^1.^2lua^7")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Load Jobs
|
local loadVehicles = function() local vehResource = ""
|
||||||
if GetResourceState(QBXExport):find("start") then
|
if GetResourceState(QBXExport):find("start") or GetResourceState(QBExport):find("start") then vehResource = QBExport
|
||||||
Core = Core or exports[QBExport]:GetCoreObject()
|
Core = Core or exports[QBExport]:GetCoreObject()
|
||||||
print("^6Bridge^7: ^2Loading ^3Jobs^7/^3Gangs^2 from ^7"..QBXExport)
|
if GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then
|
||||||
Jobs = exports[QBXExport]:GetJobs()
|
RegisterNetEvent('QBCore:Client:UpdateObject', function()
|
||||||
Gangs = exports[QBXExport]:GetGangs()
|
Core = Core or exports[QBExport]:GetCoreObject()
|
||||||
|
|
||||||
elseif GetResourceState(OXCoreExport):find("start") then
|
|
||||||
print("^6Bridge^7: ^2Loading ^3Jobs^7/^3Gangs^2 from ^7"..OXCoreExport)
|
|
||||||
CreateThread(function()
|
|
||||||
if IsDuplicityVersion() then
|
|
||||||
createCallback(GetCurrentResourceName()..":getOxGroups", function(source)
|
|
||||||
Jobs = MySQL.query.await('SELECT * FROM `ox_groups`')
|
|
||||||
return Jobs
|
|
||||||
end)
|
end)
|
||||||
else
|
end
|
||||||
local TempJobs = triggerCallback(GetCurrentResourceName()..":getOxGroups")
|
Vehicles = Core and Core.Shared.Vehicles
|
||||||
for k, v in pairs(TempJobs) do
|
elseif GetResourceState(OXCoreExport):find("start") then vehResource = OXCoreExport
|
||||||
local grades = {}
|
Vehicles = {}
|
||||||
for i = 1, #v.grades do grades[i] = { name = grades[i], isboss = (i == #v.grades)} end
|
for k, v in pairs(Ox.GetVehicleData()) do
|
||||||
Jobs = Jobs or {}
|
Vehicles[k] = { model = k, price = v.price, name = v.name, brand = v.make }
|
||||||
Jobs[v.name] = { label = v.label, grades = grades, }
|
end
|
||||||
|
elseif GetResourceState(ESXExport):find("start") then vehResource = ESXExport
|
||||||
|
CreateThread(function()
|
||||||
|
if IsDuplicityVersion() then
|
||||||
|
createCallback(GetCurrentResourceName()..":getVehiclesPrices", function(source)
|
||||||
|
Vehicles = MySQL.query.await('SELECT model, price, name FROM vehicles')
|
||||||
|
return Vehicles
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
local TempVehicles = triggerCallback(GetCurrentResourceName()..":getVehiclesPrices")
|
||||||
|
for _, v in pairs(TempVehicles) do
|
||||||
|
Vehicles = Vehicles or {}
|
||||||
|
Vehicles[v.model] = { model = v.model, price = v.price, name = v.name, brand = GetMakeNameFromVehicleModel(v.model):lower():gsub("^%l", string.upper) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end)
|
||||||
end)
|
|
||||||
|
|
||||||
elseif GetResourceState(QBExport):find("start") then
|
|
||||||
print("^6Bridge^7: ^2Loading ^3Jobs^7/^3Gangs^2 from ^7"..QBExport)
|
|
||||||
Core = Core or Core or exports[QBExport]:GetCoreObject()
|
|
||||||
RegisterNetEvent('QBCore:Client:UpdateObject', function() Core = Core or exports[QBExport]:GetCoreObject() end)
|
|
||||||
Jobs = Core.Shared.Jobs
|
|
||||||
Gangs = Core.Shared.Gangs
|
|
||||||
|
|
||||||
elseif GetResourceState(ESXExport):find("start") then
|
|
||||||
print("^6Bridge^7: ^2Loading ^3Jobs^7/^3Gangs^2 from ^7"..ESXExport)
|
|
||||||
ESX = exports[ESXExport]:getSharedObject()
|
|
||||||
if IsDuplicityVersion() then
|
|
||||||
Jobs = ESX.GetJobs()
|
|
||||||
for k, v in pairs(Jobs) do
|
|
||||||
local count = countTable(Jobs[k].grades)-1
|
|
||||||
Jobs[k].grades[tostring(count)].isBoss = true
|
|
||||||
end
|
|
||||||
Gangs = Jobs
|
|
||||||
end
|
end
|
||||||
CreateThread(function()
|
local timeout = 1000 while not Vehicles and timeout > 0 do timeout -=1 Wait(0) end
|
||||||
while not ESX do Wait(0) end
|
if not Vehicles then
|
||||||
|
print("^4ERROR^7: ^2No Vehicle info detected ^7- ^2Check ^3exports^1.^2lua^7")
|
||||||
|
else
|
||||||
|
print("^6Bridge^7: ^2Loading ^6"..countTable(Vehicles).." ^3Vehicles^2 from ^7"..vehResource)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local loadJobs = function() local jobResource = ""
|
||||||
|
if GetResourceState(QBXExport):find("start") then jobResource = QBXExport
|
||||||
|
Core = Core or exports[QBExport]:GetCoreObject()
|
||||||
|
Jobs, Gangs = exports[QBXExport]:GetJobs(), exports[QBXExport]:GetGangs()
|
||||||
|
|
||||||
|
elseif GetResourceState(OXCoreExport):find("start") then jobResource = OXExport
|
||||||
|
CreateThread(function()
|
||||||
|
if IsDuplicityVersion() then
|
||||||
|
createCallback(GetCurrentResourceName()..":getOxGroups", function(source)
|
||||||
|
Jobs = MySQL.query.await('SELECT * FROM `ox_groups`') return Jobs
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
local TempJobs = triggerCallback(GetCurrentResourceName()..":getOxGroups")
|
||||||
|
Jobs = TempJobs and {}
|
||||||
|
for k, v in pairs(TempJobs) do
|
||||||
|
local grades = {}
|
||||||
|
for i = 1, #v.grades do grades[i] = { name = v.grades[i], isboss = (i == #v.grades)} end
|
||||||
|
Jobs[v.name] = { label = v.label, grades = grades }
|
||||||
|
end
|
||||||
|
Gangs = Jobs
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
elseif GetResourceState(QBExport):find("start") then jobResource = QBExport
|
||||||
|
Core = Core or Core or exports[QBExport]:GetCoreObject()
|
||||||
|
RegisterNetEvent('QBCore:Client:UpdateObject', function() Core = Core or exports[QBExport]:GetCoreObject() end)
|
||||||
|
Jobs, Gangs = Core.Shared.Jobs, Core.Shared.Gangs
|
||||||
|
|
||||||
|
elseif GetResourceState(ESXExport):find("start") then jobResource = ESXExport
|
||||||
|
ESX = exports[ESXExport]:getSharedObject()
|
||||||
if IsDuplicityVersion() then
|
if IsDuplicityVersion() then
|
||||||
createCallback(GetCurrentResourceName()..":getJobs", function(source)
|
Jobs = ESX.GetJobs()
|
||||||
return Jobs
|
for k, v in pairs(Jobs) do
|
||||||
end)
|
local count = countTable(Jobs[k].grades) - 1
|
||||||
end
|
Jobs[k].grades[tostring(count)].isBoss = true
|
||||||
if not IsDuplicityVersion() then
|
end
|
||||||
Jobs = triggerCallback(GetCurrentResourceName()..":getJobs")
|
|
||||||
Gangs = Jobs
|
Gangs = Jobs
|
||||||
end
|
end
|
||||||
end)
|
CreateThread(function()
|
||||||
else
|
while not ESX do Wait(0) end
|
||||||
print("^4ERROR^7: ^2No Job/Gang ifo detected ^7- ^2Check ^3exports^1.^2lua^7")
|
if IsDuplicityVersion() then
|
||||||
|
createCallback(GetCurrentResourceName()..":getJobs", function(source)
|
||||||
|
return Jobs
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
Jobs = triggerCallback(GetCurrentResourceName()..":getJobs")
|
||||||
|
Gangs = Jobs
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
local timeout = 1000 while not Jobs and timeout > 0 do timeout -=1 Wait(0) end
|
||||||
|
if Jobs then
|
||||||
|
print("^6Bridge^7: ^2Loading ^6"..countTable(Jobs).." ^3Jobs^2 from ^7"..jobResource)
|
||||||
|
print("^6Bridge^7: ^2Loading ^6"..countTable(Gangs).." ^3Gangs^2 from ^7"..jobResource)
|
||||||
|
else
|
||||||
|
print("^4ERROR^7: ^2No Job/Gang info detected ^7- ^2Check ^3exports^1.^2lua^7")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
loadItems()
|
||||||
|
loadVehicles()
|
||||||
|
loadJobs()
|
||||||
|
|
||||||
function makeBossRoles(role)
|
function makeBossRoles(role)
|
||||||
local boss = {}
|
local boss = {}
|
||||||
if Jobs and Jobs[role] then
|
local data = Jobs and Jobs[role] or Gangs and Gangs[role]
|
||||||
for grade in pairs(Jobs[role].grades) do
|
if data then
|
||||||
if Jobs[role].grades[grade].isboss then
|
for grade, info in pairs(data.grades) do
|
||||||
if boss[role] then
|
if info.isboss then
|
||||||
if boss[role] > tonumber(grade) then boss[role] = tonumber(grade) end
|
boss[role] = boss[role] and math.min(boss[role], tonumber(grade)) or tonumber(grade)
|
||||||
else boss[role] = tonumber(grade) end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif Gangs and Gangs[role] then
|
|
||||||
for grade in pairs(Gangs[role].grades) do
|
|
||||||
if Gangs[role].grades[grade].isboss then
|
|
||||||
if boss[role] then
|
|
||||||
if boss[role] > tonumber(grade) then boss[role] = tonumber(grade) end
|
|
||||||
else boss[role] = tonumber(grade) end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return boss
|
return boss
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -223,19 +213,26 @@ end
|
|||||||
|
|
||||||
function openMenu(Menu, data)
|
function openMenu(Menu, data)
|
||||||
if Config.System.Menu == "ox" then
|
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",
|
table.insert(Menu, 1, { icon = "fas fa-circle-arrow-left",
|
||||||
title = "Return",
|
title = "Return",
|
||||||
onSelect = data.onBack,
|
onSelect = data.onBack,
|
||||||
|
label = "Return"
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
for k in pairs(Menu) do
|
for k in pairs(Menu) do
|
||||||
|
if data.onSelected and Menu[k].arrow then
|
||||||
|
Menu[k].icon = "fas fa-angle-right"
|
||||||
|
end
|
||||||
if not Menu[k].title then
|
if not Menu[k].title then
|
||||||
if Menu[k].header ~= nil and Menu[k].header ~= "" then
|
if Menu[k].header ~= nil and Menu[k].header ~= "" then
|
||||||
Menu[k].title = Menu[k].header
|
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
|
if Menu[k].txt then Menu[k].description = Menu[k].txt else Menu[k].description = "" end
|
||||||
else
|
else
|
||||||
Menu[k].title = Menu[k].txt
|
Menu[k].title = Menu[k].txt
|
||||||
|
Menu[k].label = Menu[k].txt
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if Menu[k].params then
|
if Menu[k].params then
|
||||||
@@ -246,8 +243,35 @@ function openMenu(Menu, data)
|
|||||||
Menu[k].disabled = true
|
Menu[k].disabled = true
|
||||||
end
|
end
|
||||||
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, })
|
local menuID = 'Menu'
|
||||||
lib.showContext("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)
|
||||||
|
if Menu[x].refresh then
|
||||||
|
if Menu[x].onSelect then
|
||||||
|
Menu[x].onSelect()
|
||||||
|
end
|
||||||
|
lib.showMenu(menuID, index)
|
||||||
|
else
|
||||||
|
if Menu[x].onSelect then
|
||||||
|
Menu[x].onSelect()
|
||||||
|
else
|
||||||
|
lib.showMenu(menuID, index)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end) or nil))
|
||||||
|
if data.onSelected then
|
||||||
|
lib.showMenu(menuID, 1)
|
||||||
|
else
|
||||||
|
lib.showContext(menuID)
|
||||||
|
end
|
||||||
elseif Config.System.Menu == "qb" then
|
elseif Config.System.Menu == "qb" then
|
||||||
if data.onBack then
|
if data.onBack then
|
||||||
table.insert(Menu, 1, { icon = "fas fa-circle-arrow-left",
|
table.insert(Menu, 1, { icon = "fas fa-circle-arrow-left",
|
||||||
@@ -750,7 +774,7 @@ function createInput(title, opts)
|
|||||||
isRequired = opts[i].isRequired,
|
isRequired = opts[i].isRequired,
|
||||||
label = opts[i].label or opts[i].text,
|
label = opts[i].label or opts[i].text,
|
||||||
name = opts[i].name,
|
name = opts[i].name,
|
||||||
default = opts[i].options[1].value,
|
default = opts[i].default or opts[i].options[1].value,
|
||||||
options = opts[i].options,
|
options = opts[i].options,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@@ -767,6 +791,7 @@ function createInput(title, opts)
|
|||||||
options[i] = {
|
options[i] = {
|
||||||
type = "input",
|
type = "input",
|
||||||
label = opts[i].text ..(opts[i].txt and " - "..opts[i].txt or ""),
|
label = opts[i].text ..(opts[i].txt and " - "..opts[i].txt or ""),
|
||||||
|
default = opts[i].default,
|
||||||
isRequired = opts[i].isRequired,
|
isRequired = opts[i].isRequired,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@@ -925,25 +950,49 @@ function getVehicleProperties(vehicle)
|
|||||||
if vehicle == nil then return nil end
|
if vehicle == nil then return nil end
|
||||||
if GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then
|
if GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then
|
||||||
properties = Core.Functions.GetVehicleProperties(vehicle)
|
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
|
elseif GetResourceState(OXLibExport):find("start") then
|
||||||
properties = lib.getVehicleProperties(vehicle)
|
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
|
end
|
||||||
return properties
|
return properties
|
||||||
end
|
end
|
||||||
|
|
||||||
function setVehicleProperties(vehicle, props)
|
function setVehicleProperties(vehicle, props)
|
||||||
if not DoesEntityExist(vehicle) then
|
local oldProps = getVehicleProperties(vehicle)
|
||||||
print(("Unable to set vehicle properties for '%s' (entity does not exist)"):
|
if checkDifferences(vehicle, props) then
|
||||||
format(vehicle))
|
--if Config.System.Debug then debugDifferences(vehicle, props) end
|
||||||
end
|
if not DoesEntityExist(vehicle) then
|
||||||
if GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then
|
print(("Unable to set vehicle properties for '%s' (entity does not exist)"):
|
||||||
if Config.System.Debug then print("^6Bridge^7: ^2Setting Vehicle Properties ^7[^6"..QBExport.."^7] - [^3"..vehicle.."^7] - [^3"..GetEntityModel(vehicle).."^7] - [^3"..props.plate.."^7]") end
|
format(vehicle))
|
||||||
Core.Functions.SetVehicleProperties(vehicle, props)
|
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
|
else
|
||||||
TriggerServerEvent(GetCurrentResourceName()..":ox:setVehicleProperties", VehToNet(vehicle), props)
|
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
|
end
|
||||||
end
|
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)
|
RegisterNetEvent(GetCurrentResourceName()..":ox:setVehicleProperties", function(netId, props)
|
||||||
local vehicle = NetworkGetEntityFromNetworkId(netId)
|
local vehicle = NetworkGetEntityFromNetworkId(netId)
|
||||||
local value = props
|
local value = props
|
||||||
@@ -1215,6 +1264,8 @@ function invImg(item)
|
|||||||
imgLink = "nui://"..QSInv.."/html/images/"..(Items[item].image or "")
|
imgLink = "nui://"..QSInv.."/html/images/"..(Items[item].image or "")
|
||||||
elseif GetResourceState(CoreInv and CoreInv or ""):find("start") then
|
elseif GetResourceState(CoreInv and CoreInv or ""):find("start") then
|
||||||
imgLink = "nui://"..CoreInv.."/html/img/"..(Items[item].image or "")
|
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
|
elseif GetResourceState(QBInv and QBInv or ""):find("start") then
|
||||||
imgLink = "nui://"..QBInv.."/html/images/"..(Items[item].image or "")
|
imgLink = "nui://"..QBInv.."/html/images/"..(Items[item].image or "")
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user