Compare commits

..

57 Commits
help ... v1.0.6

Author SHA1 Message Date
Jim Shield
8cf4a6bd23 Version Bump - 1.0.6 2024-01-22 14:35:52 +00:00
Jim Shield
3e067c8492 Merge pull request #9 from jimathy/1.0.5
1.0.5
2024-01-21 22:28:03 +00:00
Jim Shield
6847639c65 Fix version checking system being dumb 2024-01-21 17:24:32 +00:00
Jim Shield
0592c3ebc8 Fix stashRemoveItem for QS-Inv 2024-01-21 17:24:10 +00:00
Jim Shield
2ca1cbd110 fxmanifest.lua - Version Bump v1.0.5 2024-01-21 17:20:15 +00:00
Jim Shield
8642733b78 version.txt - Version bump - 1.0.5 2024-01-21 17:17:55 +00:00
Jim Shield
5a4293182c version number plz work 2024-01-21 17:10:32 +00:00
Jim Shield
6075878038 Update version.txt 2024-01-21 00:56:19 +00:00
Jim Shield
7eaeac886f Merge pull request #8 from jimathy/1.0.4
1.0.4
2024-01-21 00:27:08 +00:00
Jim Shield
fe27a1ca1c speed playAnim up + add default input message 2024-01-21 00:25:42 +00:00
Jim Shield
0caea0b473 advanced checking and handling of setVehicle 2024-01-20 14:28:10 +00:00
Jim Shield
370c77433b Version Bump - v1.0.4 2024-01-20 13:01:26 +00:00
Jim Shield
ac85d35097 Merge pull request #7 from jimathy/1.0.3
1.0.3
2024-01-19 23:58:42 +00:00
Jim Shield
85c3e06910 update addItem/removeItem prints 2024-01-19 23:57:22 +00:00
Jim Shield
7d0736bfc2 Change how bridge decides what get/setvehicleproperties to use 2024-01-19 22:33:35 +00:00
Jim Shield
b0b011ac56 update readme -main 2024-01-19 20:25:44 +00:00
Jim Shield
23091c2e73 add spam free ensureNetToVeh() 2024-01-19 20:25:04 +00:00
Jim Shield
ef2ba3ea7a tidy up new prints more 2024-01-19 20:24:25 +00:00
Jim Shield
df60f3b2b1 tidy prints for setVehicleProperties 2024-01-19 18:13:22 +00:00
Jim Shield
4cc001d2f0 fix typo in stashhasitem 2024-01-19 18:10:05 +00:00
Jim Shield
e2bb32d9de Optimize Crafting/Multicraft Menu + better hasItem prints 2024-01-19 14:46:45 +00:00
Jim Shield
725125a274 add debug prints to new ox setVehicleProperties call 2024-01-19 14:46:09 +00:00
Jim Shield
dcf2018ec6 check for destroyProp if received any info 2024-01-19 13:02:09 +00:00
Jim Shield
e5316f45aa Rewrite + Optimize hasItem() & stashhasItem() 2024-01-19 13:00:50 +00:00
Jim Shield
02c202d075 Version Bump - v1.0.3 2024-01-19 12:53:45 +00:00
Jim Shield
9e9fb14f55 Merge pull request #3 from bandgeekndb/stashoptions
Allow for passing through stash options when opening a stash
2024-01-19 12:50:10 +00:00
Jim Shield
61e0d777a8 Attempt to fix ox_lib's setVehicleProperites + 1.0.2 2024-01-18 20:21:22 +00:00
Jim Shield
78c3e33d38 version bump 1.0.1 2024-01-18 17:50:42 +00:00
Jim Shield
3be5b5e1ee Merge pull request #6 from jimathy/1.0.1
1.0.1
2024-01-18 17:49:05 +00:00
Jim Shield
f550479298 Revert "version bump"
This reverts commit d82366b59f.
2024-01-18 17:48:14 +00:00
Jim Shield
5fe0ab8815 Revert "Resolve merge conflict"
This reverts commit 56ccb43c2b.
2024-01-18 17:48:03 +00:00
Jim Shield
56ccb43c2b Resolve merge conflict 2024-01-18 17:44:25 +00:00
Jim Shield
93d0754935 Make qbx use correct export for getCoreObject
This should be fine as qbox takes over the export but just to be sure
2024-01-18 17:41:28 +00:00
Jim Shield
d82366b59f version bump 2024-01-18 15:38:28 +00:00
Jim Shield
35202f7000 add fix for recipes having no final amount added 2024-01-18 15:33:51 +00:00
Jim Shield
bc5aadc394 add export error check to stashRemoveItem 2024-01-18 15:14:38 +00:00
Jim Shield
181c480ba6 return duty check for hasJob 2024-01-18 15:06:20 +00:00
Jim Shield
b973c71638 Update version.txt(?) 2024-01-18 14:45:41 +00:00
Jim Shield
ede0a44251 fix version.txt? 2024-01-18 14:42:23 +00:00
Jim Shield
e4b0f8601a fix bridge version check looking in wrong place 2024-01-18 14:17:01 +00:00
Jim Shield
d12c615f0b Merge pull request #4 from jimathy/duty-fixes
Duty fixes + CheckVersion + better debug
2024-01-18 13:16:45 +00:00
Jim Shield
e58163d631 CheckVersion supports free script checking 2024-01-18 13:08:16 +00:00
Jim Shield
e801910519 add CheckBridgeVersion and version.txt 2024-01-18 13:07:40 +00:00
Jim Shield
dbca627bc3 Fix hasJob + Add more debug messages 2024-01-18 13:05:45 +00:00
Jim Shield
b09534aad5 toggleduty() better checks - dupewarn() more info 2024-01-18 12:40:15 +00:00
Nicholas Blew
63c2d5d83d Allow for passing through stash options when opening a stash 2024-01-18 02:20:20 -05:00
Jim Shield
52dc9ff8ae Merge pull request #2 from jimathy/fixes
Fixes
2024-01-18 00:54:51 +00:00
Jim Shield
10e184afb0 move old/new qbcore info fixes 2024-01-18 00:52:00 +00:00
Jim Shield
4e645001fb Stop invImg giving errors if no image 2024-01-18 00:50:54 +00:00
Jim Shield
e33b68bd55 change qs-inv getinventory to getuserinventory 2024-01-17 23:39:10 +00:00
Jim Shield
7094bda2fb more old qbcore updates 2024-01-17 23:38:28 +00:00
Jim Shield
409c181cb2 add support for older QBCore GetPlayer event 2024-01-17 23:36:45 +00:00
Jim Shield
6c38f90b9a fix grade crafting 2024-01-17 21:05:38 +00:00
Jim Shield
d693a99852 update readme export info 2024-01-17 20:23:54 +00:00
Jim Shield
508c4a734a fix job crafting breaking and needing grades 2024-01-17 20:23:27 +00:00
Jim Shield
cd93ea3a38 fix esx progressbar triggering with ox 2024-01-17 17:49:42 +00:00
Jim Shield
bf88dbd4b3 Fixes and updates 2024-01-17 13:39:23 +00:00
6 changed files with 592 additions and 274 deletions

View File

@@ -21,6 +21,28 @@ But I want this script to grow with help of others who know more about other cor
---
The installation of this script is simple
- REMOVE `-main` from the folder name, like any other github hosted script
- it just needs to start before any script that requires it
- it can start before core scripts if you want
- for `qb-core` I personally place this script in `resources > [standalone]`
- for `qb-core` I personally place this script in `resources > [standalone]`
---
### Support for different exports and scripts
In exports.lua is the list of script folder names
This is for people who have customised/renamed scripts
eg. for people who use `ps-inventory`, this is mainly based on qb-inventory
so you need to rename
```lua
QBInv = "qb-inventory",
```
to
```lua
QBInv = "ps-inventory",
```
This will now use events from `ps-inventory` and use it through out the scripts.

