mirror of
https://github.com/jimathy/jim_bridge.git
synced 2026-08-17 05:56:02 +01:00
Compare commits
86 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b31343991 | ||
|
|
872cb39715 | ||
|
|
dd35674307 | ||
|
|
1d102e94b4 | ||
|
|
c18932443a | ||
|
|
7563b4abdf | ||
|
|
20509e5cc2 | ||
|
|
43e30e95bc | ||
|
|
9efff1060b | ||
|
|
3b608e2b4f | ||
|
|
bfed10c019 | ||
|
|
4bb29b8f14 | ||
|
|
6eca0dd1d1 | ||
|
|
cc96bcde34 | ||
|
|
ab61e40567 | ||
|
|
e17e2fb865 | ||
|
|
a6bd82a41c | ||
|
|
fac495c0ef | ||
|
|
15bea85bfb | ||
|
|
f889080bc0 | ||
|
|
7d62358558 | ||
|
|
f7a7e89c56 | ||
|
|
5f6720d37b | ||
|
|
e541201a08 | ||
|
|
2bf04f69cf | ||
|
|
8479aea1b0 | ||
|
|
d17a1da5b2 | ||
|
|
f1ff06c098 | ||
|
|
df785043e8 | ||
|
|
5ae4799a5f | ||
|
|
8cf4a6bd23 | ||
|
|
3e067c8492 | ||
|
|
6847639c65 | ||
|
|
0592c3ebc8 | ||
|
|
2ca1cbd110 | ||
|
|
8642733b78 | ||
|
|
5a4293182c | ||
|
|
6075878038 | ||
|
|
7eaeac886f | ||
|
|
fe27a1ca1c | ||
|
|
0caea0b473 | ||
|
|
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 | ||
|
|
e801910519 | ||
|
|
dbca627bc3 | ||
|
|
b09534aad5 | ||
|
|
63c2d5d83d | ||
|
|
52dc9ff8ae | ||
|
|
10e184afb0 | ||
|
|
4e645001fb | ||
|
|
e33b68bd55 | ||
|
|
7094bda2fb | ||
|
|
409c181cb2 | ||
|
|
6c38f90b9a | ||
|
|
d693a99852 | ||
|
|
508c4a734a | ||
|
|
cd93ea3a38 |
24
README.md
24
README.md
@@ -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
|
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]`
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 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.
|
||||||
521
crafting.lua
521
crafting.lua
@@ -6,25 +6,22 @@ if IsDuplicityVersion() then
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local timeout = 0
|
local timeout, timing, stashItems = 0, false, {}
|
||||||
local timing = false
|
|
||||||
local stashItems = {}
|
|
||||||
function GetStashTimeout(stashName, stop)
|
function GetStashTimeout(stashName, stop)
|
||||||
if stop then stashItems = {} timing = false timeout = 0 return end
|
if stop then stashItems, timing, timeout = {}, false, 0 return end
|
||||||
if stashItems[1] then return true else
|
if #stashItems > 0 then return true end
|
||||||
if timeout <= 0 then
|
if timeout <= 0 then
|
||||||
stashItems = triggerCallback(GetCurrentResourceName()..':server:GetStashItems', stashName)
|
stashItems = triggerCallback(GetCurrentResourceName()..':server:GetStashItems', stashName)
|
||||||
timeout = 15000
|
timeout = 10000
|
||||||
if not timing then
|
if not timing then
|
||||||
CreateThread(function()
|
CreateThread(function()
|
||||||
timing = true
|
timing = true
|
||||||
while timeout > 0 do timeout -= 1000 Wait(1000) end
|
while timeout > 0 do timeout -= 1000 Wait(1000) end
|
||||||
timing = false stashItems = {} timeout = 0
|
timing, stashItems, timeout = false, {}, 0
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local CraftLock = false
|
local CraftLock = false
|
||||||
@@ -33,51 +30,43 @@ function craftingMenu(data)
|
|||||||
if data.stashName and not GetStashTimeout(data.stashName) then
|
if data.stashName and not GetStashTimeout(data.stashName) then
|
||||||
--triggerNotify(nil, "Chacking", "success")
|
--triggerNotify(nil, "Chacking", "success")
|
||||||
end
|
end
|
||||||
if (data.job or data.gang) and not jobCheck(data.job or data.gang) then return end
|
if (data.job or data.gang) and not jobCheck(data.job or data.gang) then return end
|
||||||
local Menu = {}
|
local Menu, hasjob = {}, false
|
||||||
local Recipes = data.craftable.Recipes
|
local Recipes = data.craftable.Recipes
|
||||||
for i = 1, #Recipes do
|
for i = 1, #Recipes do
|
||||||
for k, v in pairs(Recipes[i]) do
|
if not Recipes[i]["amount"] then Recipes[i]["amount"] = 1 end
|
||||||
|
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 Recipes[i].job then hasjob = false
|
if Recipes[i].job then
|
||||||
for l, b in pairs(data.craftable[i]["job"]) do
|
for l, b in pairs(Recipes[i].job) do
|
||||||
hasjob = hasJob(l)
|
hasjob = hasJob(l, nil, b)
|
||||||
|
if hasjob == true then break end
|
||||||
end
|
end
|
||||||
end
|
else hasjob = true end
|
||||||
local setheader, settext = "", ""
|
local setheader, settext, disable = "", "", false
|
||||||
local text = ""
|
if hasjob then
|
||||||
local disable = false
|
local itemTable = {}
|
||||||
local checktable = {}
|
|
||||||
if Recipes[i].job and hasjob == false then else
|
|
||||||
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
|
setheader = (Items[tostring(k)] and Items[tostring(k)].label or "error - "..tostring(k))..(Recipes[i]["amount"] > 1 and " x"..Recipes[i]["amount"] or "")..(not disable and " ✔️" or "")
|
||||||
end
|
|
||||||
end
|
|
||||||
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,
|
||||||
icon = invImg(tostring(k)),
|
icon = invImg(tostring(k)),
|
||||||
header = setheader, txt = settext,
|
header = setheader, txt = settext,
|
||||||
onSelect = function()
|
onSelect = function()
|
||||||
local transdata = { item = k, craft = data.craftable.Recipes[i], craftable = data.craftable, coords = data.coords, stashName = data.stashName, onBack = data.onBack }
|
local transdata = { item = k, craft = data.craftable.Recipes[i], craftable = data.craftable, coords = data.coords, stashName = data.stashName, onBack = data.onBack }
|
||||||
if Config.Crafting.MultiCraft then
|
if Config.Crafting.MultiCraft then multiCraft(transdata) else makeItem(transdata) end
|
||||||
multiCraft(transdata)
|
|
||||||
else
|
|
||||||
makeItem(transdata)
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Wait(0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
openMenu(Menu, { header = data.craftable.Header, onBack = data.onBack or nil, canClose = true, onExit = function() end, })
|
openMenu(Menu, { header = data.craftable.Header, onBack = data.onBack or nil, canClose = true, onExit = function() end, })
|
||||||
@@ -96,17 +85,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 ()
|
||||||
@@ -118,61 +110,55 @@ function multiCraft(data) local Menu = {}
|
|||||||
end
|
end
|
||||||
|
|
||||||
function makeItem(data)
|
function makeItem(data)
|
||||||
if not CraftLock then CraftLock = true else return end
|
if CraftLock then return end
|
||||||
local bartime, bartext, animDict, anim = nil, nil, nil, nil
|
CraftLock = true
|
||||||
if data.craftable.progressBar then
|
|
||||||
bartime = data.craftable.progressBar.time
|
|
||||||
bartext = data.craftable.progressBar.label
|
|
||||||
else
|
|
||||||
bartime = 5000
|
|
||||||
bartext = Loc[Config.Lan].progressbar["progress_make"]
|
|
||||||
end
|
|
||||||
animDict = data.craftable.Anims.animDict or "amb@prop_human_parking_meter@male@idle_a"
|
|
||||||
anim = data.craftable.Anims.anim or "idle_a"
|
|
||||||
|
|
||||||
local amount = (data.amount and data.amount ~= 1) and data.amount or 1
|
local bartime = data.craftable.progressBar and data.craftable.progressBar.time or 5000
|
||||||
|
local bartext = data.craftable.progressBar and data.craftable.progressBar.label or Loc[Config.Lan].progressbar["progress_make"]
|
||||||
|
local animDict = data.craftable.Anims.animDict or "amb@prop_human_parking_meter@male@idle_a"
|
||||||
|
local anim = data.craftable.Anims.anim or "idle_a"
|
||||||
|
local amount = data.amount and (data.amount ~= 1) and data.amount or 1
|
||||||
|
|
||||||
local crafted = true
|
local crafted, crafting = true, true
|
||||||
local crafting = true
|
local cam = createTempCam(PlayerPedId(), data.coords)
|
||||||
|
startTempCam(cam)
|
||||||
local cam = createTempCam(PlayerPedId(), data.coords)
|
|
||||||
startTempCam(cam)
|
|
||||||
|
|
||||||
for i = 1, amount do
|
for i = 1, amount do
|
||||||
for _, v in pairs(data.craft) do
|
for k, v in pairs(data.craft) do
|
||||||
if type(v) == "table" then
|
if k ~= "amount" and k ~= "job" then
|
||||||
for l, b in pairs(v) do
|
if type(v) == "table" then
|
||||||
if crafting and progressBar({
|
for l, b in pairs(v) do
|
||||||
label = "Using "..b.." "..Items[l].label,
|
if crafting and progressBar({
|
||||||
time = 1000,
|
label = "Using "..b.." "..Items[l].label,
|
||||||
cancel = true,
|
time = 1000,
|
||||||
dict = 'pickup_object',
|
cancel = true,
|
||||||
anim = "putdown_low",
|
dict = 'pickup_object',
|
||||||
flag = 48,
|
anim = "putdown_low",
|
||||||
icon = l,
|
flag = 48,
|
||||||
}) then
|
icon = l,
|
||||||
--TriggerEvent('inventory:client:ItemBox', Items[l], "use", b) -- Show item box for each item
|
}) then
|
||||||
else
|
--TriggerEvent('inventory:client:ItemBox', Items[l], "use", b) -- Show item box for each item
|
||||||
crafted = false
|
else
|
||||||
crafting = false
|
crafted, crafting = false, false
|
||||||
break
|
break
|
||||||
|
end
|
||||||
|
Wait(200)
|
||||||
end
|
end
|
||||||
Wait(200)
|
if crafted then
|
||||||
end
|
if crafting and progressBar({
|
||||||
if crafted then
|
label = bartext..Items[data.item].label,
|
||||||
if crafting and progressBar({
|
time = bartime,
|
||||||
label = bartext..Items[data.item].label,
|
cancel = true,
|
||||||
time = bartime,
|
dict = animDict,
|
||||||
cancel = true,
|
anim = anim,
|
||||||
dict = animDict,
|
flag = 8,
|
||||||
anim = anim,
|
icon = data.item,
|
||||||
flag = 8,
|
}) then
|
||||||
icon = data.item,
|
TriggerServerEvent(GetCurrentResourceName()..":Crafting:GetItem", data.item, data.craft, data.stashName)
|
||||||
}) then
|
else
|
||||||
TriggerServerEvent(GetCurrentResourceName()..":Crafting:GetItem", data.item, data.craft, data.stashName)
|
crafting = false
|
||||||
else
|
break
|
||||||
crafting = false
|
end
|
||||||
break
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -187,29 +173,25 @@ function makeItem(data)
|
|||||||
end
|
end
|
||||||
|
|
||||||
RegisterNetEvent(GetCurrentResourceName()..":Crafting:GetItem", function(ItemMake, craftable, stashName)
|
RegisterNetEvent(GetCurrentResourceName()..":Crafting:GetItem", function(ItemMake, craftable, stashName)
|
||||||
local src = source
|
local src, amount, stashItems = source, craftable and craftable.amount or 1, stashName and getStash(stashName)
|
||||||
local amount = 1
|
|
||||||
if stashName then
|
if stashName then
|
||||||
local stashItems = getStash(stashName)
|
|
||||||
if craftable["amount"] then amount = craftable["amount"] end
|
|
||||||
local itemRemove = {}
|
local itemRemove = {}
|
||||||
for k, v in pairs(craftable[ItemMake]) do
|
for k, v in pairs(craftable[ItemMake] or {}) do
|
||||||
for l, b in pairs(stashItems) do
|
for _, b in pairs(stashItems or {}) do
|
||||||
if k == b.name then
|
if k == b.name then itemRemove[k] = v end
|
||||||
itemRemove[k] = v
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
stashRemoveItem(stashItems, stashName, itemRemove)
|
stashRemoveItem(stashItems, stashName, itemRemove)
|
||||||
else
|
else
|
||||||
if craftable then
|
if craftable then
|
||||||
if craftable["amount"] then amount = craftable["amount"] end
|
for k, v in pairs(craftable[ItemMake] or {}) do
|
||||||
for k, v in pairs(craftable[ItemMake]) do
|
|
||||||
TriggerEvent(GetCurrentResourceName()..":server:toggleItem", false, tostring(k), v, src)
|
TriggerEvent(GetCurrentResourceName()..":server:toggleItem", false, tostring(k), v, src)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
TriggerEvent(GetCurrentResourceName()..":server:toggleItem", true, ItemMake, amount, src)
|
TriggerEvent(GetCurrentResourceName()..":server:toggleItem", true, ItemMake, amount, src)
|
||||||
|
if GetResourceState("core_skills"):find("start") then exports["core_skills"]:AddExperience(src, 2) end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--[[SHOPS]]--
|
--[[SHOPS]]--
|
||||||
@@ -224,149 +206,67 @@ 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
|
grabInv = src and exports.ox_inventory:GetInventoryItems(src) or exports[OXInv]:GetPlayerItems()
|
||||||
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
|
elseif GetResourceState(QSInv):find("start") then
|
||||||
for _, itemData in pairs(exports[QSInv]:GetInventory(src)) do
|
foundInv = QSInv
|
||||||
if itemData and (itemData.name == items) then
|
grabInv = src and exports[QSInv]:GetInventory(src) or exports[QSInv]:getUserInventory()
|
||||||
--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
|
elseif GetResourceState(OrigenInv):find("start") then
|
||||||
local item = exports[CoreInv]:getItems('primary-'..src, items)
|
foundInv = OrigenInv
|
||||||
|
grabInv = src and exports[OrigenInv]:getPlayerInventory(src) or exports[OrigenInv]:getPlayerInventory()
|
||||||
|
|
||||||
if item.amount >= amount then
|
elseif GetResourceState(CoreInv):find("start") then
|
||||||
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^5FOUND^7 ^3"..item.amount.."^7/^3"..amount.." "..tostring(items)) end
|
foundInv = CoreInv
|
||||||
return true
|
if src then
|
||||||
else if Config.System.Debug then
|
if GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then
|
||||||
print("^6Bridge^7: ^3HasItem^7: ^2"..tostring(items).." ^1NOT FOUND^7") end
|
grabInv = Core.Functions.GetPlayer(src).PlayerData.items
|
||||||
return false
|
elseif GetResourceState(ESXExport):find("start") then
|
||||||
|
local Player = ESX.GetPlayerFromId(src)
|
||||||
|
grabInv = Player.getInventory(false)
|
||||||
end
|
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
|
else
|
||||||
for _, itemData in pairs(Core.Functions.GetPlayer(src).PlayerData.items) do
|
local p = promise.new()
|
||||||
if itemData and (itemData.name == items) then
|
Core.Functions.TriggerCallback('core_inventory:server:getInventory', function(cb) p:resolve(cb) end)
|
||||||
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
|
local result = Citizen.Await(p)
|
||||||
count += (itemData.amount or 1)
|
if type(result) == "string" then result = json.decode(result) end
|
||||||
end
|
grabInv = result
|
||||||
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(CodeMInv):find("start") then
|
||||||
|
foundInv = CodeMInv
|
||||||
|
grabInv = src and exports[CodeMInv]:GetUserInventory(src) or exports[CodeMInv]:GetClientPlayerInventory()
|
||||||
|
|
||||||
|
elseif GetResourceState(QBInv):find("start") then
|
||||||
|
foundInv = QBInv
|
||||||
|
grabInv = src and Core.Functions.GetPlayer(src).PlayerData.items or Core.Functions.GetPlayerData().items
|
||||||
|
|
||||||
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]:GetInventory()) 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
|
||||||
end
|
for _, itemData in pairs(grabInv) do
|
||||||
|
if itemData and (itemData.name == item) then count += (itemData.count or itemData.amount or 1) end
|
||||||
end
|
end
|
||||||
if count >= amount then
|
foundInv = foundInv:gsub("%-", "^7-^6"):gsub("%_", "^7_^6")
|
||||||
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^5FOUND^7 ^3"..count.."^7/^3"..amount.." "..tostring(items)) end
|
local foundMessage = "^6Bridge^7: ^3hasItem^7[^6"..foundInv.."^7]: "..tostring(item).." ^3"..count.."^7/^3"..amount
|
||||||
return true
|
if count >= amount then foundMessage = foundMessage.." ^5FOUND^7" else foundMessage = foundMessage .." ^1NOT FOUND^7" end
|
||||||
else
|
if Config.System.Debug then print(foundMessage) end
|
||||||
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^2"..tostring(items).." ^1NOT FOUND^7") end
|
hasTable[item] = { hasItem = count >= amount, count = count }
|
||||||
return false
|
|
||||||
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 not v.hasItem then return false, hasTable end end
|
||||||
|
return true, hasTable
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -379,43 +279,51 @@ 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
|
||||||
|
|
||||||
function getStash(stashName)
|
function getStash(stashName) local stashResource = ""
|
||||||
local stashItems, items = {}, {}
|
local stashItems, items = {}, {}
|
||||||
if GetResourceState(OXInv):find("start") then
|
if GetResourceState(OXInv):find("start") then stashResource = OXInv
|
||||||
if Config.System.Debug then print("^6Bridge^7: ^2Retrieving ^3Stash^2 with ^7ox_inventory") end
|
|
||||||
stashItems = exports[OXInv]:Inventory(stashName).items
|
stashItems = exports[OXInv]:Inventory(stashName).items
|
||||||
elseif GetResourceState(QSInv):find("start") then
|
|
||||||
if Config.System.Debug then print("^6Bridge^7: ^2Retrieving ^3Stash^2 with ^7qs-inventory") end
|
elseif GetResourceState(QSInv):find("start") then stashResource = QSInv
|
||||||
stashItems = exports[QSInv]:GetStashItems(stashName)
|
stashItems = exports[QSInv]:GetStashItems(stashName)
|
||||||
elseif GetResourceState(CodeMInv):find("start") then
|
|
||||||
if Config.System.Debug then print("^6Bridge^7: ^2Retrieving ^3Stash^2 with ^7qs-inventory") end
|
elseif GetResourceState(CoreInv):find("start") then stashResource = CoreInv
|
||||||
|
stashItems = exports[CoreInv]:getInventory(stashName)
|
||||||
|
|
||||||
|
elseif GetResourceState(CodeMInv):find("start") then stashResource = CodeMInv
|
||||||
stashItems = exports[CodeMInv]:GetInventoryItems('Stash', stashName)
|
stashItems = exports[CodeMInv]:GetInventoryItems('Stash', stashName)
|
||||||
elseif GetResourceState(QBInv):find("start") then
|
|
||||||
if Config.System.Debug then print("^6Bridge^7: ^2Retrieving ^3Stash^2 with ^7qb-inventory") end
|
elseif GetResourceState(OrigenInv):find("start") then stashResource = OrigenInv
|
||||||
|
stashItems = exports[OrigenInv]:GetStashItems(stashName)
|
||||||
|
|
||||||
|
elseif GetResourceState(QBInv):find("start") then stashResource = QBInv
|
||||||
local result = MySQL.scalar.await('SELECT items FROM stashitems WHERE stash = ?', { stashName })
|
local result = MySQL.scalar.await('SELECT items FROM stashitems WHERE stash = ?', { stashName })
|
||||||
if result then stashItems = json.decode(result) end
|
if result then stashItems = json.decode(result) end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if Config.System.Debug then print("^6Bridge^7: ^2Retrieving ^3Stash^2 with ^7"..stashResource) end
|
||||||
if stashItems then
|
if stashItems then
|
||||||
for _, item in pairs(stashItems) do
|
for _, item in pairs(stashItems) do
|
||||||
local itemInfo = Items[item.name:lower()]
|
local itemInfo = Items[item.name:lower()]
|
||||||
if itemInfo then
|
if itemInfo then
|
||||||
items[item.slot] = {
|
local indexNum = #items+1 -- Added to help recreate missing slot numbers
|
||||||
name = itemInfo["name"],
|
items[(item.slot and item.slot) or indexNum] = {
|
||||||
|
name = itemInfo.name or nil,
|
||||||
amount = tonumber(item.amount) or tonumber(item.count),
|
amount = tonumber(item.amount) or tonumber(item.count),
|
||||||
info = item.info ~= nil and item.info or "",
|
info = item.info or "",
|
||||||
label = itemInfo["label"],
|
label = itemInfo.label or nil,
|
||||||
description = itemInfo["description"] ~= nil and itemInfo["description"] or "",
|
description = itemInfo.description or "",
|
||||||
weight = itemInfo["weight"],
|
weight = itemInfo.weight or nil,
|
||||||
type = itemInfo["type"],
|
type = itemInfo.type or nil,
|
||||||
unique = itemInfo["unique"],
|
unique = itemInfo.unique or nil,
|
||||||
useable = itemInfo["useable"],
|
useable = itemInfo.useable or nil,
|
||||||
image = itemInfo["image"],
|
image = itemInfo.image or nil,
|
||||||
slot = item.slot,
|
slot = (item.slot and item.slot) or indexNum,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -430,11 +338,32 @@ function stashRemoveItem(stashItems, stashName, items) local amount = amount and
|
|||||||
exports[OXInv]:RemoveItem(stashName, k, v)
|
exports[OXInv]:RemoveItem(stashName, k, v)
|
||||||
if Config.System.Debug then print("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..OXInv, k, v) end
|
if Config.System.Debug then print("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..OXInv, k, v) end
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif GetResourceState(QSInv):find("start") then
|
elseif GetResourceState(QSInv):find("start") then
|
||||||
|
for k, v in pairs(items) do
|
||||||
|
for l in pairs(stashItems) do
|
||||||
|
if stashItems[l].name == k then
|
||||||
|
if (stashItems[l].amount - v) <= 0 then
|
||||||
|
if Config.System.Debug then
|
||||||
|
print("^6Bridge^7: ^2None of this item left in stash ^3Stash^7", k, v)
|
||||||
|
end
|
||||||
|
stashItems[l] = nil
|
||||||
|
else
|
||||||
|
if Config.System.Debug then
|
||||||
|
print("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..QBInv, k, v)
|
||||||
|
end
|
||||||
|
exports[QSInv]:RemoveItemIntoStash(stashName, k, v, l)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
elseif GetResourceState(CoreInv):find("start") then
|
||||||
for k, v in pairs(items) do
|
for k, v in pairs(items) do
|
||||||
exports[QSInv]:RemoveItemIntoStash(stashName, k, v)
|
exports[CoreInv]:removeItemExact(stashName, k, v)
|
||||||
if Config.System.Debug then print("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..QSInv, k, v) end
|
if Config.System.Debug then print("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..CoreInv, k, v) end
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif GetResourceState(CodeMInv):find("start") then
|
elseif GetResourceState(CodeMInv):find("start") then
|
||||||
for k, v in pairs(items) do
|
for k, v in pairs(items) do
|
||||||
for l in pairs(stashItems) do
|
for l in pairs(stashItems) do
|
||||||
@@ -456,7 +385,14 @@ 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(OrigenInv):find("start") then
|
||||||
|
for k, v in pairs(items) do
|
||||||
|
exports[OrigenInv]:RemoveItem(stashName, k, v)
|
||||||
|
if Config.System.Debug then print("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..OrigenInv, k, v) end
|
||||||
|
end
|
||||||
|
|
||||||
|
elseif GetResourceState(QBInv):find("start") then
|
||||||
for k, v in pairs(items) do
|
for 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 +414,37 @@ 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 invs = {OXInv, QSInv, CoreInv, CodeMInv, OrigenInv, QBInv}
|
||||||
if itemData and (itemData.name == item) then
|
local foundInv = ""
|
||||||
--if Config.System.Debug then
|
for _, inv in ipairs(invs) do
|
||||||
-- print("^6Bridge^7: ^3stashHasItem^7: ^2Item^7: '^3"..tostring(item).."^7' ^2Slot^7: ^3"..itemData.slot.." ^7x(^3"..tostring(itemData.amount).."^7)")
|
if GetResourceState(inv):find("start") then
|
||||||
--end
|
foundInv = inv:gsub("%-", "^7-^6"):gsub("%_", "^7_^6")
|
||||||
count += (itemData.amount or 1)
|
break
|
||||||
end
|
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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
local debugMsg = string.format("^6Bridge^7: ^3stashHasItem^7[^6%s^7]: %s '%s' ^3%d^7/^3%d^7", foundInv, (count >= amount and "^5FOUND^7" or "^1NOT FOUND^7"), item, count, amount)
|
||||||
|
if Config.System.Debug then print(debugMsg) end
|
||||||
|
|
||||||
|
hasTable[item] = { hasItem = (count >= amount), count = count }
|
||||||
|
end
|
||||||
|
for k, v in pairs(hasTable) do if v.hasItem == false then return false, hasTable end end
|
||||||
|
return true, hasTable
|
||||||
end
|
end
|
||||||
@@ -7,8 +7,9 @@ Exports = {
|
|||||||
OXInv = "ox_inventory",
|
OXInv = "ox_inventory",
|
||||||
QBInv = "qb-inventory",
|
QBInv = "qb-inventory",
|
||||||
QSInv = "qs-inventory",
|
QSInv = "qs-inventory",
|
||||||
CoreInv = "core-inventory",
|
CoreInv = "core_inventory",
|
||||||
CodeMInv = "codem-inventory",
|
CodeMInv = "codem-inventory",
|
||||||
|
OrigenInv = "origen_inventory",
|
||||||
|
|
||||||
OXLibExport = "ox_lib",
|
OXLibExport = "ox_lib",
|
||||||
|
|
||||||
|
|||||||
153
functions.lua
153
functions.lua
@@ -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)
|
||||||
@@ -95,11 +95,26 @@ function makeProp(data, freeze, synced)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function cv(amount)
|
function cv(amount)
|
||||||
local formatted = 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
|
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
|
return formatted
|
||||||
end
|
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)
|
AddEventHandler('onResourceStop', function(r)
|
||||||
if r ~= GetCurrentResourceName() then return end
|
if r ~= GetCurrentResourceName() then return end
|
||||||
stopSpinner()
|
stopSpinner()
|
||||||
@@ -139,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)
|
||||||
@@ -173,6 +190,18 @@ 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)
|
||||||
@@ -288,8 +317,6 @@ function progressBar(data)
|
|||||||
if data.cam then stopTempCam(data.cam) end
|
if data.cam then stopTempCam(data.cam) end
|
||||||
end
|
end
|
||||||
|
|
||||||
exports["esx_progressbar"]:Progressbar(message, length, Options)
|
|
||||||
|
|
||||||
elseif Config.System.ProgressBar == "qb" then
|
elseif Config.System.ProgressBar == "qb" then
|
||||||
Core.Functions.Progressbar("mechbar",
|
Core.Functions.Progressbar("mechbar",
|
||||||
data.label,
|
data.label,
|
||||||
@@ -476,7 +503,7 @@ function setThirst(src, thirst)
|
|||||||
if GetResourceState(ESXExport):find("start") then
|
if GetResourceState(ESXExport):find("start") then
|
||||||
TriggerClientEvent('esx_status:add', src, 'thirst', thirst)
|
TriggerClientEvent('esx_status:add', src, 'thirst', thirst)
|
||||||
elseif GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then
|
elseif GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then
|
||||||
local Player = QBCore.Functions.GetPlayer(src)
|
local Player = Core.Functions.GetPlayer(src)
|
||||||
Player.Functions.SetMetaData('thirst', thirst)
|
Player.Functions.SetMetaData('thirst', thirst)
|
||||||
TriggerClientEvent("hud:client:UpdateNeeds", src, thirst, Player.PlayerData.metadata.thirst)
|
TriggerClientEvent("hud:client:UpdateNeeds", src, thirst, Player.PlayerData.metadata.thirst)
|
||||||
end
|
end
|
||||||
@@ -486,7 +513,7 @@ function setHunger(src, hunger)
|
|||||||
if GetResourceState(ESXExport):find("start") then
|
if GetResourceState(ESXExport):find("start") then
|
||||||
TriggerClientEvent('esx_status:add', src, 'hunger', hunger)
|
TriggerClientEvent('esx_status:add', src, 'hunger', hunger)
|
||||||
elseif GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then
|
elseif GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then
|
||||||
local Player = QBCore.Functions.GetPlayer(src)
|
local Player = Core.Functions.GetPlayer(src)
|
||||||
Player.Functions.SetMetaData('hunger', hunger)
|
Player.Functions.SetMetaData('hunger', hunger)
|
||||||
TriggerClientEvent("hud:client:UpdateNeeds", src, hunger, Player.PlayerData.metadata.hunger)
|
TriggerClientEvent("hud:client:UpdateNeeds", src, hunger, Player.PlayerData.metadata.hunger)
|
||||||
end
|
end
|
||||||
@@ -536,8 +563,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
|
||||||
@@ -545,12 +573,38 @@ RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give,
|
|||||||
if hasItem(item, amount and amount or 1, src) then -- check if you still have the item
|
if hasItem(item, amount and amount or 1, src) then -- check if you still have the item
|
||||||
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
|
||||||
|
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
|
elseif GetResourceState(QSInv):find("start") then
|
||||||
local success = exports[QSInv]:RemoveItem(src, item, amount)
|
local success = exports[QSInv]:RemoveItem(src, item, amount)
|
||||||
elseif GetResourceState(CoreInv):find("start") then
|
if Config.System.Debug then
|
||||||
local success = exports[CoreInv]:removeItemExact('primary-'..src, item, amount)
|
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")
|
||||||
elseif GetResourceState(CodeMInv):find("start") then
|
end
|
||||||
|
|
||||||
|
elseif GetResourceState(CoreInv):find("start") then
|
||||||
|
if GetResourceState(QBExport):find("start") then
|
||||||
|
Core.Functions.GetPlayer(src).Functions.RemoveItem(item, amount, nil)
|
||||||
|
elseif GetResourceState(ESXExport):find("start") then
|
||||||
|
ESX.GetPlayerFromId(src).removeInventoryItem(item, count)
|
||||||
|
end
|
||||||
|
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(OrigenInv):find("start") then
|
||||||
|
local success = exports[OrigenInv]:RemoveItem(src, item, amount)
|
||||||
|
if Config.System.Debug then
|
||||||
|
print("^6Bridge^7: ^3"..addremove.."^7[^6"..OrigenInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7")
|
||||||
|
end
|
||||||
|
|
||||||
|
elseif GetResourceState(CodeMInv):find("start") then
|
||||||
local success = exports[CodeMInv]:RemoveItem(src, item, amount)
|
local success = exports[CodeMInv]:RemoveItem(src, item, amount)
|
||||||
|
if Config.System.Debug then
|
||||||
|
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
|
elseif GetResourceState(QBInv):find("start") then
|
||||||
while remamount > 0 do
|
while remamount > 0 do
|
||||||
if Core.Functions.GetPlayer(src).Functions.RemoveItem(item, 1) then end
|
if Core.Functions.GetPlayer(src).Functions.RemoveItem(item, 1) then end
|
||||||
@@ -559,10 +613,12 @@ RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give,
|
|||||||
if Config.Crafting.showItemBox then
|
if Config.Crafting.showItemBox then
|
||||||
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
|
||||||
|
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
|
||||||
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
|
else
|
||||||
dupeWarn(src, item) -- if not boot the player
|
dupeWarn(src, item) -- if not boot the player
|
||||||
end
|
end
|
||||||
@@ -571,26 +627,49 @@ 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) ^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
|
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) ^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
|
end
|
||||||
|
|
||||||
elseif GetResourceState(CoreInv):find("start") then
|
elseif GetResourceState(CoreInv):find("start") then
|
||||||
local success = exports[CoreInv]:addItem('primary-'..src, item, amount)
|
if GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then
|
||||||
if Config.System.Debug then
|
Core.Functions.GetPlayer(src).Functions.AddItem(item, amount, nil, nil)
|
||||||
print("^6Bridge^7: ^4Giving ^2Player^7(^2"..src.."^7) '^6"..Items[item].label.."^7(^2x^6"..((amount and amount or "1")).."^7) ^1Core^7'")
|
elseif GetResourceState(ESXExport):find("start") then
|
||||||
|
ESX.GetPlayerFromId(src).addInventoryItem(item, amount)
|
||||||
|
end
|
||||||
|
if Config.System.Debug then
|
||||||
|
print("^6Bridge^7: ^3"..addremove.."^7[^6"..CoreInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7")
|
||||||
end
|
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)
|
||||||
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(OrigenInv):find("start") then
|
||||||
|
local success = exports[OrigenInv]:AddItem(src, item, amount)
|
||||||
|
if Config.System.Debug then
|
||||||
|
print("^6Bridge^7: ^3"..addremove.."^7[^6"..OrigenInv.."^7] ^2Player^7("..src..") ^6"..Items[item].label.."^7("..item..") x^5"..(amount and amount or "1").."^7")
|
||||||
|
end
|
||||||
|
|
||||||
|
elseif GetResourceState(QBInv):find("start") then
|
||||||
if Core.Functions.GetPlayer(src).Functions.AddItem(item, amount or 1) then
|
if Core.Functions.GetPlayer(src).Functions.AddItem(item, amount or 1) then
|
||||||
--if Config.Crafting.showItemBox then
|
--if Config.Crafting.showItemBox then
|
||||||
TriggerClientEvent("inventory:client:ItemBox", src, Items[item], "add", amount and amount or 1)
|
TriggerClientEvent("inventory:client:ItemBox", src, Items[item], "add", amount and amount or 1)
|
||||||
--end
|
--end
|
||||||
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
|
end
|
||||||
end)
|
end)
|
||||||
@@ -601,12 +680,11 @@ function dupeWarn(src, item)
|
|||||||
if Config.System.Debug == false then
|
if Config.System.Debug == false then
|
||||||
DropPlayer(src, src.." ^1Kicked for attempting to duplicate items")
|
DropPlayer(src, src.." ^1Kicked for attempting to duplicate items")
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
|
|
||||||
function toggleDuty()
|
function toggleDuty()
|
||||||
if GetResourceState(QBExport):find("start") then
|
if GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then
|
||||||
TriggerServerEvent("QBCore:ToggleDuty")
|
TriggerServerEvent("QBCore:ToggleDuty")
|
||||||
else
|
else
|
||||||
onDuty = not onDuty
|
onDuty = not onDuty
|
||||||
@@ -620,12 +698,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"):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
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
name "Jim_Bridge"
|
name "Jim_Bridge"
|
||||||
author "Jimathy"
|
author "Jimathy"
|
||||||
version "alpha"
|
version "1.0.9"
|
||||||
description "Framework Bridge By Jimathy"
|
description "Framework Bridge By Jimathy"
|
||||||
fx_version "cerulean"
|
fx_version "cerulean"
|
||||||
game "gta5"
|
game "gta5"
|
||||||
@@ -11,4 +11,4 @@ files {
|
|||||||
'functions.lua',
|
'functions.lua',
|
||||||
'wrapper.lua',
|
'wrapper.lua',
|
||||||
'crafting.lua',
|
'crafting.lua',
|
||||||
}
|
}
|
||||||
|
|||||||
1
version.txt
Normal file
1
version.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
1.0.9
|
||||||
470
wrapper.lua
470
wrapper.lua
@@ -1,73 +1,84 @@
|
|||||||
Items, Vehicles, Jobs, Gangs, Core, ESX = {}, nil, nil, nil, nil, nil
|
Items, Vehicles, Jobs, Gangs, Core, ESX = {}, nil, nil, nil, nil, nil
|
||||||
|
|
||||||
OXLibExport = Exports and Exports.OXLibExport or ""
|
Exports.QBInv = GetResourceState("ps-inventory"):find("start") and "ps-inventory" or GetResourceState("lj-inventory"):find("start") and "lj-inventory" or Exports.QBInv
|
||||||
|
|
||||||
QBXExport = Exports and Exports.QBXExport or ""
|
OXLibExport, QBXExport, QBExport, ESXExport, OXCoreExport = Exports.OXLibExport or "", Exports.QBXExport or "", Exports.QBExport or "", Exports.ESXExport or "", Exports.OXCoreExport or ""
|
||||||
QBExport = Exports and Exports.QBExport or ""
|
|
||||||
ESXExport = Exports and Exports.ESXExport or ""
|
|
||||||
OXCoreExport = Exports and Exports.OXCoreExport or ""
|
|
||||||
|
|
||||||
OXInv = Exports and Exports.OXInv or ""
|
OXInv, QBInv, QSInv, CoreInv, CodeMInv, OrigenInv = Exports.OXInv or "", Exports.QBInv or "", Exports.QSInv or "", Exports.CoreInv or "", Exports.CodeMInv or "", Exports.OrigenInv or ""
|
||||||
QBInv = Exports and Exports.QBInv or ""
|
|
||||||
QSInv = Exports and Exports.QSInv or ""
|
|
||||||
CoreInv = Exports and Exports.CoreInv or ""
|
|
||||||
CodeMInv = Exports and Exports.CodeMInv or ""
|
|
||||||
|
|
||||||
QBMenuExport = Exports and Exports.QBMenuExport or ""
|
QBMenuExport = Exports.QBMenuExport or ""
|
||||||
|
|
||||||
QBTargetExport = Exports and Exports.QBTargetExport or ""
|
QBTargetExport, OXTargetExport = Exports.QBTargetExport or "", Exports.OXTargetExport or ""
|
||||||
OXTargetExport = Exports and Exports.OXTargetExport or ""
|
|
||||||
|
function CheckBridgeVersion()
|
||||||
|
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
|
for k, v in pairs(Exports) do
|
||||||
if GetResourceState(v):find("start") then print("^6Bridge^7: '^3"..v.."^7' ^2export found ^7") end
|
if GetResourceState(v):find("start") then print("^6Bridge^7: '^3"..v.."^7' ^2export found ^7") end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Load item lists from qb-core or ox_lib
|
local itemResource, vehResource, jobResource = "", "", ""
|
||||||
if GetResourceState(OXInv):find("start") then
|
|
||||||
print("^6Bridge^7: ^2Loading ^3Items^2 from ^7"..OXInv)
|
-- Load item lists
|
||||||
|
if GetResourceState(OXInv):find("start") then itemResource = OXInv
|
||||||
Items = exports[OXInv]:Items()
|
Items = exports[OXInv]:Items()
|
||||||
for k, v in pairs(Items) do
|
for k, v in pairs(Items) do
|
||||||
if v.client then
|
if v.client and v.client.image then
|
||||||
if v.client.image then Items[k].image = (Items[k].client.image):gsub("nui://"..OXInv.."/web/images/","")
|
Items[k].image = (v.client.image):gsub("nui://"..OXInv.."/web/images/", "")
|
||||||
else Items[k].image = k..".png" end
|
else
|
||||||
if v.client.hunger then Items[k].hunger = v.client.hunger end
|
Items[k].image = k..".png"
|
||||||
if v.client.thirst then Items[k].thirst = v.client.thirst end
|
|
||||||
end
|
end
|
||||||
|
Items[k].hunger = v.client and v.client.hunger or nil
|
||||||
|
Items[k].thirst = v.client and v.client.thirst or nil
|
||||||
end
|
end
|
||||||
elseif GetResourceState(QBExport):find("start") then
|
|
||||||
print("^6Bridge^7: ^2Loading ^3Items^2 from ^7"..QBExport)
|
elseif GetResourceState(QBExport):find("start") then itemResource = QBExport
|
||||||
Core = Core or exports[QBExport]:GetCoreObject()
|
Core = Core or exports[QBExport]:GetCoreObject()
|
||||||
Items = Core.Shared.Items
|
Items = Core and Core.Shared.Items or nil
|
||||||
elseif GetResourceState(ESXExport):find("start") then
|
|
||||||
print("^6Bridge^7: ^2Loading ^3Items^2 from ^7"..ESXExport)
|
elseif GetResourceState(ESXExport):find("start") then itemResource = ESXExport
|
||||||
ESX = exports[ESXExport]:getSharedObject()
|
ESX = exports[ESXExport]:getSharedObject()
|
||||||
Items = ESX.Items
|
Items = ESX and ESX.Items or nil
|
||||||
|
end
|
||||||
|
if not Items then
|
||||||
|
print("^4ERROR^7: ^2No Core Items detected ^7- ^2Check ^3exports^1.^2lua^7")
|
||||||
|
else
|
||||||
|
print("^6Bridge^7: ^2Loading ^6"..countTable(Items).." ^3Items^2 from ^7" .. itemResource)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Load Vehicles
|
-- Load Vehicles
|
||||||
if GetResourceState(QBXExport):find("start") then
|
if GetResourceState(QBXExport):find("start") or GetResourceState(QBExport):find("start") then vehResource = QBExport
|
||||||
Core = Core or exports[QBExport]:GetCoreObject()
|
Core = Core or exports[QBExport]:GetCoreObject()
|
||||||
print("^6Bridge^7: ^2Loading ^3Vehicles^2 from ^7"..QBXExport)
|
if GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then
|
||||||
Vehicles = exports[QBXExport]:GetVehiclesByHash()
|
RegisterNetEvent('QBCore:Client:UpdateObject', function()
|
||||||
elseif GetResourceState(QBExport):find("start") then
|
Core = Core or exports[QBExport]:GetCoreObject()
|
||||||
print("^6Bridge^7: ^2Loading ^3Vehicles^2 from ^7"..QBExport)
|
end)
|
||||||
Core = Core or exports[QBExport]:GetCoreObject()
|
end
|
||||||
RegisterNetEvent('QBCore:Client:UpdateObject', function()
|
Vehicles = Core and Core.Shared.Vehicles
|
||||||
Core = Core or exports[QBExport]:GetCoreObject()
|
print("^6Bridge^7: ^2Loading ^6"..countTable(Vehicles).." ^3Vehicles^2 from ^7"..QBExport)
|
||||||
end)
|
|
||||||
Vehicles = Core.Shared.Vehicles
|
|
||||||
elseif GetResourceState(OXCoreExport):find("start") then
|
elseif GetResourceState(OXCoreExport):find("start") then
|
||||||
print("^6Bridge^7: ^2Loading ^3Vehicles^2 from ^7"..OXCoreExport)
|
Vehicles = {}
|
||||||
for k, v in pairs(Ox.GetVehicleData()) do
|
for k, v in pairs(Ox.GetVehicleData()) do
|
||||||
Vehicles = Vehicles or {}
|
|
||||||
Vehicles[k] = { model = k, price = v.price, name = v.name, brand = v.make }
|
Vehicles[k] = { model = k, price = v.price, name = v.name, brand = v.make }
|
||||||
end
|
end
|
||||||
|
print("^6Bridge^7: ^2Loading ^6"..countTable(Vehicles).." ^3Vehicles^2 from ^7"..OXCoreExport)
|
||||||
elseif GetResourceState(ESXExport):find("start") then
|
elseif GetResourceState(ESXExport):find("start") then
|
||||||
print("^6Bridge^7: ^2Loading ^3Vehicles^2 from ^7"..ESXExport)
|
print("^6Bridge^7: ^2Loading ^3Vehicles^2 from ^7"..ESXExport)
|
||||||
|
--print("^6Bridge^7: ^2Loading ^6"..countTable(Vehicles).." ^3Vehicles^2 from ^7"..ESXExport)
|
||||||
CreateThread(function()
|
CreateThread(function()
|
||||||
if IsDuplicityVersion() then
|
if IsDuplicityVersion() then
|
||||||
createCallback(GetCurrentResourceName()..":getVehiclesPrices", function(source)
|
createCallback(GetCurrentResourceName()..":getVehiclesPrices", function(source)
|
||||||
Vehicles = MySQL.query.await('SELECT model, price, name FROM vehicles')
|
Vehicles = MySQL.query.await('SELECT model, price, name FROM vehicles')
|
||||||
|
print("^6Bridge^7: ^3Found ^6"..countTable(Vehicles).." ^3Vehicles^2 from ^7"..ESXExport)
|
||||||
return Vehicles
|
return Vehicles
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
@@ -79,40 +90,38 @@ elseif GetResourceState(ESXExport):find("start") then
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
else
|
||||||
|
print("^4ERROR^7: ^2No Vehicle info detected ^7- ^2Check ^3exports^1.^2lua^7")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Load Jobs
|
-- Load Jobs
|
||||||
if GetResourceState(QBXExport):find("start") then
|
local jobResource = ""
|
||||||
|
if GetResourceState(QBXExport):find("start") then jobResource = QBXExport
|
||||||
Core = Core or exports[QBExport]:GetCoreObject()
|
Core = Core or exports[QBExport]:GetCoreObject()
|
||||||
print("^6Bridge^7: ^2Loading ^3Jobs^7/^3Gangs^2 from ^7"..QBXExport)
|
Jobs, Gangs = exports[QBXExport]:GetJobs(), exports[QBXExport]:GetGangs()
|
||||||
Jobs = exports[QBXExport]:GetJobs()
|
|
||||||
Gangs = exports[QBXExport]:GetGangs()
|
|
||||||
|
|
||||||
elseif GetResourceState(OXCoreExport):find("start") then
|
elseif GetResourceState(OXCoreExport):find("start") then jobResource = OXExport
|
||||||
print("^6Bridge^7: ^2Loading ^3Jobs^7/^3Gangs^2 from ^7"..OXCoreExport)
|
|
||||||
CreateThread(function()
|
CreateThread(function()
|
||||||
if IsDuplicityVersion() then
|
if IsDuplicityVersion() then
|
||||||
createCallback(GetCurrentResourceName()..":getOxGroups", function(source)
|
createCallback(GetCurrentResourceName()..":getOxGroups", function(source)
|
||||||
Jobs = MySQL.query.await('SELECT * FROM `ox_groups`')
|
Jobs = MySQL.query.await('SELECT * FROM `ox_groups`') return Jobs
|
||||||
return Jobs
|
|
||||||
end)
|
end)
|
||||||
else
|
else
|
||||||
local TempJobs = triggerCallback(GetCurrentResourceName()..":getOxGroups")
|
local TempJobs = triggerCallback(GetCurrentResourceName()..":getOxGroups")
|
||||||
|
Jobs = TempJobs and {}
|
||||||
for k, v in pairs(TempJobs) do
|
for k, v in pairs(TempJobs) do
|
||||||
local grades = {}
|
local grades = {}
|
||||||
for i = 1, #v.grades do grades[i] = { name = grades[i], isboss = (i == #v.grades)} end
|
for i = 1, #v.grades do grades[i] = { name = v.grades[i], isboss = (i == #v.grades)} end
|
||||||
Jobs = Jobs or {}
|
Jobs[v.name] = { label = v.label, grades = grades }
|
||||||
Jobs[v.name] = { label = v.label, grades = grades, }
|
|
||||||
end
|
end
|
||||||
|
Gangs = Jobs
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
elseif GetResourceState(QBExport):find("start") then
|
elseif GetResourceState(QBExport):find("start") then jobResource = QBExport
|
||||||
print("^6Bridge^7: ^2Loading ^3Jobs^7/^3Gangs^2 from ^7"..QBExport)
|
|
||||||
Core = Core or Core or exports[QBExport]:GetCoreObject()
|
Core = Core or Core or exports[QBExport]:GetCoreObject()
|
||||||
RegisterNetEvent('QBCore:Client:UpdateObject', function() Core = Core or exports[QBExport]:GetCoreObject() end)
|
RegisterNetEvent('QBCore:Client:UpdateObject', function() Core = Core or exports[QBExport]:GetCoreObject() end)
|
||||||
Jobs = Core.Shared.Jobs
|
Jobs, Gangs = Core.Shared.Jobs, Core.Shared.Gangs
|
||||||
Gangs = Core.Shared.Gangs
|
|
||||||
|
|
||||||
elseif GetResourceState(ESXExport):find("start") then
|
elseif GetResourceState(ESXExport):find("start") then
|
||||||
print("^6Bridge^7: ^2Loading ^3Jobs^7/^3Gangs^2 from ^7"..ESXExport)
|
print("^6Bridge^7: ^2Loading ^3Jobs^7/^3Gangs^2 from ^7"..ESXExport)
|
||||||
@@ -138,26 +147,20 @@ elseif GetResourceState(ESXExport):find("start") then
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
if not GetResourceState(ESXExport):find("start") and Jobs then
|
||||||
|
print("^6Bridge^7: ^2Loading ^6"..countTable(Jobs).." ^3Jobs^2 from ^7"..jobResource, "^6Bridge^7: ^2Loading ^6"..countTable(Gangs).." ^3Gangs^2 from ^7"..jobResource)
|
||||||
|
end
|
||||||
|
|
||||||
function makeBossRoles(role)
|
function makeBossRoles(role)
|
||||||
local boss = {}
|
local boss = {}
|
||||||
if Jobs and Jobs[role] then
|
local data = Jobs and Jobs[role] or Gangs and Gangs[role]
|
||||||
for grade in pairs(Jobs[role].grades) do
|
if data then
|
||||||
if Jobs[role].grades[grade].isboss then
|
for grade, info in pairs(data.grades) do
|
||||||
if boss[role] then
|
if info.isboss then
|
||||||
if boss[role] > tonumber(grade) then boss[role] = tonumber(grade) end
|
boss[role] = boss[role] and math.min(boss[role], tonumber(grade)) or tonumber(grade)
|
||||||
else boss[role] = tonumber(grade) end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif Gangs and Gangs[role] then
|
|
||||||
for grade in pairs(Gangs[role].grades) do
|
|
||||||
if Gangs[role].grades[grade].isboss then
|
|
||||||
if boss[role] then
|
|
||||||
if boss[role] > tonumber(grade) then boss[role] = tonumber(grade) end
|
|
||||||
else boss[role] = tonumber(grade) end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return boss
|
return boss
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -173,12 +176,10 @@ function createPoly(data) local Location = nil
|
|||||||
if Config.System.Debug then print("^6Bridge^7: ^2Creating new poly with ^7PolyZone "..data.name) end
|
if Config.System.Debug then print("^6Bridge^7: ^2Creating new poly with ^7PolyZone "..data.name) end
|
||||||
Location = PolyZone:Create(data.points, { name = data.name, debugPoly = data.debug })
|
Location = PolyZone:Create(data.points, { name = data.name, debugPoly = data.debug })
|
||||||
Location:onPlayerInOut(function(isPointInside)
|
Location:onPlayerInOut(function(isPointInside)
|
||||||
if isPointInside then
|
if isPointInside then data.onEnter() else data.onExit() end
|
||||||
data.onEnter()
|
|
||||||
else
|
|
||||||
data.onExit()
|
|
||||||
end
|
|
||||||
end)
|
end)
|
||||||
|
else
|
||||||
|
print("^4ERROR^7: ^2No PolyZone creation script detected ^7- ^2Check ^3exports^1.^2lua^7")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -196,24 +197,33 @@ function createCirclePoly(data) local Location = nil
|
|||||||
data.onExit()
|
data.onExit()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
else
|
||||||
|
print("^4ERROR^7: ^2No PolyZone creation script detected ^7- ^2Check ^3exports^1.^2lua^7")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function openMenu(Menu, data)
|
function openMenu(Menu, data)
|
||||||
if Config.System.Menu == "ox" then
|
if Config.System.Menu == "ox" then
|
||||||
if data.onBack then
|
local index = nil
|
||||||
|
if data.onBack and not data.onSelected then
|
||||||
table.insert(Menu, 1, { icon = "fas fa-circle-arrow-left",
|
table.insert(Menu, 1, { icon = "fas fa-circle-arrow-left",
|
||||||
title = "Return",
|
title = "Return",
|
||||||
onSelect = data.onBack,
|
onSelect = data.onBack,
|
||||||
|
label = "Return"
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
for k in pairs(Menu) do
|
for k in pairs(Menu) do
|
||||||
|
if data.onSelected and Menu[k].arrow then
|
||||||
|
Menu[k].icon = "fas fa-angle-right"
|
||||||
|
end
|
||||||
if not Menu[k].title then
|
if not Menu[k].title then
|
||||||
if Menu[k].header ~= nil and Menu[k].header ~= "" then
|
if Menu[k].header ~= nil and Menu[k].header ~= "" then
|
||||||
Menu[k].title = Menu[k].header
|
Menu[k].title = Menu[k].header
|
||||||
|
Menu[k].label = Menu[k].header
|
||||||
if Menu[k].txt then Menu[k].description = Menu[k].txt else Menu[k].description = "" end
|
if Menu[k].txt then Menu[k].description = Menu[k].txt else Menu[k].description = "" end
|
||||||
else
|
else
|
||||||
Menu[k].title = Menu[k].txt
|
Menu[k].title = Menu[k].txt
|
||||||
|
Menu[k].label = Menu[k].txt
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if Menu[k].params then
|
if Menu[k].params then
|
||||||
@@ -224,8 +234,35 @@ function openMenu(Menu, data)
|
|||||||
Menu[k].disabled = true
|
Menu[k].disabled = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
lib.registerContext({id = 'Menu', title = data.header..br..br..(data.headertxt and data.headertxt or ""), position = 'top-right', options = Menu, canClose = data.canClose and data.canClose or nil, onExit = data.onExit and data.onExit or nil, })
|
local menuID = 'Menu'
|
||||||
lib.showContext("Menu")
|
(data.onSelected and lib.registerMenu or lib.registerContext)({
|
||||||
|
id = menuID,
|
||||||
|
title = data.header..br..br..(data.headertxt and data.headertxt or ""),
|
||||||
|
position = 'top-right',
|
||||||
|
options = Menu,
|
||||||
|
canClose = data.canClose and data.canClose or nil,
|
||||||
|
onClose = (data.onBack and data.onBack) or (data.onExit and data.onExit) or nil,
|
||||||
|
onExit = data.onExit and data.onExit or nil,
|
||||||
|
onSelected = data.onSelected and (function(selected) index = selected end) or nil,
|
||||||
|
}, (data.onSelected and (function(x, y, args)
|
||||||
|
if Menu[x].refresh then
|
||||||
|
if Menu[x].onSelect then
|
||||||
|
Menu[x].onSelect()
|
||||||
|
end
|
||||||
|
lib.showMenu(menuID, index)
|
||||||
|
else
|
||||||
|
if Menu[x].onSelect then
|
||||||
|
Menu[x].onSelect()
|
||||||
|
else
|
||||||
|
lib.showMenu(menuID, index)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end) or nil))
|
||||||
|
if data.onSelected then
|
||||||
|
lib.showMenu(menuID, 1)
|
||||||
|
else
|
||||||
|
lib.showContext(menuID)
|
||||||
|
end
|
||||||
elseif Config.System.Menu == "qb" then
|
elseif Config.System.Menu == "qb" then
|
||||||
if data.onBack then
|
if data.onBack then
|
||||||
table.insert(Menu, 1, { icon = "fas fa-circle-arrow-left",
|
table.insert(Menu, 1, { icon = "fas fa-circle-arrow-left",
|
||||||
@@ -364,6 +401,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
|
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 --
|
-- Targets --
|
||||||
local targetEntities = {}
|
local targetEntities = {}
|
||||||
function createEntityTarget(entity, opts, dist)
|
function createEntityTarget(entity, opts, dist)
|
||||||
@@ -392,6 +441,14 @@ function createEntityTarget(entity, opts, dist)
|
|||||||
end
|
end
|
||||||
local options = { options = opts, distance = dist }
|
local options = { options = opts, distance = dist }
|
||||||
exports[QBTargetExport]:AddTargetEntity(entity, options)
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -435,6 +492,15 @@ function createBoxTarget(data, opts, dist)
|
|||||||
local target = exports[QBTargetExport]:AddBoxZone(data[1], data[2], data[3], data[4], data[5], options)
|
local target = exports[QBTargetExport]:AddBoxZone(data[1], data[2], data[3], data[4], data[5], options)
|
||||||
boxTargets[#boxTargets+1] = target
|
boxTargets[#boxTargets+1] = target
|
||||||
return 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
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -475,17 +541,52 @@ function createCircleTarget(data, opts, dist)
|
|||||||
|
|
||||||
circleTargets[#circleTargets+1] = target
|
circleTargets[#circleTargets+1] = target
|
||||||
return 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
|
||||||
end
|
end
|
||||||
|
|
||||||
function removeEntityTarget(entity)
|
function removeEntityTarget(entity)
|
||||||
if GetResourceState(QBTargetExport):find("start") then exports[QBTargetExport]:RemoveTargetEntity(entity) end
|
if GetResourceState(QBTargetExport):find("start") then exports[QBTargetExport]:RemoveTargetEntity(entity) end
|
||||||
if GetResourceState(OXTargetExport):find("start") then exports[OXTargetExport]:removeLocalEntity(entity, nil) 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
|
end
|
||||||
|
|
||||||
function removeZoneTarget(target)
|
function removeZoneTarget(target)
|
||||||
if GetResourceState(QBTargetExport):find("start") then exports[QBTargetExport]:RemoveZone(target) end
|
if GetResourceState(QBTargetExport):find("start") then exports[QBTargetExport]:RemoveZone(target) end
|
||||||
if GetResourceState(OXTargetExport):find("start") then exports[OXTargetExport]:removeZone(target, true) 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
|
end
|
||||||
|
|
||||||
AddEventHandler('onResourceStop', function(r)
|
AddEventHandler('onResourceStop', function(r)
|
||||||
@@ -644,6 +745,8 @@ function onPlayerLoaded(func)
|
|||||||
elseif GetResourceState(OXCoreExport):find("start") then
|
elseif GetResourceState(OXCoreExport):find("start") then
|
||||||
if Config.System.Debug then print("^6Bridge^7: ^2Registering ^3onPlayerLoaded^2 with ^7"..OXLibExport) end
|
if Config.System.Debug then print("^6Bridge^7: ^2Registering ^3onPlayerLoaded^2 with ^7"..OXLibExport) end
|
||||||
AddEventHandler('ox:playerLoaded', func)
|
AddEventHandler('ox:playerLoaded', func)
|
||||||
|
else
|
||||||
|
print("^4ERROR^7: ^2No Core detected for onPlayerLoaded ^7- ^2Check ^3exports^1.^2lua^7")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -656,14 +759,13 @@ function createInput(title, opts)
|
|||||||
if opts[i].type == "radio" then
|
if opts[i].type == "radio" then
|
||||||
for k in pairs(opts[i].options) do
|
for k in pairs(opts[i].options) do
|
||||||
opts[i].options[k].label = opts[i].options[k].text
|
opts[i].options[k].label = opts[i].options[k].text
|
||||||
print(opts[i].options[k].text)
|
|
||||||
end
|
end
|
||||||
options[i] = {
|
options[i] = {
|
||||||
type = "select",
|
type = "select",
|
||||||
isRequired = opts[i].isRequired,
|
isRequired = opts[i].isRequired,
|
||||||
label = opts[i].label or opts[i].text,
|
label = opts[i].label or opts[i].text,
|
||||||
name = opts[i].name,
|
name = opts[i].name,
|
||||||
default = opts[i].options[1].value,
|
default = opts[i].default or opts[i].options[1].value,
|
||||||
options = opts[i].options,
|
options = opts[i].options,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@@ -676,6 +778,14 @@ function createInput(title, opts)
|
|||||||
options = opts[i].options,
|
options = opts[i].options,
|
||||||
}
|
}
|
||||||
end
|
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
|
if opts[i].type == "select" then
|
||||||
options[i] = {
|
options[i] = {
|
||||||
type = "select",
|
type = "select",
|
||||||
@@ -829,44 +939,93 @@ 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
|
||||||
if GetResourceState(OXInv):find("start") then
|
if GetResourceState(OXInv):find("start") then
|
||||||
exports[OXInv]:RemoveItem(src, "money", cost)
|
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
|
elseif GetResourceState(QBExport):find("start") then
|
||||||
Core.Functions.GetPlayer(src).Functions.RemoveMoney("cash", cost)
|
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
|
elseif GetResourceState(ESXExport):find("start") then
|
||||||
local Player = ESX.GetPlayerFromId(src)
|
local Player = ESX.GetPlayerFromId(src)
|
||||||
Player.removeMoney(cost, "")
|
Player.removeMoney(cost, "")
|
||||||
|
if Config.System.Debug then print("^6Bridge^7: ^2Charging ^2Player: '^6"..cost.."^7'", type, ESXExport) end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if type == "bank" then
|
if type == "bank" then
|
||||||
if GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then
|
if GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then
|
||||||
Core.Functions.GetPlayer(src).Functions.RemoveMoney("bank", cost)
|
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
|
elseif GetResourceState(ESXExport):find("start") then
|
||||||
local Player = ESX.GetPlayerFromId(src)
|
local Player = ESX.GetPlayerFromId(src)
|
||||||
Player.removeMoney(cost, "")
|
Player.removeMoney(cost, "")
|
||||||
|
if Config.System.Debug then print("^6Bridge^7: ^2Charging ^2Player: '^6"..cost.."^7'", type, ESXExport) end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
@@ -885,8 +1044,9 @@ function createUseableItem(item, funct)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function hasJob(job, src) local hasJob = false
|
function hasJob(job, source, grade) local hasJob, duty = false, true
|
||||||
if src then
|
if source then
|
||||||
|
local src = tonumber(source)
|
||||||
if GetResourceState(ESXExport):find("start") then
|
if GetResourceState(ESXExport):find("start") then
|
||||||
local info = ESX.GetPlayerFromId(src).job
|
local info = ESX.GetPlayerFromId(src).job
|
||||||
while not info do
|
while not info do
|
||||||
@@ -905,14 +1065,39 @@ function hasJob(job, src) 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 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
|
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
|
else
|
||||||
local jobinfo = exports[QBExport]:GetPlayer(src).PlayerData.job
|
print("^4ERROR^7: ^2No Core detected for hasJob ^7- ^2Check ^3exports^1.^2lua^7")
|
||||||
if jobinfo.name == job then hasJob = true end
|
|
||||||
local ganginfo = exports[QBExport]:GetPlayer(src).PlayerData.gang
|
|
||||||
if ganginfo.name == job then hasJob = true end
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if GetResourceState(ESXExport):find("start") then
|
if GetResourceState(ESXExport):find("start") then
|
||||||
@@ -931,26 +1116,40 @@ function hasJob(job, src) 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 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
|
local ganginfo = QBX.PlayerData.gang
|
||||||
if ganginfo.name == job then hasJob = true end
|
if ganginfo.name == job then hasJob = true
|
||||||
else
|
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
|
local info = nil
|
||||||
Core.Functions.GetPlayerData(function(PlayerData)
|
Core.Functions.GetPlayerData(function(PlayerData)
|
||||||
info = PlayerData
|
info = PlayerData
|
||||||
end)
|
end)
|
||||||
local jobinfo = info.job
|
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
|
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
|
||||||
end
|
end
|
||||||
return hasJob
|
return hasJob, duty
|
||||||
end
|
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 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
|
if GetResourceState(ESXExport):find("start") then
|
||||||
local info = ESX.GetPlayerFromId(src)
|
local info = ESX.GetPlayerFromId(src)
|
||||||
Player = {
|
Player = {
|
||||||
@@ -977,15 +1176,26 @@ function getPlayer(src) local Player = {}
|
|||||||
bank = info.Functions.GetMoney("bank"),
|
bank = info.Functions.GetMoney("bank"),
|
||||||
}
|
}
|
||||||
elseif GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then
|
elseif GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then
|
||||||
local info = Core.Functions.GetPlayer(tonumber(src))
|
if Core.Functions.GetPlayer ~= nil then -- support older qb-core functions
|
||||||
Player = {
|
local info = Core.Functions.GetPlayer(src).PlayerData
|
||||||
name = info.PlayerData.charinfo.firstname.." "..info.PlayerData.charinfo.lastname,
|
Player = {
|
||||||
cash = info.PlayerData.money["cash"],
|
name = info.charinfo.firstname.." "..info.charinfo.lastname,
|
||||||
bank = info.PlayerData.money["bank"],
|
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
|
end
|
||||||
else
|
else
|
||||||
if ESX ~= nil then
|
if GetResourceState(ESXExport):find("start") and ESX ~= nil then
|
||||||
local info = ESX.GetPlayerData()
|
local info = ESX.GetPlayerData()
|
||||||
local cash, bank = 0, 0
|
local cash, bank = 0, 0
|
||||||
for k, v in pairs(ESX.GetPlayerData().accounts) do
|
for k, v in pairs(ESX.GetPlayerData().accounts) do
|
||||||
@@ -1011,16 +1221,16 @@ function getPlayer(src) local Player = {}
|
|||||||
cash = info.money["cash"],
|
cash = info.money["cash"],
|
||||||
bank = info.money["bank"],
|
bank = info.money["bank"],
|
||||||
}
|
}
|
||||||
else
|
elseif GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then
|
||||||
local info = nil
|
local info = nil
|
||||||
Core.Functions.GetPlayerData(function(PlayerData)
|
Core.Functions.GetPlayerData(function(PlayerData) info = PlayerData end)
|
||||||
info = PlayerData
|
|
||||||
end)
|
|
||||||
Player = {
|
Player = {
|
||||||
name = info.charinfo.firstname.." "..info.charinfo.lastname,
|
name = info.charinfo.firstname.." "..info.charinfo.lastname,
|
||||||
cash = info.money["cash"],
|
cash = info.money["cash"],
|
||||||
bank = info.money["bank"],
|
bank = info.money["bank"],
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
print("^4ERROR^7: ^2No Core detected for hasJob ^7- ^2Check ^3exports^1.^2lua^7")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return Player
|
return Player
|
||||||
@@ -1040,13 +1250,17 @@ function invImg(item)
|
|||||||
local imgLink = ""
|
local imgLink = ""
|
||||||
if item ~= "" and Items[item] then
|
if item ~= "" and Items[item] then
|
||||||
if GetResourceState(OXInv):find("start") 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
|
elseif GetResourceState(QSInv):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
|
elseif GetResourceState(CoreInv):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
|
elseif GetResourceState(OrigenInv):find("start") then
|
||||||
imgLink = "nui://"..QBInv.."/html/images/"..Items[item].image
|
imgLink = "nui://"..OrigenInv.."/html/img/"..(Items[item].image or "")
|
||||||
|
elseif GetResourceState(QBInv):find("start") then
|
||||||
|
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
|
||||||
end
|
end
|
||||||
return imgLink
|
return imgLink
|
||||||
@@ -1061,4 +1275,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