mirror of
https://github.com/jimathy/jim_bridge.git
synced 2026-08-17 05:56:02 +01:00
Compare commits
38 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8642733b78 | ||
|
|
5a4293182c | ||
|
|
6075878038 | ||
|
|
7eaeac886f | ||
|
|
fe27a1ca1c | ||
|
|
0caea0b473 | ||
|
|
370c77433b | ||
|
|
ac85d35097 | ||
|
|
85c3e06910 | ||
|
|
7d0736bfc2 | ||
|
|
b0b011ac56 | ||
|
|
23091c2e73 | ||
|
|
ef2ba3ea7a | ||
|
|
df60f3b2b1 | ||
|
|
4cc001d2f0 | ||
|
|
e2bb32d9de | ||
|
|
725125a274 | ||
|
|
dcf2018ec6 | ||
|
|
e5316f45aa | ||
|
|
02c202d075 | ||
|
|
9e9fb14f55 | ||
|
|
61e0d777a8 | ||
|
|
78c3e33d38 | ||
|
|
3be5b5e1ee | ||
|
|
f550479298 | ||
|
|
5fe0ab8815 | ||
|
|
56ccb43c2b | ||
|
|
93d0754935 | ||
|
|
d82366b59f | ||
|
|
35202f7000 | ||
|
|
bc5aadc394 | ||
|
|
181c480ba6 | ||
|
|
b973c71638 | ||
|
|
ede0a44251 | ||
|
|
e4b0f8601a | ||
|
|
d12c615f0b | ||
|
|
e58163d631 | ||
|
|
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
|
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 just needs to start before any script that requires it
|
||||||
- it can start before core scripts if you want
|
- it can start before core scripts if you want
|
||||||
- for `qb-core` I personally place this script in `resources > [standalone]`
|
- for `qb-core` I personally place this script in `resources > [standalone]`
|
||||||
|
|||||||
261
crafting.lua
261
crafting.lua
@@ -39,6 +39,7 @@ function craftingMenu(data) local hasjob = false
|
|||||||
for i = 1, #Recipes do
|
for i = 1, #Recipes do
|
||||||
for k, v in pairs(Recipes[i]) do
|
for k, v in pairs(Recipes[i]) do
|
||||||
if k ~= "amount" and k ~= "job" and k ~= "gang" then
|
if k ~= "amount" and k ~= "job" and k ~= "gang" then
|
||||||
|
if not Recipes[i]["amount"] then Recipes[i]["amount"] = 1 end
|
||||||
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)
|
||||||
@@ -47,21 +48,17 @@ function craftingMenu(data) local hasjob = false
|
|||||||
end
|
end
|
||||||
local setheader, settext = "", ""
|
local setheader, settext = "", ""
|
||||||
local disable = false
|
local disable = false
|
||||||
local checktable = {}
|
|
||||||
if Recipes[i].job and hasjob == false then else
|
if Recipes[i].job and hasjob == false then else
|
||||||
|
local itemTable = {}
|
||||||
for l, b in pairs(Recipes[i][tostring(k)]) do
|
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] and Items[l].label or "error - "..l)..(b > 1 and " x"..b or "")
|
||||||
settext = settext..(settext ~= "" and br or "")..Items[l].label..(b > 1 and " x"..b or "")
|
itemTable[l] = b
|
||||||
if data.stashName then checktable[l] = stashhasItem(stashItems, l, b)
|
|
||||||
else checktable[l] = hasItem(l, b) end
|
|
||||||
Wait(0)
|
Wait(0)
|
||||||
end
|
end
|
||||||
for _, v in pairs(checktable) do
|
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 not v then
|
if data.stashName then disable = not stashhasItem(stashItems, itemTable)
|
||||||
disable = true
|
else disable = not hasItem(itemTable) end
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
setheader = Items[tostring(k)].label..(Recipes[i]["amount"] > 1 and " x"..Recipes[i]["amount"] or "")..(not disable and " ✔️" or "")
|
setheader = Items[tostring(k)].label..(Recipes[i]["amount"] > 1 and " x"..Recipes[i]["amount"] or "")..(not disable and " ✔️" or "")
|
||||||
Menu[#Menu + 1] = {
|
Menu[#Menu + 1] = {
|
||||||
isMenuHeader = disable,
|
isMenuHeader = disable,
|
||||||
@@ -96,17 +93,20 @@ function multiCraft(data) local Menu = {}
|
|||||||
}
|
}
|
||||||
for k in pairsByKeys(success) do
|
for k in pairsByKeys(success) do
|
||||||
local settext = ""
|
local settext = ""
|
||||||
|
local itemTable = {}
|
||||||
for l, b in pairs(data.craft[data.item]) do
|
for l, b in pairs(data.craft[data.item]) do
|
||||||
if data.stashName then
|
itemTable[l] = (b * k)
|
||||||
success[k] = stashhasItem(stashItems, l, (b * k))
|
|
||||||
else
|
|
||||||
success[k] = hasItem(l, (b * k))
|
|
||||||
end
|
|
||||||
settext = settext..(settext ~= "" and br or "")..Items[l].label..(b*k > 1 and "- x"..b*k or "")
|
settext = settext..(settext ~= "" and br or "")..Items[l].label..(b*k > 1 and "- x"..b*k or "")
|
||||||
Wait(0)
|
Wait(0)
|
||||||
end
|
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] = {
|
Menu[#Menu + 1] = {
|
||||||
isMenuHeader = not success[k],
|
isMenuHeader = disable,
|
||||||
|
arrow = not disable,
|
||||||
header = "Craft - x"..k * data.craft.amount,
|
header = "Craft - x"..k * data.craft.amount,
|
||||||
txt = settext,
|
txt = settext,
|
||||||
onSelect = function ()
|
onSelect = function ()
|
||||||
@@ -224,149 +224,65 @@ function openShop(data)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Client & Server side
|
-- Client & Server side
|
||||||
function hasItem(items, amount, src) local amount, count = amount and amount or 1, 0
|
function hasItem(items, amount, src) local amount = amount and amount or 1
|
||||||
if src then
|
local grabInv = nil
|
||||||
if GetResourceState(OXInv):find("start") then
|
local foundInv = ""
|
||||||
local item = exports[OXInv]:GetItem(src, items)
|
if type(items) ~= "table" then items = { [items] = amount and amount or 1, } end
|
||||||
local amount = (amount or 1)
|
if GetResourceState(OXInv):find("start") then
|
||||||
if item.count >= amount then
|
foundInv = OXInv
|
||||||
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^5FOUND^7 ^3"..item.count.."^7/^3"..amount.." "..tostring(items)) end
|
if src then grabInv = exports.ox_inventory:GetInventoryItems(src)
|
||||||
return true
|
else grabInv = exports[OXInv]:GetPlayerItems()
|
||||||
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
|
|
||||||
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
|
|
||||||
|
|
||||||
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
|
|
||||||
end
|
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(CoreInv):find("start") then
|
||||||
|
foundInv = CoreInv
|
||||||
|
if src then grabInv = exports['core_inventory']:getInventory('primary-'..src)
|
||||||
|
else grabInv = exports[CoreInv]:getInventory('primary-'..GetPlayerServerId(PlayerPedId()))
|
||||||
|
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
|
else
|
||||||
if GetResourceState(OXInv):find("start") then
|
print("^4ERROR^7: ^2No Inventory detected ^7- ^2Check ^3exports^1.^2lua^7")
|
||||||
local count = tonumber(exports[OXInv]:Search('count', items))
|
end
|
||||||
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
|
|
||||||
|
|
||||||
elseif GetResourceState(QSInv):find("start") then
|
if grabInv then
|
||||||
for _, itemData in pairs(exports[QSInv]:getUserInventory()) do
|
local hasTable = {}
|
||||||
if itemData and (itemData.name == items) then
|
for item, amount in pairs(items) do
|
||||||
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
|
if not Items[item] then print("^4ERROR^7: ^2Script can't find ingredient item in Shared Items - ^1"..item.."^7") end
|
||||||
count += (itemData.amount or 1)
|
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
|
||||||
end
|
end
|
||||||
if count >= amount then
|
if count >= amount then
|
||||||
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^5FOUND^7 ^3"..count.."^7/^3"..amount.." "..tostring(items)) end
|
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7[^6"..foundInv.."^7]: "..tostring(item).." ^3"..count.."^7/^3"..amount.." ^5FOUND^7") end
|
||||||
return true
|
hasTable[item] = { hasItem = true, count = count, }
|
||||||
else
|
else
|
||||||
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^2"..tostring(items).." ^1NOT FOUND^7") end
|
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7[^6"..foundInv.."^7]: "..tostring(item).." ^1"..count.."^7/^3"..amount.." ^1NOT FOUND^7") end
|
||||||
return false
|
hasTable[item] = { hasItem = false, count = count, }
|
||||||
end
|
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
|
end
|
||||||
|
for k, v in pairs(hasTable) do if v.hasItem == false then return false, hasTable end end
|
||||||
|
return true, hasTable
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -379,7 +295,7 @@ function openStash(data)
|
|||||||
exports[CodeMInv]:OpenStash(data.stash, 400000, 100)
|
exports[CodeMInv]:OpenStash(data.stash, 400000, 100)
|
||||||
else
|
else
|
||||||
TriggerEvent("inventory:client:SetCurrentStash", data.stash)
|
TriggerEvent("inventory:client:SetCurrentStash", data.stash)
|
||||||
TriggerServerEvent("inventory:server:OpenInventory", "stash", data.stash)
|
TriggerServerEvent("inventory:server:OpenInventory", "stash", data.stash, data.stashOptions)
|
||||||
end
|
end
|
||||||
lookEnt(data.coords)
|
lookEnt(data.coords)
|
||||||
end
|
end
|
||||||
@@ -456,7 +372,7 @@ 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
|
||||||
else
|
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
|
||||||
if stashItems[l].name == k then
|
if stashItems[l].name == k then
|
||||||
@@ -478,26 +394,31 @@ function stashRemoveItem(stashItems, stashName, items) local amount = amount and
|
|||||||
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
|
||||||
MySQL.Async.insert('INSERT INTO stashitems (stash, items) VALUES (:stash, :items) ON DUPLICATE KEY UPDATE items = :items', { ['stash'] = stashName, ['items'] = json.encode(stashItems) })
|
MySQL.Async.insert('INSERT INTO stashitems (stash, items) VALUES (:stash, :items) ON DUPLICATE KEY UPDATE items = :items', { ['stash'] = stashName, ['items'] = json.encode(stashItems) })
|
||||||
|
else
|
||||||
|
print("^4ERROR^7: ^2No Inventory detected ^7- ^2Check ^3exports^1.^2lua^7")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
RegisterNetEvent(GetCurrentResourceName()..":server:stashRemoveItem", stashRemoveItem)
|
RegisterNetEvent(GetCurrentResourceName()..":server:stashRemoveItem", stashRemoveItem)
|
||||||
|
|
||||||
function stashhasItem(stashItems, item, amount) local amount, count = amount and amount or 1, 0
|
function stashhasItem(stashItems, items, amount)
|
||||||
for k, itemData in pairs(stashItems) do
|
local foundInv = ""
|
||||||
if itemData and (itemData.name == item) then
|
if type(items) ~= "table" then items = { [items] = amount and amount or 1, } end
|
||||||
--if Config.System.Debug then
|
local hasTable = {}
|
||||||
-- print("^6Bridge^7: ^3stashHasItem^7: ^2Item^7: '^3"..tostring(item).."^7' ^2Slot^7: ^3"..itemData.slot.." ^7x(^3"..tostring(itemData.amount).."^7)")
|
for item, amount in pairs(items) do
|
||||||
--end
|
local count = 0
|
||||||
count += (itemData.amount or 1)
|
for _, itemData in pairs(stashItems) do
|
||||||
end
|
if itemData and (itemData.name == item) then
|
||||||
end
|
count += (itemData.amount or 1)
|
||||||
if count >= amount then
|
end
|
||||||
if Config.System.Debug then
|
end
|
||||||
print("^6Bridge^7: ^3stashHasItem^7: ^2Items ^3"..item.." ^5FOUND^7 x^3"..count.."^7/^3"..amount.."^7") end
|
if count >= amount then
|
||||||
return
|
if Config.System.Debug then print("^6Bridge^7: ^3stashHasItem^7: ^5FOUND '"..item.."' ^3"..count.."^7/^3"..amount.."^7") end
|
||||||
true
|
hasTable[item] = { hasItem = true, count = count, }
|
||||||
else
|
else
|
||||||
if Config.System.Debug then print("^6Bridge^7: ^3stashHasItem^7: ^2Items ^1NOT FOUND^7 "..json.encode(item)) end
|
if Config.System.Debug then print("^6Bridge^7: ^3stashHasItem^7: ^1NOT FOUND^7 '"..item.."' ^1"..count.."^7/^3"..amount.."^7") end
|
||||||
return false
|
hasTable[item] = { hasItem = false, count = count, }
|
||||||
|
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
|
||||||
@@ -11,7 +11,7 @@ end
|
|||||||
local time = 100
|
local time = 100
|
||||||
function loadModel(model)
|
function loadModel(model)
|
||||||
if not HasModelLoaded(model) then if Config.System.Debug then print("^6Bridge^7: ^2Loading Model^7: '^6"..model.."^7'") end
|
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
|
else time = 1000 print("^6Bridge^7: ^3LoadModel^7: ^2Timed out loading model ^7'^6"..model.."^7'") break end
|
||||||
Wait(10) end
|
Wait(10) end
|
||||||
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)
|
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)
|
||||||
@@ -154,12 +154,14 @@ function lookEnt(entity) local ped = PlayerPedId()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function destroyProp(entity)
|
function destroyProp(entity)
|
||||||
if Config.System.Debug then print("^6Bridge^7: ^2Destroying Prop^7: '^6"..entity.."^7'") end
|
if entity then
|
||||||
if IsEntityAttachedToEntity(entity, PlayerPedId()) then
|
if Config.System.Debug then print("^6Bridge^7: ^2Destroying Prop^7: '^6"..entity.."^7'") end
|
||||||
SetEntityAsMissionEntity(entity)
|
if IsEntityAttachedToEntity(entity, PlayerPedId()) then
|
||||||
DetachEntity(entity, true, true)
|
SetEntityAsMissionEntity(entity)
|
||||||
|
DetachEntity(entity, true, true)
|
||||||
|
end
|
||||||
|
DeleteObject(entity)
|
||||||
end
|
end
|
||||||
DeleteObject(entity)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function pushVehicle(entity)
|
function pushVehicle(entity)
|
||||||
@@ -188,6 +190,28 @@ function pushVehicle(entity)
|
|||||||
end
|
end
|
||||||
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)
|
function makeBlip(data)
|
||||||
local blip = AddBlipForCoord(data.coords)
|
local blip = AddBlipForCoord(data.coords)
|
||||||
SetBlipAsShortRange(blip, true)
|
SetBlipAsShortRange(blip, true)
|
||||||
@@ -549,8 +573,9 @@ end
|
|||||||
|
|
||||||
RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give, item, amount, newsrc)
|
RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give, item, amount, newsrc)
|
||||||
local src = newsrc or source
|
local src = newsrc or source
|
||||||
|
local addremove = (tostring(give) == "true" and "addItem" or "removeItem")
|
||||||
if Config.System.Debug then
|
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
|
end
|
||||||
local remamount = (amount and amount or 1)
|
local remamount = (amount and amount or 1)
|
||||||
if item == nil then return end
|
if item == nil then return end
|
||||||
@@ -559,22 +584,22 @@ RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give,
|
|||||||
if GetResourceState(OXInv):find("start") then
|
if GetResourceState(OXInv):find("start") then
|
||||||
local success = exports[OXInv]:RemoveItem(src, item, (amount and amount or 1), nil)
|
local success = exports[OXInv]:RemoveItem(src, item, (amount and amount or 1), nil)
|
||||||
if Config.System.Debug then
|
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
|
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: ^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
|
end
|
||||||
elseif GetResourceState(CoreInv):find("start") then
|
elseif GetResourceState(CoreInv):find("start") then
|
||||||
local success = exports[CoreInv]:removeItemExact('primary-'..src, item, amount)
|
local success = exports[CoreInv]:removeItemExact('primary-'..src, item, amount)
|
||||||
if Config.System.Debug then
|
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
|
end
|
||||||
elseif GetResourceState(CodeMInv):find("start") then
|
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: ^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
|
end
|
||||||
elseif GetResourceState(QBInv):find("start") then
|
elseif GetResourceState(QBInv):find("start") then
|
||||||
while remamount > 0 do
|
while remamount > 0 do
|
||||||
@@ -585,10 +610,10 @@ RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give,
|
|||||||
TriggerClientEvent('inventory:client:ItemBox', src, Items[item], "remove", (amount and amount or 1))
|
TriggerClientEvent('inventory:client:ItemBox', src, Items[item], "remove", (amount and amount or 1))
|
||||||
end
|
end
|
||||||
if Config.System.Debug then
|
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
|
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
|
||||||
else
|
else
|
||||||
dupeWarn(src, item) -- if not boot the player
|
dupeWarn(src, item) -- if not boot the player
|
||||||
@@ -598,22 +623,22 @@ RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give,
|
|||||||
if GetResourceState(OXInv):find("start") then
|
if GetResourceState(OXInv):find("start") then
|
||||||
local success = exports[OXInv]:AddItem(src, item, amount or 1, nil)
|
local success = exports[OXInv]:AddItem(src, item, amount or 1, nil)
|
||||||
if Config.System.Debug then
|
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
|
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: ^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
|
end
|
||||||
elseif GetResourceState(CoreInv):find("start") then
|
elseif GetResourceState(CoreInv):find("start") then
|
||||||
local success = exports[CoreInv]:addItem('primary-'..src, item, amount)
|
local success = exports[CoreInv]:addItem('primary-'..src, item, amount)
|
||||||
if Config.System.Debug then
|
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)
|
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: ^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
|
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
|
||||||
@@ -622,10 +647,10 @@ RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give,
|
|||||||
--end
|
--end
|
||||||
end
|
end
|
||||||
if Config.System.Debug then
|
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
|
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
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
@@ -654,12 +679,21 @@ end
|
|||||||
|
|
||||||
local function CheckVersion()
|
local function CheckVersion()
|
||||||
if IsDuplicityVersion() then
|
if IsDuplicityVersion() then
|
||||||
|
local currentVersion = "^3"..GetResourceMetadata(GetCurrentResourceName(), 'version'):gsub("%.", "^7.^3").."^7"
|
||||||
PerformHttpRequest('https://raw.githubusercontent.com/jimathy/UpdateVersions/master/'..GetCurrentResourceName()..'.txt', function(err, newestVersion, headers)
|
PerformHttpRequest('https://raw.githubusercontent.com/jimathy/UpdateVersions/master/'..GetCurrentResourceName()..'.txt', function(err, newestVersion, headers)
|
||||||
if not newestVersion then print("Currently unable to run a version check.") return end
|
if not newestVersion then
|
||||||
local currentVersion = "^3"..GetResourceMetadata(GetCurrentResourceName(), 'version'):gsub("%.", "^7.^3").."^7"
|
PerformHttpRequest('https://raw.githubusercontent.com/jimathy/'..GetCurrentResourceName()..'/master/version.txt', function(err, freeVersion, headers)
|
||||||
newestVersion = "^3"..newestVersion:sub(1, -2):gsub("%.", "^7.^3").."^7"
|
if not freeVersion then print("^1Currently unable to run a version check for ^7'^3"..GetCurrentResourceName().."^7' ("..currentVersion.."^7)") return end
|
||||||
print("^6Version Check^7: ^2Running^7: "..currentVersion.." ^2Latest^7: "..newestVersion)
|
local currentVersion = "^3"..GetResourceMetadata(GetCurrentResourceName(), 'version'):gsub("%.", "^7.^3").."^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!")
|
freeVersion = "^3"..freeVersion:sub(1, -2):gsub("%.", "^7.^3").."^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"
|
||||||
|
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
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -854,4 +888,4 @@ function StopEffects() -- Used to clear up any effects stuck on screen
|
|||||||
AnimpostfxStop('RaceTurbo')
|
AnimpostfxStop('RaceTurbo')
|
||||||
AnimpostfxStop('FocusIn')
|
AnimpostfxStop('FocusIn')
|
||||||
AnimpostfxStop('Rampage')
|
AnimpostfxStop('Rampage')
|
||||||
end
|
end
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
name "Jim_Bridge"
|
name "Jim_Bridge"
|
||||||
author "Jimathy"
|
author "Jimathy"
|
||||||
version "1.0"
|
version "1.0.4"
|
||||||
description "Framework Bridge By Jimathy"
|
description "Framework Bridge By Jimathy"
|
||||||
fx_version "cerulean"
|
fx_version "cerulean"
|
||||||
game "gta5"
|
game "gta5"
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
1.0
|
1.0.5
|
||||||
|
|||||||
92
wrapper.lua
92
wrapper.lua
@@ -21,7 +21,7 @@ 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/duty-fixes/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").."^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!")
|
||||||
@@ -560,12 +560,7 @@ if not GetResourceState(OXTargetExport):find("start") and not GetResourceState(Q
|
|||||||
local pedCoords = GetEntityCoords(PlayerPedId())
|
local pedCoords = GetEntityCoords(PlayerPedId())
|
||||||
for k, v in pairs (TextTargets) do
|
for k, v in pairs (TextTargets) do
|
||||||
if #(pedCoords - v.coords) <= v.dist then
|
if #(pedCoords - v.coords) <= v.dist then
|
||||||
DrawText3D(
|
DrawText3D(v.coords.x, v.coords.y, v.coords.z + 1.0, v.buttontext)
|
||||||
v.coords.x,
|
|
||||||
v.coords.y,
|
|
||||||
v.coords.z + 1.0,
|
|
||||||
v.buttontext
|
|
||||||
)
|
|
||||||
for i = 1, #v.options do
|
for i = 1, #v.options do
|
||||||
if IsControlJustPressed(0, v.options[i].key) then
|
if IsControlJustPressed(0, v.options[i].key) then
|
||||||
if v.options[i].onSelect then v.options[i].onSelect() end
|
if v.options[i].onSelect then v.options[i].onSelect() end
|
||||||
@@ -740,7 +735,6 @@ function onPlayerLoaded(func)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- INPUT --
|
-- INPUT --
|
||||||
function createInput(title, opts)
|
function createInput(title, opts)
|
||||||
local dialog = nil
|
local dialog = nil
|
||||||
@@ -773,6 +767,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
|
||||||
@@ -929,26 +924,70 @@ end
|
|||||||
function getVehicleProperties(vehicle)
|
function getVehicleProperties(vehicle)
|
||||||
local properties = {}
|
local properties = {}
|
||||||
if vehicle == nil then return nil end
|
if vehicle == nil then return nil end
|
||||||
if GetResourceState(OXLibExport):find("start") then
|
if GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then
|
||||||
properties = lib.getVehicleProperties(vehicle)
|
|
||||||
elseif GetResourceState(QBExport):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
|
||||||
|
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(OXLibExport):find("start") then
|
print(("Unable to set vehicle properties for '%s' (entity does not exist)"):
|
||||||
lib.setVehicleProperties(vehicle, props)
|
format(vehicle))
|
||||||
elseif GetResourceState(QBExport):find("start") then
|
end
|
||||||
Core.Functions.SetVehicleProperties(vehicle, props)
|
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
|
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)
|
||||||
|
local vehicle = NetworkGetEntityFromNetworkId(netId)
|
||||||
|
local value = props
|
||||||
|
Entity(vehicle).state[GetCurrentResourceName()..':setVehicleProperties'] = value
|
||||||
|
end)
|
||||||
|
|
||||||
|
AddStateBagChangeHandler(GetCurrentResourceName()..':setVehicleProperties', '', function(bagName, _, value)
|
||||||
|
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
|
||||||
|
|
||||||
|
if lib.setVehicleProperties(entity, value) then
|
||||||
|
Entity(entity).state:set('setVehicleProperties', nil, true)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
RegisterNetEvent(GetCurrentResourceName()..":server:ChargePlayer", function(cost, type) local src = source
|
RegisterNetEvent(GetCurrentResourceName()..":server:ChargePlayer", function(cost, type) local src = source
|
||||||
if Config.System.Debug then print("^6Bridge^7: ^2Charging ^2Player: '^6"..cost.."^7'", type) end
|
if Config.System.Debug then print("^6Bridge^7: ^2Charging ^2Player: '^6"..cost.."^7'", type) end
|
||||||
if type == "cash" then
|
if type == "cash" then
|
||||||
@@ -990,7 +1029,7 @@ function createUseableItem(item, funct)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function hasJob(job, source, grade) local hasJob = false
|
function hasJob(job, source, grade) local hasJob, duty = false, true
|
||||||
if source then
|
if source then
|
||||||
local src = tonumber(source)
|
local src = tonumber(source)
|
||||||
if GetResourceState(ESXExport):find("start") then
|
if GetResourceState(ESXExport):find("start") then
|
||||||
@@ -1012,16 +1051,19 @@ function hasJob(job, source, grade) local hasJob = false
|
|||||||
elseif GetResourceState(QBXExport):find("start") then
|
elseif GetResourceState(QBXExport):find("start") then
|
||||||
local jobinfo = exports[QBXExport]:GetPlayer(src).PlayerData.job
|
local jobinfo = exports[QBXExport]:GetPlayer(src).PlayerData.job
|
||||||
if jobinfo.name == job then hasJob = true
|
if jobinfo.name == job then hasJob = true
|
||||||
|
duty = exports[QBXExport]:GetPlayer(src).PlayerData.job.onduty
|
||||||
if grade and not (grade <= jobinfo.grade.level) then hasJob = false end
|
if grade and not (grade <= jobinfo.grade.level) then hasJob = false end
|
||||||
end
|
end
|
||||||
local ganginfo = exports[QBXExport]:GetPlayer(src).PlayerData.gang
|
local ganginfo = exports[QBXExport]:GetPlayer(src).PlayerData.gang
|
||||||
if ganginfo.name == job then hasJob = true
|
if ganginfo.name == job then hasJob = true
|
||||||
if grade and not (grade <= ganginfo.grade.level) then hasJob = false end
|
if grade and not (grade <= ganginfo.grade.level) then hasJob = false end
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then
|
elseif GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then
|
||||||
if Core.Functions.GetPlayer then -- support older qb-core functions
|
if Core.Functions.GetPlayer then -- support older qb-core functions
|
||||||
local jobinfo = Core.Functions.GetPlayer(src).PlayerData.job
|
local jobinfo = Core.Functions.GetPlayer(src).PlayerData.job
|
||||||
if jobinfo.name == job then hasJob = true
|
if jobinfo.name == job then hasJob = true
|
||||||
|
duty = Core.Functions.GetPlayer(src).PlayerData.job.onduty
|
||||||
if grade and not (grade <= jobinfo.grade.level) then hasJob = false end
|
if grade and not (grade <= jobinfo.grade.level) then hasJob = false end
|
||||||
end
|
end
|
||||||
local ganginfo = Core.Functions.GetPlayer(src).PlayerData.gang
|
local ganginfo = Core.Functions.GetPlayer(src).PlayerData.gang
|
||||||
@@ -1031,6 +1073,7 @@ function hasJob(job, source, grade) local hasJob = false
|
|||||||
else -- support newer qb-core exports
|
else -- support newer qb-core exports
|
||||||
local jobinfo = exports[QBExport]:GetPlayer(src).PlayerData.job
|
local jobinfo = exports[QBExport]:GetPlayer(src).PlayerData.job
|
||||||
if jobinfo.name == job then hasJob = true
|
if jobinfo.name == job then hasJob = true
|
||||||
|
duty = exports[QBExport]:GetPlayer(src).PlayerData.job.onduty
|
||||||
if grade and not (grade <= jobinfo.grade.level) then hasJob = false end
|
if grade and not (grade <= jobinfo.grade.level) then hasJob = false end
|
||||||
end
|
end
|
||||||
local ganginfo = exports[QBExport]:GetPlayer(src).PlayerData.gang
|
local ganginfo = exports[QBExport]:GetPlayer(src).PlayerData.gang
|
||||||
@@ -1059,6 +1102,7 @@ function hasJob(job, source, grade) local hasJob = false
|
|||||||
elseif GetResourceState(QBXExport):find("start") then
|
elseif GetResourceState(QBXExport):find("start") then
|
||||||
local jobinfo = QBX.PlayerData.job
|
local jobinfo = QBX.PlayerData.job
|
||||||
if jobinfo.name == job then hasJob = true
|
if jobinfo.name == job then hasJob = true
|
||||||
|
duty = QBX.PlayerData.job.onduty
|
||||||
if grade and not (grade <= jobinfo.grade.level) then hasJob = false end
|
if grade and not (grade <= jobinfo.grade.level) then hasJob = false end
|
||||||
end
|
end
|
||||||
local ganginfo = QBX.PlayerData.gang
|
local ganginfo = QBX.PlayerData.gang
|
||||||
@@ -1071,8 +1115,8 @@ function hasJob(job, source, grade) local hasJob = false
|
|||||||
info = PlayerData
|
info = PlayerData
|
||||||
end)
|
end)
|
||||||
local jobinfo = info.job
|
local jobinfo = info.job
|
||||||
if jobinfo.name == job then
|
if jobinfo.name == job then hasJob = true
|
||||||
hasJob = true
|
duty = jobinfo.onduty
|
||||||
if grade and not (grade <= jobinfo.grade.level) then hasJob = false end
|
if grade and not (grade <= jobinfo.grade.level) then hasJob = false end
|
||||||
end
|
end
|
||||||
local ganginfo = info.gang
|
local ganginfo = info.gang
|
||||||
@@ -1084,7 +1128,7 @@ function hasJob(job, source, grade) local hasJob = false
|
|||||||
print("^4ERROR^7: ^2No Core detected for hasJob() ^7- ^2Check ^3exports^1.^2lua^7")
|
print("^4ERROR^7: ^2No Core detected for hasJob() ^7- ^2Check ^3exports^1.^2lua^7")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return hasJob
|
return hasJob, duty
|
||||||
end
|
end
|
||||||
|
|
||||||
function getPlayer(source) local Player = {}
|
function getPlayer(source) local Player = {}
|
||||||
@@ -1214,4 +1258,4 @@ function registerStash(name, label)
|
|||||||
exports[QSInv]:RegisterStash(name, 50, 4000000)
|
exports[QSInv]:RegisterStash(name, 50, 4000000)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- IN NO WAY PERFECT --
|
-- IN NO WAY PERFECT --
|
||||||
Reference in New Issue
Block a user