View File

@@ -1,7 +1,9 @@
if GetResourceState(OXLibExport):find("start") then
createCallback(GetCurrentResourceName()..':server:GetStashItems', function(source, stashName) local stash = getStash(stashName) return stash end)
else
createCallback(GetCurrentResourceName()..':server:GetStashItems', function(source, cb, stashName) local stash = getStash(stashName) cb(stash) end)
if IsDuplicityVersion() then
if GetResourceState(OXLibExport):find("start") then
createCallback(GetCurrentResourceName()..':server:GetStashItems', function(source, stashName) local stash = getStash(stashName) return stash end)
else
createCallback(GetCurrentResourceName()..':server:GetStashItems', function(source, cb, stashName) local stash = getStash(stashName) cb(stash) end)
end
end
local timeout = 0
@@ -26,7 +28,7 @@ function GetStashTimeout(stashName, stop)
end
local CraftLock = false
function craftingMenu(data)
function craftingMenu(data) local hasjob = false
if CraftLock then return end
if data.stashName and not GetStashTimeout(data.stashName) then
--triggerNotify(nil, "Chacking", "success")
@@ -37,29 +39,26 @@ function craftingMenu(data)
for i = 1, #Recipes do
for k, v in pairs(Recipes[i]) do
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
for l, b in pairs(data.craftable[i]["job"]) do
hasjob = hasJob(l)
for l, b in pairs(Recipes[i].job) do
hasjob = hasJob(l, nil, b)
if hasJob == true then break end
end
end
local setheader, settext = "", ""
local text = ""
local disable = false
local checktable = {}
if Recipes[i].job and hasjob == false then else
local itemTable = {}
for l, b in pairs(Recipes[i][tostring(k)]) do
if not Items[l] then print("^3Error^7: ^2Script can't find ingredient item in Shared Items - ^1"..l.."^7") return end
settext = settext..(settext ~= "" and br or "")..Items[l].label..(b > 1 and " x"..b or "")
if data.stashName then checktable[l] = stashhasItem(stashItems, l, b)
else checktable[l] = hasItem(l, b) end
settext = settext..(settext ~= "" and br or "")..(Items[l] and Items[l].label or "error - "..l)..(b > 1 and " x"..b or "")
itemTable[l] = b
Wait(0)
end
for _, v in pairs(checktable) do
if not v then
disable = true
break
end
end
if Config.System.Debug then print("^6Bridge^7: ^2Checking"..(data.stashName and " ^7'^6"..data.stashName.."^7'" or "").." ^2ingredients^7 - ^6"..k.."^7") end
if data.stashName then disable = not stashhasItem(stashItems, itemTable)
else disable = not hasItem(itemTable) end
setheader = Items[tostring(k)].label..(Recipes[i]["amount"] > 1 and " x"..Recipes[i]["amount"] or "")..(not disable and " ✔️" or "")
Menu[#Menu + 1] = {
isMenuHeader = disable,
@@ -94,17 +93,20 @@ function multiCraft(data) local Menu = {}
}
for k in pairsByKeys(success) do
local settext = ""
local itemTable = {}
for l, b in pairs(data.craft[data.item]) do
if data.stashName then
success[k] = stashhasItem(stashItems, l, (b * k))
else
success[k] = hasItem(l, (b * k))
end
itemTable[l] = (b * k)
settext = settext..(settext ~= "" and br or "")..Items[l].label..(b*k > 1 and "- x"..b*k or "")
Wait(0)
end
local disable = false
if Config.System.Debug then print("^6Bridge^7: ^2Checking "..(data.stashName and "^7'^6"..data.stashName.."^7'" or "inventory").."^7x^5"..k.." ^2ingredients^7 - ^6"..data.item.."^7") end
if data.stashName then disable = not stashhasItem(stashItems, itemTable)
else disable = not hasItem(itemTable) end
Menu[#Menu + 1] = {
isMenuHeader = not success[k],
isMenuHeader = disable,
arrow = not disable,
header = "Craft - x"..k * data.craft.amount,
txt = settext,
onSelect = function ()
@@ -216,155 +218,71 @@ function openShop(data)
if GetResourceState(OXInv):find("start") then
exports[OXInv]:openInventory('shop', { type = data.shop })
else
TriggerServerEvent(Config.JimShops and "jim-shops:ShopOpen" or "inventory:server:OpenInventory", "shop", data.shop, data.items)
TriggerServerEvent(Config.General.JimShops and "jim-shops:ShopOpen" or "inventory:server:OpenInventory", "shop", data.items.label, data.items)
end
lookEnt(data.coords)
end
-- Client & Server side
function hasItem(items, amount, src) local amount, count = amount and amount or 1, 0
if src then
if GetResourceState(OXInv):find("start") then
local item = exports[OXInv]:GetItem(src, items)
local amount = (amount or 1)
if item.count >= amount then
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^5FOUND^7 ^3"..item.count.."^7/^3"..amount.." "..tostring(items)) end
return true
else if Config.System.Debug then
print("^6Bridge^7: ^3HasItem^7: ^2"..tostring(items).." ^1NOT FOUND^7") end
return false
end
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
function hasItem(items, amount, src) local amount = amount and amount or 1
local grabInv = nil
local foundInv = ""
if type(items) ~= "table" then items = { [items] = amount and amount or 1, } end
if GetResourceState(OXInv):find("start") then
foundInv = OXInv
if src then grabInv = exports.ox_inventory:GetInventoryItems(src)
else grabInv = exports[OXInv]:GetPlayerItems()
end
elseif GetResourceState(QSInv):find("start") then
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
if GetResourceState(OXInv):find("start") then
local count = tonumber(exports[OXInv]:Search('count', items))
local amount = (amount or 1)
if count >= amount then if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^5FOUND^7 ^3"..count.."^7/^3"..amount.." "..tostring(items)) end return true
else if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^2"..tostring(items).." ^1NOT FOUND^7") end return false end
print("^4ERROR^7: ^2No Inventory detected ^7- ^2Check ^3exports^1.^2lua^7")
end
elseif GetResourceState(QSInv):find("start") then
for _, itemData in pairs(exports[QSInv]:GetInventory()) do
if itemData and (itemData.name == items) then
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^2Item^7: '^3"..tostring(items).."^7' ^2Slot^7: ^3"..itemData.slot.." ^7x(^3"..tostring(itemData.amount).."^7)") end
count += (itemData.amount or 1)
if grabInv then
local hasTable = {}
for item, amount in pairs(items) do
if not Items[item] then print("^4ERROR^7: ^2Script can't find ingredient item in Shared Items - ^1"..item.."^7") end
local count = 0
for _, itemData in pairs(grabInv) do
if itemData and (itemData.name == item) then
--if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^2Item^7: '^3"..tostring(item).."^7' ^2Slot^7: ^3"..itemData.slot.." ^7x(^3"..tostring(itemData.count or itemData.amount).."^7)", foundInv) end
count += ((itemData.count or itemData.amount) or 1)
end
end
if count >= amount then
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^5FOUND^7 ^3"..count.."^7/^3"..amount.." "..tostring(items)) end
return true
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7[^6"..foundInv.."^7]: "..tostring(item).." ^3"..count.."^7/^3"..amount.." ^5FOUND^7") end
hasTable[item] = { hasItem = true, count = count, }
else
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^2"..tostring(items).." ^1NOT FOUND^7") end
return false
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7[^6"..foundInv.."^7]: "..tostring(item).." ^1"..count.."^7/^3"..amount.." ^1NOT FOUND^7") end
hasTable[item] = { hasItem = false, count = count, }
end
elseif GetResourceState(CoreInv):find("start") then
for _, itemData in pairs(exports[CoreInv]:getInventory('primary-'..GetPlayerServerId(PlayerPedId()))) do
if itemData and (itemData.name == items) then
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^2Item^7: '^3"..tostring(items).."^7' ^2Slot^7: ^3"..itemData.slot.." ^7x(^3"..tostring(itemData.amount).."^7)") end
count += (itemData.amount or 1)
end
end
if count >= amount then
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^5FOUND^7 ^3"..count.."^7/^3"..amount.." "..tostring(items)) end
return true
else
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^2"..tostring(items).." ^1NOT FOUND^7") end
return false
end
elseif GetResourceState(CodeMInv):find("start") then
local success = exports[CodeMInv]:CheckItemValid(items, amount)
if success then
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^5FOUND^7 ^3"..amount.." "..tostring(items)) end
return true
end
elseif GetResourceState(QBInv):find("start") then
--if tonumber(GetResourceMetadata(QBInv, 'version')) <= 1.2 then
-- return exports[QBInv]:HasItem(items, amount)
--else
for _, itemData in pairs(Core.Functions.GetPlayerData().items) do
if itemData and (itemData.name == items) then
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^2Item^7: '^3"..tostring(items).."^7' ^2Slot^7: ^3"..itemData.slot.." ^7x(^3"..tostring(itemData.amount).."^7)") end
count += (itemData.amount or 1)
end
end
if count >= amount then
if Config.System.Debug then
print("^6Bridge^7: ^3HasItem^7: ^5FOUND^7 ^3"..count.."^7/^3"..amount.." "..tostring(items))
end
return true
else
if Config.System.Debug then
print("^6Bridge^7: ^3HasItem^7: ^2"..tostring(items).." ^1NOT FOUND^7")
end
return false
end
-- end
end
for k, v in pairs(hasTable) do if v.hasItem == false then return false, hasTable end end
return true, hasTable
end
end
@@ -377,7 +295,7 @@ function openStash(data)
exports[CodeMInv]:OpenStash(data.stash, 400000, 100)
else
TriggerEvent("inventory:client:SetCurrentStash", data.stash)
TriggerServerEvent("inventory:server:OpenInventory", "stash", data.stash)
TriggerServerEvent("inventory:server:OpenInventory", "stash", data.stash, data.stashOptions)
end
lookEnt(data.coords)
end
@@ -430,8 +348,21 @@ function stashRemoveItem(stashItems, stashName, items) local amount = amount and
end
elseif GetResourceState(QSInv):find("start") then
for k, v in pairs(items) do
exports[QSInv]:RemoveItemIntoStash(stashName, k, v)
if Config.System.Debug then print("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..QSInv, k, v) end
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(CodeMInv):find("start") then
for k, v in pairs(items) do
@@ -454,7 +385,7 @@ function stashRemoveItem(stashItems, stashName, items) local amount = amount and
if Config.System.Debug then
print("^6Bridge^7: ^3saveStash^7: ^2Saving ^3QB^2 stash ^7'^6"..stashName.."^7'")
end
else
elseif GetResourceState(QBInv):find("start") then
for k, v in pairs(items) do
for l in pairs(stashItems) do
if stashItems[l].name == k then
@@ -476,26 +407,31 @@ function stashRemoveItem(stashItems, stashName, items) local amount = amount and
print("^6Bridge^7: ^3saveStash^7: ^2Saving ^3QB^2 stash ^7'^6"..stashName.."^7'")
end
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
RegisterNetEvent(GetCurrentResourceName()..":server:stashRemoveItem", stashRemoveItem)
function stashhasItem(stashItems, item, amount) local amount, count = amount and amount or 1, 0
for k, itemData in pairs(stashItems) do
if itemData and (itemData.name == item) then
--if Config.System.Debug then
-- print("^6Bridge^7: ^3stashHasItem^7: ^2Item^7: '^3"..tostring(item).."^7' ^2Slot^7: ^3"..itemData.slot.." ^7x(^3"..tostring(itemData.amount).."^7)")
--end
count += (itemData.amount or 1)
end
end
if count >= amount then
if Config.System.Debug then
print("^6Bridge^7: ^3stashHasItem^7: ^2Items ^3"..item.." ^5FOUND^7 x^3"..count.."^7/^3"..amount.."^7") end
return
true
else
if Config.System.Debug then print("^6Bridge^7: ^3stashHasItem^7: ^2Items ^1NOT FOUND^7 "..json.encode(item)) end
return false
function stashhasItem(stashItems, items, amount)
local foundInv = ""
if type(items) ~= "table" then items = { [items] = amount and amount or 1, } end
local hasTable = {}
for item, amount in pairs(items) do
local count = 0
for _, itemData in pairs(stashItems) do
if itemData and (itemData.name == item) then
count += (itemData.amount or 1)
end
end
if count >= amount then
if Config.System.Debug then print("^6Bridge^7: ^3stashHasItem^7: ^5FOUND '"..item.."' ^3"..count.."^7/^3"..amount.."^7") end
hasTable[item] = { hasItem = true, count = count, }
else
if Config.System.Debug then print("^6Bridge^7: ^3stashHasItem^7: ^1NOT FOUND^7 '"..item.."' ^1"..count.."^7/^3"..amount.."^7") end
hasTable[item] = { hasItem = false, count = count, }
end
end
for k, v in pairs(hasTable) do if v.hasItem == false then return false, hasTable end end
return true, hasTable
end

View File

@@ -11,7 +11,7 @@ end
local time = 100
function loadModel(model)
if not HasModelLoaded(model) then if Config.System.Debug then print("^6Bridge^7: ^2Loading Model^7: '^6"..model.."^7'") end
while not HasModelLoaded(model) do if time > 0 then time = time - 1 RequestModel(model)
while not HasModelLoaded(model) do if time > 0 then time -= 1 RequestModel(model)
else time = 1000 print("^6Bridge^7: ^3LoadModel^7: ^2Timed out loading model ^7'^6"..model.."^7'") break end
Wait(10) end
end
@@ -29,7 +29,7 @@ function pairsByKeys(t) local a = {} for n in pairs(t) do a[#a+1] = n end table.
function playAnim(animDict, animName, duration, flag, ped)
loadAnimDict(animDict)
TaskPlayAnim(ped and ped or PlayerPedId(), animDict, animName, 1.0, -1.0, duration or 30000, flag or 50, 1, false, false, false)
TaskPlayAnim(ped and ped or PlayerPedId(), animDict, animName, 8.0, -8.0, duration or 30000, flag or 50, 1, false, false, false)
end
function stopAnim(animDict, animName)
@@ -94,6 +94,27 @@ function makeProp(data, freeze, synced)
return prop
end
function cv(amount)
local formatted = amount or "0"
while true do formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') if (k==0) then break end Wait(0) end
return formatted
end
function DrawText3D(x, y, z, text)
SetTextScale(0.35, 0.35)
SetTextFont(4)
SetTextProportional(true)
SetTextColour(255, 255, 255, 215)
BeginTextCommandDisplayText("STRING")
SetTextCentre(true)
AddTextComponentSubstringPlayerName(text)
SetDrawOrigin(x,y,z, 0)
EndTextCommandDisplayText(0.0, 0.0)
local factor = string.len(text) / 370
DrawRect(0.0, 0.0 + 0.0125, 0.017 + factor, 0.03, 0, 0, 0, 75)
ClearDrawOrigin()
end
AddEventHandler('onResourceStop', function(r)
if r ~= GetCurrentResourceName() then return end
stopSpinner()
@@ -133,12 +154,14 @@ function lookEnt(entity) local ped = PlayerPedId()
end
function destroyProp(entity)
if Config.System.Debug then print("^6Bridge^7: ^2Destroying Prop^7: '^6"..entity.."^7'") end
if IsEntityAttachedToEntity(entity, PlayerPedId()) then
SetEntityAsMissionEntity(entity)
DetachEntity(entity, true, true)
if entity then
if Config.System.Debug then print("^6Bridge^7: ^2Destroying Prop^7: '^6"..entity.."^7'") end
if IsEntityAttachedToEntity(entity, PlayerPedId()) then
SetEntityAsMissionEntity(entity)
DetachEntity(entity, true, true)
end
DeleteObject(entity)
end
DeleteObject(entity)
end
function pushVehicle(entity)
@@ -167,6 +190,28 @@ function pushVehicle(entity)
end
end
function ensureNetToVeh(vehNetID)
if Config.System.Debug then print("^6Bridge^7: ^3ensureNetToVeh^7: ^2Requesting NetworkDoesNetworkIdExist^7(^6"..vehNetID.."^7)") end
local timeout = 100
while not NetworkDoesNetworkIdExist(vehNetID) and timeout > 0 do
timeout -= 1
Wait(10)
end
if not NetworkDoesNetworkIdExist(vehNetID) then
return 0
end
timeout = 100
local vehicle = NetToVeh(vehNetID)
while not DoesEntityExist(vehicle) and vehicle ~= 0 and timeout > 0 do
timeout -= 1
Wait(10)
end
if not DoesEntityExist(vehicle) then
return 0
end
return vehicle
end
function makeBlip(data)
local blip = AddBlipForCoord(data.coords)
SetBlipAsShortRange(blip, true)
@@ -211,7 +256,12 @@ function createTempCam(ent, coords)
if Config.System.Debug then
triggerNotify(nil, "ModCam Created", "success")
end
local camCoords = GetOffsetFromEntityInWorldCoords(ent, 1.2, -0.3, 0.8)
local camCoords = nil
if type(ent) ~= "vector3" then
camCoords = GetOffsetFromEntityInWorldCoords(ent, 1.2, -0.3, 0.8)
else
camCoords = ent
end
--local pedCoords = GetEntityCoords(PlayerPedId())
cam = CreateCamWithParams("DEFAULT_SCRIPTED_CAMERA", camCoords.x, camCoords.y, camCoords.z+0.5, 1.0, 0.0, 0.0, 60.00, false, 0)
PointCamAtCoord(cam, coords)
@@ -276,6 +326,7 @@ function progressBar(data)
lockInv(false)
if data.cam then stopTempCam(data.cam) end
end
elseif Config.System.ProgressBar == "qb" then
Core.Functions.Progressbar("mechbar",
data.label,
@@ -297,10 +348,35 @@ function progressBar(data)
stopTempCam(data.cam)
end
end, data.icon)
elseif Config.System.ProgressBar == "gta" then
--local wait, inProgress = (Config.System.Debug and 1000 or data.time), true
local wait = data.time
elseif Config.System.ProgressBar == "esx" then
ESX.Progressbar(data.label, Config.System.Debug and 1000 or data.time, {
FreezePlayer = true,
animation ={
type =data.anim,
dict = data.dict,
scenario = data.task,
},
onFinish = function()
result = true
FreezeEntityPosition(PlayerPedId(), false)
lockInv(false)
if data.cam then
stopTempCam(data.cam)
end
end, onCancel = function()
result = false
FreezeEntityPosition(PlayerPedId(), false)
lockInv(false)
if data.cam then
stopTempCam(data.cam)
end
end
})
elseif Config.System.ProgressBar == "gta" then
local wait, inProgress = (Config.System.Debug and 1000 or data.time), true
--local wait = data.time
inProgress = true
if not (data.dead and data.dead or false) then
lockInv(true)
@@ -497,8 +573,9 @@ end
RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give, item, amount, newsrc)
local src = newsrc or source
local addremove = (tostring(give) == "true" and "addItem" or "removeItem")
if Config.System.Debug then
print("^6Bridge^7: ^3toggleItem ^2triggered^7: ^6"..(tostring(give) == "true" and "addItem" or "removeItem").."^7 - ['^8"..tostring(item).."^7'] x"..(tostring(amount) or "1"))
print("^6Bridge^7: ^3toggleItem ^2triggered^7: ^6"..addremove.."^7 - '"..tostring(item).."' x"..(tostring(amount) or "1"))
end
local remamount = (amount and amount or 1)
if item == nil then return end
@@ -506,12 +583,24 @@ RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give,
if hasItem(item, amount and amount or 1, src) then -- check if you still have the item
if GetResourceState(OXInv):find("start") then
local success = exports[OXInv]:RemoveItem(src, item, (amount and amount or 1), nil)
if Config.System.Debug then
print("^6Bridge^7: ^3"..addremove.."^7[^6"..OXInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7")
end
elseif GetResourceState(QSInv):find("start") then
local success = exports[QSInv]:RemoveItem(src, item, amount)
if Config.System.Debug then
print("^6Bridge^7: ^3"..addremove.."^7[^6"..QSInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7")
end
elseif GetResourceState(CoreInv):find("start") then
local success = exports[CoreInv]:removeItemExact('primary-'..src, item, amount)
if Config.System.Debug then
print("^6Bridge^7: ^3"..addremove.."^7[^6"..CoreInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7")
end
elseif GetResourceState(CodeMInv):find("start") then
local success = exports[CodeMInv]:RemoveItem(src, item, amount)
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")
end
elseif GetResourceState(QBInv):find("start") then
while remamount > 0 do
if Core.Functions.GetPlayer(src).Functions.RemoveItem(item, 1) then end
@@ -520,10 +609,12 @@ RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give,
if Config.Crafting.showItemBox then
TriggerClientEvent('inventory:client:ItemBox', src, Items[item], "remove", (amount and amount or 1))
end
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")
end
else
print("^4ERROR^7: ^2No Inventory detected ^7- ^2Check ^3exports^1.^2lua^7")
end
if Config.System.Debug then
print("^6Bridge^7: ^1Removing ^2from Player^7(^2"..src.."^7) '^6"..Items[item].label.."^7(^2x^6"..((amount and amount or "1")).."^7)'")
end
else
dupeWarn(src, item) -- if not boot the player
end
@@ -532,26 +623,34 @@ RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give,
if GetResourceState(OXInv):find("start") then
local success = exports[OXInv]:AddItem(src, item, amount or 1, nil)
if Config.System.Debug then
print("^6Bridge^7: ^4Giving ^2Player^7(^2"..src.."^7) '^6"..Items[item].label.."^7(^2x^6"..((amount and amount or "1")).."^7) ^1OX^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
elseif GetResourceState(QSInv):find("start") then
local success = exports[QSInv]:AddItem(src, item, amount)
if Config.System.Debug then
print("^6Bridge^7: ^4Giving ^2Player^7(^2"..src.."^7) '^6"..Items[item].label.."^7(^2x^6"..((amount and amount or "1")).."^7) ^1QS^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
elseif GetResourceState(CoreInv):find("start") then
local success = exports[CoreInv]:addItem('primary-'..src, item, amount)
if Config.System.Debug then
print("^6Bridge^7: ^4Giving ^2Player^7(^2"..src.."^7) '^6"..Items[item].label.."^7(^2x^6"..((amount and amount or "1")).."^7) ^1Core^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
elseif GetResourceState(CodeMInv):find("start") then
local success = exports[CodeMInv]:AddItem(src, item, amount)
elseif GetResourceState(QBInv):find("start") 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")
end
elseif GetResourceState(QBInv):find("start") then
if Core.Functions.GetPlayer(src).Functions.AddItem(item, amount or 1) then
--if Config.Crafting.showItemBox then
TriggerClientEvent("inventory:client:ItemBox", src, Items[item], "add", amount and amount or 1)
--end
end
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")
end
else
print("^4ERROR^7: ^2No Inventory detected ^7- ^2Check ^3exports^1.^2lua^7")
end
end
end)
@@ -562,12 +661,11 @@ function dupeWarn(src, item)
if Config.System.Debug == false then
DropPlayer(src, src.." ^1Kicked for attempting to duplicate items")
end
print("^5DupeWarn:^7: (^1"..tostring(src).."^7) ^2Dropped from server for item duplicating^7")
print("^5DupeWarn:^7: (^1"..tostring(src).."^7) ^2Dropped from server - exploit protection detected an item not being found in players inventory^7")
end
function toggleDuty()
if GetResourceState(QBExport):find("start") then
if GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then
TriggerServerEvent("QBCore:ToggleDuty")
else
onDuty = not onDuty
@@ -581,12 +679,21 @@ end
local function CheckVersion()
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)
if not newestVersion then print("Currently unable to run a version check.") return end
local currentVersion = "^3"..GetResourceMetadata(GetCurrentResourceName(), 'version'):gsub("%.", "^7.^3").."^7"
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!")
if not newestVersion then
PerformHttpRequest('https://raw.githubusercontent.com/jimathy/'..GetCurrentResourceName()..'/master/version.txt', function(err, freeVersion, headers)
if not freeVersion then print("^1Currently unable to run a version check for ^7'^3"..GetCurrentResourceName().."^7' ("..currentVersion.."^7)") return end
local currentVersion = "^3"..GetResourceMetadata(GetCurrentResourceName(), 'version'):gsub("%.", "^7.^3").."^7"
freeVersion = "^3"..freeVersion:sub(1, -2):gsub("%.", "^7.^3"):gsub("%\r", "").."^7"
print("^6Version Check^7: ^2Running^7: "..currentVersion.." ^2Latest^7: "..freeVersion)
print(freeVersion == currentVersion and "^7'^3"..GetCurrentResourceName().."^7' - ^6You are running the latest version.^7 ("..currentVersion..")" or "^7'^3"..GetCurrentResourceName().."^7' - ^1You are currently running an outdated version^7, ^1please update^7!")
end)
else
newestVersion = "^3"..newestVersion:sub(1, -2):gsub("%.", "^7.^3"):gsub("%\r", "").."^7"
print("^6Version Check^7: ^2Running^7: "..currentVersion.." ^2Latest^7: "..newestVersion)
print(newestVersion == currentVersion and '^6You are running the latest version.^7 ('..currentVersion..')' or "^1You are currently running an outdated version^7, ^1please update^7!")
end
end)
end
end

View File

@@ -1,6 +1,6 @@
name "Jim_Bridge"
author "Jimathy"
version "help"
version "1.0.6"
description "Framework Bridge By Jimathy"
fx_version "cerulean"
game "gta5"
@@ -11,4 +11,4 @@ files {
'functions.lua',
'wrapper.lua',
'crafting.lua',
}
}

1
version.txt Normal file
View File

@@ -0,0 +1 @@
1.0.6

View File

@@ -11,17 +11,30 @@ OXInv = Exports and Exports.OXInv 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 ""
QBTargetExport = Exports and Exports.QBTargetExport or ""
OXTargetExport = Exports and Exports.OXTargetExport or ""
function CheckBridgeVersion()
if IsDuplicityVersion() then
local currentVersion = "^3"..GetResourceMetadata("jim_bridge", 'version'):gsub("%.", "^7.^3").."^7"
PerformHttpRequest('https://raw.githubusercontent.com/jimathy/jim_bridge/master/version.txt', function(err, newestVersion, headers)
if not newestVersion then print("^1Currently unable to run a version check for ^7'^3jim_bridge^7' ("..currentVersion.."^7)") return end
newestVersion = "^3"..newestVersion:sub(1, -2):gsub("%.", "^7.^3"):gsub("%\r", "").."^7"
print(newestVersion == currentVersion and "^7'^3jim_bridge^7' - ^6You are running the latest version.^7 ("..currentVersion..")" or "^7'^3jim_bridge^7' - ^1You are currently running an outdated version^7, ^1please update^7!")
end)
end
end
CheckBridgeVersion()
for k, v in pairs(Exports) do
if GetResourceState(v):find("start") then print("^6Bridge^7: '^3"..v.."^7' ^2export found ^7") end
end
-- Load item lists from qb-core or ox_lib
-- Load item lists
if GetResourceState(OXInv):find("start") then
print("^6Bridge^7: ^2Loading ^3Items^2 from ^7"..OXInv)
Items = exports[OXInv]:Items()
@@ -35,24 +48,26 @@ if GetResourceState(OXInv):find("start") then
end
elseif GetResourceState(QBExport):find("start") then
print("^6Bridge^7: ^2Loading ^3Items^2 from ^7"..QBExport)
Core = exports[QBExport]:GetCoreObject()
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 = exports[QBExport]:GetCoreObject()
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 = exports[QBExport]:GetCoreObject()
Core = Core or exports[QBExport]:GetCoreObject()
RegisterNetEvent('QBCore:Client:UpdateObject', function()
Core = exports[QBExport]:GetCoreObject()
Core = Core or exports[QBExport]:GetCoreObject()
end)
Vehicles = Core.Shared.Vehicles
elseif GetResourceState(OXCoreExport):find("start") then
@@ -78,11 +93,13 @@ elseif GetResourceState(ESXExport):find("start") then
end
end
end)
else
print("^4ERROR^7: ^2No Vehicle info detected ^7- ^2Check ^3exports^1.^2lua^7")
end
-- Load Jobs
if GetResourceState(QBXExport):find("start") then
Core = exports[QBExport]:GetCoreObject()
Core = Core or exports[QBExport]:GetCoreObject()
print("^6Bridge^7: ^2Loading ^3Jobs^7/^3Gangs^2 from ^7"..QBXExport)
Jobs = exports[QBXExport]:GetJobs()
Gangs = exports[QBXExport]:GetGangs()
@@ -108,8 +125,8 @@ elseif GetResourceState(OXCoreExport):find("start") then
elseif GetResourceState(QBExport):find("start") then
print("^6Bridge^7: ^2Loading ^3Jobs^7/^3Gangs^2 from ^7"..QBExport)
Core = Core or exports[QBExport]:GetCoreObject()
RegisterNetEvent('QBCore:Client:UpdateObject', function() Core = exports[QBExport]:GetCoreObject() end)
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
@@ -136,6 +153,8 @@ elseif GetResourceState(ESXExport):find("start") then
Gangs = Jobs
end
end)
else
print("^4ERROR^7: ^2No Job/Gang ifo detected ^7- ^2Check ^3exports^1.^2lua^7")
end
function makeBossRoles(role)
@@ -178,6 +197,8 @@ function createPoly(data) local Location = nil
data.onExit()
end
end)
else
print("^4ERROR^7: ^2No PolyZone creation script detected ^7- ^2Check ^3exports^1.^2lua^7")
end
end
@@ -195,6 +216,8 @@ function createCirclePoly(data) local Location = nil
data.onExit()
end
end)
else
print("^4ERROR^7: ^2No PolyZone creation script detected ^7- ^2Check ^3exports^1.^2lua^7")
end
end
@@ -363,6 +386,18 @@ function isOx() return (Config.System.Menu == "ox" or Config.System.Menu == "gta
function isWarMenuOpen() if Config.System.Menu == "gta" then return WarMenu.IsAnyMenuOpened() else return false end end
local TextTargets = {}
local Keys = {
[322] = "ESC", [288] = "F1", [289] = "F2", [170] = "F3", [166] = "F5",
[167] = "F6", [168] = "F7", [169] = "F8", [56] = "F9", [57] = "F10",
[243] = "~", [157] = "1", [158] = "2", [160] = "3", [164] = "4", [165] = "5", [159] = "6", [161] = "7", [162] = "8", [163] = "9", [84] = "-", [83] = "=", [177] = "BACKSPACE", [37] = "TAB",
[44] = "Q", [32] = "W", [38] = "E", [45] = "R", [245] = "T", [246] = "Y", [303] = "U", [199] = "P",
[39] = "[", [40] = "]", [18] = "ENTER", [137] = "CAPS",
[34] = "A", [8] = "S", [9] = "D", [23] = "F", [47] = "G",
[74] = "H", [311] = "K", [182] = "L", [21] = "LEFTSHIFT",
[20] = "Z", [73] = "X", [26] = "C", [0] = "V", [29] = "B", [249] = "N",
[244] = "M", [82] = ",", [81] = "."
}
-- Targets --
local targetEntities = {}
function createEntityTarget(entity, opts, dist)
@@ -391,6 +426,14 @@ function createEntityTarget(entity, opts, dist)
end
local options = { options = opts, distance = dist }
exports[QBTargetExport]:AddTargetEntity(entity, options)
else
local tempText = ""
local keyTable = { 38, 29, 303, }
for i = 1, #opts do
opts[i].key = keyTable[i]
tempText = tempText.."~b~["..Keys[opts[i].key].."] ~w~"..opts[i].label.." "
end
TextTargets[entity] = { coords = GetEntityCoords(entity), buttontext = tempText, options = opts, dist = dist }
end
end
@@ -434,17 +477,101 @@ function createBoxTarget(data, opts, dist)
local target = exports[QBTargetExport]:AddBoxZone(data[1], data[2], data[3], data[4], data[5], options)
boxTargets[#boxTargets+1] = target
return target
else
local tempText = ""
local keyTable = { 38, 29, 303, }
for i = 1, #opts do
opts[i].key = keyTable[i]
tempText = tempText.."~b~["..Keys[opts[i].key].."] ~w~"..opts[i].label.." "
end
TextTargets[data[1]] = { coords = data[2], buttontext = tempText, options = opts, dist = dist }
return data[1]
end
end
local circleTargets = {}
function createCircleTarget(data, opts, dist)
if GetResourceState(OXTargetExport):find("start") then
if Config.System.Debug then
print("^6Bridge^7: ^2Creating new ^3Sphere^2 target with ^6"..OXTargetExport.." ^7"..data[1])
end
local options = {}
for i = 1, #opts do
options[i] = {
icon = opts[i].icon,
label = opts[i].label,
item = opts[i].item or nil,
groups = opts[i].job or opts[i].gang,
onSelect = opts[i].onSelect or opts[i].action,
canInteract = function(_, distance)
return distance < dist and true or false
end
}
end
local target = exports[OXTargetExport]:addSphereZone({
coords = data[2],
radius = data[3],
debug = data[4].debugPoly,
options = options
})
circleTargets[#circleTargets+1] = target
return target
elseif GetResourceState(QBTargetExport):find("start") then
if Config.System.Debug then
print("^6Bridge^7: ^2Creating new ^3Circle^2 target with ^6"..QBTargetExport.." ^7"..data[1])
end
local options = { options = opts, distance = dist }
local target = exports[QBTargetExport]:AddCircleZone(data[1], data[2], data[3], data[4], options)
circleTargets[#circleTargets+1] = target
return target
else
local tempText = ""
local keyTable = { 38, 29, 303, }
for i = 1, #opts do
opts[i].key = keyTable[i]
tempText = tempText.."~b~["..Keys[opts[i].key].."] ~w~"..opts[i].label.." "
end
TextTargets[data[1]] = { coords = data[2], buttontext = tempText, options = opts, dist = dist }
return data[1]
end
end
function removeEntityTarget(entity)
if GetResourceState(QBTargetExport):find("start") then exports[QBTargetExport]:RemoveTargetEntity(entity) end
if GetResourceState(OXTargetExport):find("start") then exports[OXTargetExport]:removeLocalEntity(entity, nil) end
if not GetResourceState(OXTargetExport):find("start") and not GetResourceState(QBTargetExport):find("start") then
TextTargets[entity] = nil
end
end
function removeZoneTarget(target)
if GetResourceState(QBTargetExport):find("start") then exports[QBTargetExport]:RemoveZone(target) end
if GetResourceState(OXTargetExport):find("start") then exports[OXTargetExport]:removeZone(target, true) end
if not GetResourceState(OXTargetExport):find("start") and not GetResourceState(QBTargetExport):find("start") then
TextTargets[target] = nil
end
end
if not GetResourceState(OXTargetExport):find("start") and not GetResourceState(QBTargetExport):find("start") and not IsDuplicityVersion() then
CreateThread(function()
while true do
local pedCoords = GetEntityCoords(PlayerPedId())
for k, v in pairs (TextTargets) do
if #(pedCoords - v.coords) <= v.dist then
DrawText3D(v.coords.x, v.coords.y, v.coords.z + 1.0, v.buttontext)
for i = 1, #v.options do
if IsControlJustPressed(0, v.options[i].key) then
if v.options[i].onSelect then v.options[i].onSelect() end
if v.options[i].action then v.options[i].action() end
end
end
end
end
Wait(0)
end
end)
end
AddEventHandler('onResourceStop', function(r)
@@ -457,6 +584,10 @@ AddEventHandler('onResourceStop', function(r)
if GetResourceState(OXTargetExport):find("start") then exports[OXTargetExport]:removeZone(boxTargets[i], true)
elseif GetResourceState(QBTargetExport):find("start") then exports[QBTargetExport]:RemoveZone(boxTargets[i].name) end
end
for i = 1, #circleTargets do
if GetResourceState(OXTargetExport):find("start") then exports[OXTargetExport]:removeZone(circleTargets[i], true)
elseif GetResourceState(QBTargetExport):find("start") then exports[QBTargetExport]:RemoveZone(circleTargets[i].name) end
end
end)
-- NOTIFICATIONS --
@@ -554,14 +685,14 @@ end
-- Callbacks
function createCallback(callbackName, funct)
if GetResourceState(OXLibExport):find("start") then
if Config and Config.System.Debug then print("^6Bridge^7: ^2Registering ^3Callback^2 with ^7"..OXLibExport, callbackName) end
if Config.System.Debug then print("^6Bridge^7: ^2Registering ^3Callback^2 with ^7"..OXLibExport, callbackName) end
lib.callback.register(callbackName, funct)
elseif GetResourceState(QBExport):find("start") then
if Config and Config.System.Debug then print("^6Bridge^7: ^2Registering ^3Callback^2 with ^7"..QBExport, callbackName) end
Core = exports[QBExport]:GetCoreObject()
if Config.System.Debug then print("^6Bridge^7: ^2Registering ^3Callback^2 with ^7"..QBExport, callbackName) end
Core = Core or exports[QBExport]:GetCoreObject()
Core.Functions.CreateCallback(callbackName, funct)
elseif GetResourceState(ESXExport):find("start") then
if Config and Config.System.Debug then print("^6Bridge^7: ^2Registering ^3Callback^2 with ^7"..ESXExport, callbackName) end
if Config.System.Debug then print("^6Bridge^7: ^2Registering ^3Callback^2 with ^7"..ESXExport, callbackName) end
ESX.RegisterServerCallback(callbackName, funct)
else
print("^6Bridge^7: ^1ERROR^7: ^3Can't find any script to register callback with", callbackName)
@@ -570,15 +701,15 @@ end
function triggerCallback(callBackName, value) local result = nil
if GetResourceState(OXLibExport):find("start") then
if Config and Config.System.Debug then print("^6Bridge^7: ^2Triggering ^3Callback^2 with ^7"..OXLibExport, callBackName) end
if Config.System.Debug then print("^6Bridge^7: ^2Triggering ^3Callback^2 with ^7"..OXLibExport, callBackName) end
result = lib.callback.await(callBackName, false, value)
elseif GetResourceState(QBExport):find("start") then
if Config and Config.System.Debug then print("^6Bridge^7: ^2Triggering ^3Callback^2 with ^7"..QBExport, callBackName) end
if Config.System.Debug then print("^6Bridge^7: ^2Triggering ^3Callback^2 with ^7"..QBExport, callBackName) end
local p = promise.new()
Core.Functions.TriggerCallback(callBackName, function(cb) p:resolve(cb) end, value)
result = Citizen.Await(p)
elseif GetResourceState(ESXExport):find("start") then
if Config and Config.System.Debug then print("^6Bridge^7: ^2Triggering ^3Callback^2 with ^7"..ESXExport, callBackName) end
if Config.System.Debug then print("^6Bridge^7: ^2Triggering ^3Callback^2 with ^7"..ESXExport, callBackName) end
local p = promise.new()
ESX.TriggerServerCallback(callBackName, function(cb) p:resolve(cb) end, value)
result = Citizen.Await(p)
@@ -599,6 +730,8 @@ function onPlayerLoaded(func)
elseif GetResourceState(OXCoreExport):find("start") then
if Config.System.Debug then print("^6Bridge^7: ^2Registering ^3onPlayerLoaded^2 with ^7"..OXLibExport) end
AddEventHandler('ox:playerLoaded', func)
else
print("^4ERROR^7: ^2No Core detected for onPlayerLoaded ^7- ^2Check ^3exports^1.^2lua^7")
end
end
@@ -606,7 +739,7 @@ end
function createInput(title, opts)
local dialog = nil
local options = {}
if Config.Input.Menu == "ox" then
if Config.System.Menu == "ox" then
for i = 1, #opts do
if opts[i].type == "radio" then
for k in pairs(opts[i].options) do
@@ -615,7 +748,7 @@ function createInput(title, opts)
options[i] = {
type = "select",
isRequired = opts[i].isRequired,
label = opts[i].label,
label = opts[i].label or opts[i].text,
name = opts[i].name,
default = opts[i].options[1].value,
options = opts[i].options,
@@ -624,7 +757,24 @@ function createInput(title, opts)
if opts[i].type == "number" then
options[i] = {
type = "number",
label = opts[i].text.." - "..opts[i].txt,
label = opts[i].text ..(opts[i].txt and " - "..opts[i].txt or ""),
isRequired = opts[i].isRequired,
name = opts[i].name,
options = opts[i].options,
}
end
if opts[i].type == "text" then
options[i] = {
type = "input",
label = opts[i].text ..(opts[i].txt and " - "..opts[i].txt or ""),
default = opts[i].default,
isRequired = opts[i].isRequired,
}
end
if opts[i].type == "select" then
options[i] = {
type = "select",
label = opts[i].text ..(opts[i].txt and " - "..opts[i].txt or ""),
isRequired = opts[i].isRequired,
name = opts[i].name,
options = opts[i].options,
@@ -637,11 +787,11 @@ function createInput(title, opts)
dialog = exports[OXLibExport]:inputDialog(title, options)
return dialog
end
if Config.Input.Menu == "qb" then
dialog = exports['qb-input']:ShowInput({ header = title, submitText = "Pay", inputs = opts })
if Config.System.Menu == "qb" then
dialog = exports['qb-input']:ShowInput({ header = title, submitText = "Accept", inputs = opts })
return dialog
end
if Config.Input.Menu == "gta" then
if Config.System.Menu == "gta" then
WarMenu.CreateMenu(tostring(opts),
title,
" ",
@@ -774,44 +924,93 @@ end
function getVehicleProperties(vehicle)
local properties = {}
if vehicle == nil then return nil end
if GetResourceState(OXLibExport):find("start") then
properties = lib.getVehicleProperties(vehicle)
elseif GetResourceState(QBExport):find("start") then
if GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then
properties = Core.Functions.GetVehicleProperties(vehicle)
if Config.System.Debug then print("^6Bridge^7: ^2Getting Vehicle Properties ^7[^6"..QBExport.."^7] - [^3"..vehicle.."^7] - [^3"..GetEntityModel(vehicle).."^7/^3"..properties.model.."^7] - [^3"..properties.plate.."^7]") end
elseif GetResourceState(OXLibExport):find("start") then
properties = lib.getVehicleProperties(vehicle)
if Config.System.Debug then print("^6Bridge^7: ^2Getting Vehicle Properties ^7[^6"..OXLibExport.."^7] - [^3"..vehicle.."^7] - [^3"..GetEntityModel(vehicle).."^7/^3"..properties.model.."^7] - [^3"..properties.plate.."^7]") end
end
return properties
end
function setVehicleProperties(vehicle, props)
if not DoesEntityExist(vehicle) then
print(("Unable to set vehicle properties for '%s' (entity does not exist)"):
format(vehicle))
end
if GetResourceState(OXLibExport):find("start") then
lib.setVehicleProperties(vehicle, props)
elseif GetResourceState(QBExport):find("start") then
Core.Functions.SetVehicleProperties(vehicle, props)
local oldProps = getVehicleProperties(vehicle)
if checkDifferences(vehicle, props) then
--if Config.System.Debug then debugDifferences(vehicle, props) end
if not DoesEntityExist(vehicle) then
print(("Unable to set vehicle properties for '%s' (entity does not exist)"):
format(vehicle))
end
if GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then
Core.Functions.SetVehicleProperties(vehicle, props)
if Config.System.Debug then print("^6Bridge^7: ^2Setting Vehicle Properties ^7[^6"..QBExport.."^7] - [^3"..vehicle.."^7] - [^3"..GetEntityModel(vehicle).."^7/^3"..props.model.."^7] - [^3"..props.plate.."^7]") end
else
TriggerServerEvent(GetCurrentResourceName()..":ox:setVehicleProperties", VehToNet(vehicle), props)
end
else
if Config.System.Debug then print("^6Bridge^7: ^2No Changes Found ^7 [^3"..vehicle.."^7] - [^3"..GetEntityModel(vehicle).."^7/^3"..props.model.."^7] - [^3"..props.plate.."^7]") end
end
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
if Config.System.Debug then print("^6Bridge^7: ^2Charging ^2Player: '^6"..cost.."^7'", type) end
if type == "cash" then
if GetResourceState(OXInv):find("start") then
exports[OXInv]:RemoveItem(src, "money", cost)
if Config.System.Debug then print("^6Bridge^7: ^2Charging ^2Player: '^6"..cost.."^7'", type, OXInv) end
elseif GetResourceState(QBExport):find("start") then
Core.Functions.GetPlayer(src).Functions.RemoveMoney("cash", cost)
if Config.System.Debug then print("^6Bridge^7: ^2Charging ^2Player: '^6"..cost.."^7'", type, QBExport) end
elseif GetResourceState(ESXExport):find("start") then
local Player = ESX.GetPlayerFromId(src)
Player.removeMoney(cost, "")
if Config.System.Debug then print("^6Bridge^7: ^2Charging ^2Player: '^6"..cost.."^7'", type, ESXExport) end
end
end
if type == "bank" then
if GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then
Core.Functions.GetPlayer(src).Functions.RemoveMoney("bank", cost)
if Config.System.Debug then print("^6Bridge^7: ^2Charging ^2Player: '^6"..cost.."^7'", type, QBExport) end
elseif GetResourceState(ESXExport):find("start") then
local Player = ESX.GetPlayerFromId(src)
Player.removeMoney(cost, "")
if Config.System.Debug then print("^6Bridge^7: ^2Charging ^2Player: '^6"..cost.."^7'", type, ESXExport) end
end
end
end)
@@ -830,8 +1029,9 @@ function createUseableItem(item, funct)
end
end
function hasJob(job, src) local hasJob = false
if src then
function hasJob(job, source, grade) local hasJob, duty = false, true
if source then
local src = tonumber(source)
if GetResourceState(ESXExport):find("start") then
local info = ESX.GetPlayerFromId(src).job
while not info do
@@ -850,14 +1050,39 @@ function hasJob(job, src) local hasJob = false
elseif GetResourceState(QBXExport):find("start") then
local jobinfo = exports[QBXExport]:GetPlayer(src).PlayerData.job
if jobinfo.name == job then hasJob = true end
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
end
local ganginfo = exports[QBXExport]:GetPlayer(src).PlayerData.gang
if ganginfo.name == job then hasJob = true end
if ganginfo.name == job then hasJob = true
if grade and not (grade <= ganginfo.grade.level) then hasJob = false end
end
elseif GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then
if Core.Functions.GetPlayer then -- support older qb-core functions
local jobinfo = Core.Functions.GetPlayer(src).PlayerData.job
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
end
local ganginfo = Core.Functions.GetPlayer(src).PlayerData.gang
if ganginfo.name == job then hasJob = true
if grade and not (grade <= ganginfo.grade.level) then hasJob = false end
end
else -- support newer qb-core exports
local jobinfo = exports[QBExport]:GetPlayer(src).PlayerData.job
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
end
local ganginfo = exports[QBExport]:GetPlayer(src).PlayerData.gang
if ganginfo.name == job then hasJob = true
if grade and not (grade <= ganginfo.grade.level) then hasJob = false end
end
end
else
local jobinfo = exports[QBExport]:GetPlayer(src).PlayerData.job
if jobinfo.name == job then hasJob = true end
local ganginfo = exports[QBExport]:GetPlayer(src).PlayerData.gang
if ganginfo.name == job then hasJob = true end
print("^4ERROR^7: ^2No Core detected for hasJob ^7- ^2Check ^3exports^1.^2lua^7")
end
else
if GetResourceState(ESXExport):find("start") then
@@ -876,26 +1101,40 @@ function hasJob(job, src) local hasJob = false
elseif GetResourceState(QBXExport):find("start") then
local jobinfo = QBX.PlayerData.job
if jobinfo.name == job then hasJob = true end
if jobinfo.name == job then hasJob = true
duty = QBX.PlayerData.job.onduty
if grade and not (grade <= jobinfo.grade.level) then hasJob = false end
end
local ganginfo = QBX.PlayerData.gang
if ganginfo.name == job then hasJob = true end
else
if ganginfo.name == job then hasJob = true
if grade and not (grade <= ganginfo.grade.level) then hasJob = false end
end
elseif GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then
local info = nil
Core.Functions.GetPlayerData(function(PlayerData)
info = PlayerData
end)
local jobinfo = info.job
if jobinfo.name == job then hasJob = true end
if jobinfo.name == job then hasJob = true
duty = jobinfo.onduty
if grade and not (grade <= jobinfo.grade.level) then hasJob = false end
end
local ganginfo = info.gang
if ganginfo.name == job then hasJob = true end
if ganginfo.name == job then
hasJob = true
if grade and not (grade <= ganginfo.grade.level) then hasJob = false end
end
else
print("^4ERROR^7: ^2No Core detected for hasJob() ^7- ^2Check ^3exports^1.^2lua^7")
end
end
return hasJob
return hasJob, duty
end
function getPlayer(src) local Player = {}
function getPlayer(source) local Player = {}
if Config.System.Debug then print("^6Bridge^7: ^2Getting ^3Player^2 info^7") end
if src then -- If called from server
if source then -- If called from server
local src = tonumber(source)
if GetResourceState(ESXExport):find("start") then
local info = ESX.GetPlayerFromId(src)
Player = {
@@ -922,15 +1161,26 @@ function getPlayer(src) local Player = {}
bank = info.Functions.GetMoney("bank"),
}
elseif GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then
local info = Core.Functions.GetPlayer(tonumber(src))
Player = {
name = info.PlayerData.charinfo.firstname.." "..info.PlayerData.charinfo.lastname,
cash = info.PlayerData.money["cash"],
bank = info.PlayerData.money["bank"],
}
if Core.Functions.GetPlayer ~= nil then -- support older qb-core functions
local info = Core.Functions.GetPlayer(src).PlayerData
Player = {
name = info.charinfo.firstname.." "..info.charinfo.lastname,
cash = info.money["cash"],
bank = info.money["bank"],
}
else
local info = exports[QBExport]:GetPlayer(src).PlayerData
Player = {
name = info.charinfo.firstname.." "..info.charinfo.lastname,
cash = info.money["cash"],
bank = info.money["bank"],
}
end
else
print("^4ERROR^7: ^2No Core detected for getPlayer() ^7- ^2Check ^3exports^1.^2lua^7")
end
else
if ESX ~= nil then
if GetResourceState(ESXExport):find("start") and ESX ~= nil then
local info = ESX.GetPlayerData()
local cash, bank = 0, 0
for k, v in pairs(ESX.GetPlayerData().accounts) do
@@ -956,16 +1206,16 @@ function getPlayer(src) local Player = {}
cash = info.money["cash"],
bank = info.money["bank"],
}
else
elseif GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then
local info = nil
Core.Functions.GetPlayerData(function(PlayerData)
info = PlayerData
end)
Core.Functions.GetPlayerData(function(PlayerData) info = PlayerData end)
Player = {
name = info.charinfo.firstname.." "..info.charinfo.lastname,
cash = info.money["cash"],
bank = info.money["bank"],
}
else
print("^4ERROR^7: ^2No Core detected for hasJob ^7- ^2Check ^3exports^1.^2lua^7")
end
end
return Player
@@ -985,13 +1235,15 @@ function invImg(item)
local imgLink = ""
if item ~= "" and Items[item] then
if GetResourceState(OXInv):find("start") then
imgLink = "nui://"..OXInv.."/web/images/"..Items[item].image
imgLink = "nui://"..OXInv.."/web/images/"..(Items[item].image or "")
elseif GetResourceState(QSInv and QSInv or ""):find("start") then
imgLink = "nui://"..QSInv.."/html/images/"..Items[item].image
imgLink = "nui://"..QSInv.."/html/images/"..(Items[item].image or "")
elseif GetResourceState(CoreInv and CoreInv or ""):find("start") then
imgLink = "nui://"..CoreInv.."/html/img/"..Items[item].image
imgLink = "nui://"..CoreInv.."/html/img/"..(Items[item].image or "")
elseif GetResourceState(QBInv and QBInv or ""):find("start") then
imgLink = "nui://"..QBInv.."/html/images/"..Items[item].image
imgLink = "nui://"..QBInv.."/html/images/"..(Items[item].image or "")
else
print("^4ERROR^7: ^2No Inventory detected for invImg ^7- ^2Check ^3exports^1.^2lua^7")
end
end
return imgLink