mirror of
https://github.com/jimathy/jim_bridge.git
synced 2026-08-17 05:56:02 +01:00
Compare commits
40 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
46e3f18edc | ||
|
|
0886d8a4b6 | ||
|
|
6a23e4ac91 | ||
|
|
f7b7718679 | ||
|
|
9ae034da77 | ||
|
|
4d1b2abd3d | ||
|
|
f8e3f64907 | ||
|
|
3702835958 | ||
|
|
23c2e1472e | ||
|
|
6367c9ed3b | ||
|
|
2d299a6a4a | ||
|
|
ced629d4dc | ||
|
|
714121d272 | ||
|
|
14c140cf85 | ||
|
|
881aec7c04 | ||
|
|
85b31e7e1d | ||
|
|
66c9287202 | ||
|
|
f0f59b8568 | ||
|
|
e03efa6687 | ||
|
|
5a22651961 | ||
|
|
236689452e | ||
|
|
b686f267e1 | ||
|
|
096e323409 | ||
|
|
b71ec14615 | ||
|
|
5a2304b785 | ||
|
|
6f413c555d | ||
|
|
fbc92aea41 | ||
|
|
7b31343991 | ||
|
|
872cb39715 | ||
|
|
dd35674307 | ||
|
|
1d102e94b4 | ||
|
|
c18932443a | ||
|
|
7563b4abdf | ||
|
|
20509e5cc2 | ||
|
|
43e30e95bc | ||
|
|
9efff1060b | ||
|
|
3b608e2b4f | ||
|
|
bfed10c019 | ||
|
|
4bb29b8f14 | ||
|
|
6eca0dd1d1 |
373
crafting.lua
373
crafting.lua
@@ -6,75 +6,82 @@ 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
|
||||||
function craftingMenu(data) local hasjob = false
|
function craftingMenu(data)
|
||||||
if CraftLock then return end
|
if CraftLock then return end
|
||||||
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
|
||||||
|
local tempCarryTable = {}
|
||||||
for i = 1, #Recipes do
|
for i = 1, #Recipes do
|
||||||
for k, v in pairs(Recipes[i]) do
|
for k in pairs(Recipes[i]) do
|
||||||
|
if k ~= "amount" and k ~= "job" and k ~= "gang" then
|
||||||
|
tempCarryTable[k] = Recipes[i].amount or 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local canCarryTable = triggerCallback(GetCurrentResourceName()..':server:canCarry', tempCarryTable)
|
||||||
|
for i = 1, #Recipes 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 not Recipes[i]["amount"] then Recipes[i]["amount"] = 1 end
|
if Recipes[i].job then
|
||||||
if Recipes[i].job then hasjob = false
|
|
||||||
for l, b in pairs(Recipes[i].job) do
|
for l, b in pairs(Recipes[i].job) do
|
||||||
hasjob = hasJob(l, nil, b)
|
hasjob = hasJob(l, nil, b)
|
||||||
if hasjob == true then break end
|
if hasjob == true then break end
|
||||||
end
|
end
|
||||||
end
|
else hasjob = true end
|
||||||
local setheader, settext = "", ""
|
local setheader, settext, disable = "", "", false
|
||||||
local disable = false
|
if hasjob then
|
||||||
if Recipes[i].job and hasjob == false then else
|
|
||||||
local itemTable = {}
|
local itemTable = {}
|
||||||
for l, b in pairs(Recipes[i][tostring(k)]) do
|
for l, b in pairs(Recipes[i][tostring(k)]) do
|
||||||
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] and Items[l].label or "error - "..l)..(b > 1 and " x"..b or "")
|
||||||
itemTable[l] = b
|
itemTable[l] = b
|
||||||
Wait(0)
|
Wait(0)
|
||||||
end
|
end
|
||||||
|
while not canCarryTable do Wait(0) end
|
||||||
if Config.System.Debug then print("^6Bridge^7: ^2Checking"..(data.stashName and " ^7'^6"..data.stashName.."^7'" or "").." ^2ingredients^7 - ^6"..k.."^7") end
|
if Config.System.Debug then print("^6Bridge^7: ^2Checking"..(data.stashName and " ^7'^6"..data.stashName.."^7'" or "").." ^2ingredients^7 - ^6"..k.."^7") end
|
||||||
if data.stashName then disable = not stashhasItem(stashItems, itemTable)
|
if data.stashName then disable = not stashhasItem(stashItems, itemTable)
|
||||||
else disable = not hasItem(itemTable) end
|
else disable = not hasItem(itemTable) end
|
||||||
|
setheader = (Items[tostring(k)] and Items[tostring(k)].label or "error - " .. tostring(k)) .. (Recipes[i]["amount"] > 1 and " x" .. Recipes[i]["amount"] or "")
|
||||||
setheader = Items[tostring(k)].label..(Recipes[i]["amount"] > 1 and " x"..Recipes[i]["amount"] or "")..(not disable and " ✔️" or "")
|
if not disable then
|
||||||
|
if not canCarryTable[k] then setheader = setheader .. " 📦"
|
||||||
|
else setheader = setheader .. " ✔️" end
|
||||||
|
elseif not canCarryTable[k] then setheader = setheader .. " 📦" end
|
||||||
Menu[#Menu + 1] = {
|
Menu[#Menu + 1] = {
|
||||||
isMenuHeader = disable,
|
isMenuHeader = disable or not canCarryTable[k],
|
||||||
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, })
|
||||||
@@ -118,26 +125,18 @@ 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 and Loc[Config.Lan].progressbar["progress_make"]) or "Making a"
|
||||||
local crafted = true
|
local animDict = data.craftable.Anims and data.craftable.Anims.animDict or "amb@prop_human_parking_meter@male@idle_a"
|
||||||
local crafting = true
|
local anim = data.craftable.Anims and data.craftable.Anims.anim or "idle_a"
|
||||||
|
local amount = data.amount and (data.amount ~= 1) and data.amount or 1
|
||||||
local cam = createTempCam(PlayerPedId(), data.coords)
|
|
||||||
startTempCam(cam)
|
|
||||||
|
|
||||||
|
local crafted, crafting = true, true
|
||||||
|
local cam = createTempCam(PlayerPedId(), data.coords)
|
||||||
|
startTempCam(cam)
|
||||||
for i = 1, amount do
|
for i = 1, amount do
|
||||||
for k, v in pairs(data.craft) do
|
for k, v in pairs(data.craft) do
|
||||||
if k ~= "amount" and k ~= "job" then
|
if k ~= "amount" and k ~= "job" then
|
||||||
@@ -154,9 +153,8 @@ function makeItem(data)
|
|||||||
}) then
|
}) then
|
||||||
--TriggerEvent('inventory:client:ItemBox', Items[l], "use", b) -- Show item box for each item
|
--TriggerEvent('inventory:client:ItemBox', Items[l], "use", b) -- Show item box for each item
|
||||||
else
|
else
|
||||||
crafted = false
|
crafted, crafting = false, false
|
||||||
crafting = false
|
break
|
||||||
break
|
|
||||||
end
|
end
|
||||||
Wait(200)
|
Wait(200)
|
||||||
end
|
end
|
||||||
@@ -189,32 +187,101 @@ 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]]--
|
||||||
|
function sellMenu(data)
|
||||||
|
local origData = data
|
||||||
|
local Menu = {}
|
||||||
|
if data.sellTable.Items then
|
||||||
|
local itemList = {}
|
||||||
|
for k, v in pairs(data.sellTable.Items) do itemList[k] = 1 end
|
||||||
|
local hasitems, hasTable = hasItem(itemList)
|
||||||
|
for k, v in pairsByKeys(data.sellTable.Items) do
|
||||||
|
Menu[#Menu +1] = {
|
||||||
|
isMenuHeader = not hasTable[k].hasItem,
|
||||||
|
icon = invImg(k),
|
||||||
|
header = Items[k].label.. (hasTable[k].hasItem and "💰 (x"..hasTable[k].count..")" or ""),
|
||||||
|
txt = Loc[Config.Lan].info["sell_all"].." "..v.." "..Loc[Config.Lan].info["sell_each"],
|
||||||
|
onSelect = function()
|
||||||
|
sellAnim({ item = k, price = v, ped = data.ped, onBack = function() sellMenu(data) end })
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
else
|
||||||
|
for k, v in pairsByKeys(data.sellTable) do
|
||||||
|
if type(v) == "table" then
|
||||||
|
Menu[#Menu +1] = {
|
||||||
|
arrow = true,
|
||||||
|
header = k,
|
||||||
|
txt = "Amount of items: "..countTable(v.Items),
|
||||||
|
onSelect = function()
|
||||||
|
v.onBack = function() sellMenu(origData) end
|
||||||
|
v.sellTable = data.sellTable[k]
|
||||||
|
sellMenu(v)
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
openMenu(Menu, { header = data.sellTable.Header or "Amount of items: "..countTable(data.sellTable.Items), canClose = true, onBack = data.onBack })
|
||||||
|
end
|
||||||
|
|
||||||
|
function sellAnim(data)
|
||||||
|
if not hasItem(data.item, 1) then
|
||||||
|
triggerNotify(nil, Loc[Config.Lan].error["dont_have"].." "..Items[data.item].label, "error")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
for k, v in pairs(GetGamePool('CObject')) do
|
||||||
|
for _, model in pairs({`p_cs_clipboard`}) do
|
||||||
|
if GetEntityModel(v) == model then
|
||||||
|
if IsEntityAttachedToEntity(data.ped, v) then
|
||||||
|
DeleteObject(v) DetachEntity(v, 0, 0) SetEntityAsMissionEntity(v, true, true)
|
||||||
|
Wait(100) DeleteEntity(v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
TriggerServerEvent(GetCurrentResourceName().."Sellitems", data) -- Had to slip in the sell command during the animation command
|
||||||
|
lookEnt(data.ped)
|
||||||
|
local dict = "mp_common"
|
||||||
|
playAnim(dict, "givetake2_a", 0.3, 2)
|
||||||
|
playAnim(dict, "givetake2_b", 0.3, 2, data.ped)
|
||||||
|
Wait(2000)
|
||||||
|
StopAnimTask(PlayerPedId(), dict, "givetake2_a", 0.5)
|
||||||
|
StopAnimTask(data.ped, dict, "givetake2_b", 0.5)
|
||||||
|
if data.onBack then data.onBack() end
|
||||||
|
end
|
||||||
|
|
||||||
|
RegisterNetEvent(GetCurrentResourceName().."Sellitems", function(data)
|
||||||
|
local src = source
|
||||||
|
local hasItems, hasTable = hasItem(data.item, 1, src)
|
||||||
|
if hasItems then
|
||||||
|
TriggerEvent(GetCurrentResourceName()..":server:toggleItem", false, data.item, hasTable[data.item].count, src)
|
||||||
|
TriggerEvent(GetCurrentResourceName()..":server:FundPlayer", (hasTable[data.item].count * data.price), "cash", src)
|
||||||
|
else
|
||||||
|
triggerNotify(nil,Loc[Config.Lan].error["dont_have"].." "..Items[data.item].label, "error", src)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
function openShop(data)
|
function openShop(data)
|
||||||
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
|
||||||
if GetResourceState(OXInv):find("start") then
|
if GetResourceState(OXInv):find("start") then
|
||||||
@@ -232,23 +299,18 @@ function hasItem(items, amount, src) local amount = amount and amount or 1
|
|||||||
if type(items) ~= "table" then items = { [items] = amount and amount or 1, } end
|
if type(items) ~= "table" then items = { [items] = amount and amount or 1, } end
|
||||||
if GetResourceState(OXInv):find("start") then
|
if GetResourceState(OXInv):find("start") then
|
||||||
foundInv = OXInv
|
foundInv = OXInv
|
||||||
if src then grabInv = exports.ox_inventory:GetInventoryItems(src)
|
if src then grabInv = exports[OXInv]:GetInventoryItems(src)
|
||||||
else grabInv = exports[OXInv]:GetPlayerItems()
|
else grabInv = exports[OXInv]:GetPlayerItems() end
|
||||||
end
|
|
||||||
|
|
||||||
elseif GetResourceState(QSInv):find("start") then
|
elseif GetResourceState(QSInv):find("start") then
|
||||||
foundInv = QSInv
|
foundInv = QSInv
|
||||||
if src then grabInv = exports[QSInv]:GetInventory(src)
|
if src then grabInv = exports[QSInv]:GetInventory(src)
|
||||||
else grabInv = exports[QSInv]:getUserInventory()
|
else grabInv = exports[QSInv]:getUserInventory() end
|
||||||
end
|
|
||||||
|
|
||||||
elseif GetResourceState(OrigenInv):find("start") then
|
elseif GetResourceState(OrigenInv):find("start") then
|
||||||
foundInv = OrigenInv
|
foundInv = OrigenInv
|
||||||
if src then
|
if src then grabInv = exports[OrigenInv]:GetInventory(src)
|
||||||
grabInv = exports[OrigenInv]:getPlayerInventory(src)
|
else grabInv = exports[OrigenInv]:getPlayerInventory() end
|
||||||
else
|
|
||||||
grabInv = exports[OrigenInv]:getPlayerInventory()
|
|
||||||
end
|
|
||||||
|
|
||||||
elseif GetResourceState(CoreInv):find("start") then
|
elseif GetResourceState(CoreInv):find("start") then
|
||||||
foundInv = CoreInv
|
foundInv = CoreInv
|
||||||
@@ -269,15 +331,11 @@ function hasItem(items, amount, src) local amount = amount and amount or 1
|
|||||||
|
|
||||||
elseif GetResourceState(CodeMInv):find("start") then
|
elseif GetResourceState(CodeMInv):find("start") then
|
||||||
foundInv = CodeMInv
|
foundInv = CodeMInv
|
||||||
if src then grabInv = exports[CodeMInv]:GetUserInventory(src)
|
grabInv = src and exports[CodeMInv]:GetUserInventory(src) or exports[CodeMInv]:GetClientPlayerInventory()
|
||||||
else grabInv = exports[CodeMInv]:GetClientPlayerInventory()
|
|
||||||
end
|
|
||||||
|
|
||||||
elseif GetResourceState(QBInv):find("start") then
|
elseif GetResourceState(QBInv):find("start") then
|
||||||
foundInv = QBInv
|
foundInv = QBInv
|
||||||
if src then grabInv = Core.Functions.GetPlayer(src).PlayerData.items
|
grabInv = src and Core.Functions.GetPlayer(src).PlayerData.items or Core.Functions.GetPlayerData().items
|
||||||
else grabInv = Core.Functions.GetPlayerData().items
|
|
||||||
end
|
|
||||||
|
|
||||||
else
|
else
|
||||||
print("^4ERROR^7: ^2No Inventory detected ^7- ^2Check ^3exports^1.^2lua^7")
|
print("^4ERROR^7: ^2No Inventory detected ^7- ^2Check ^3exports^1.^2lua^7")
|
||||||
@@ -289,20 +347,15 @@ function hasItem(items, amount, src) local amount = amount and amount or 1
|
|||||||
if not Items[item] then print("^4ERROR^7: ^2Script can't find ingredient item in Shared Items - ^1"..item.."^7") end
|
if not Items[item] then print("^4ERROR^7: ^2Script can't find ingredient item in Shared Items - ^1"..item.."^7") end
|
||||||
local count = 0
|
local count = 0
|
||||||
for _, itemData in pairs(grabInv) do
|
for _, itemData in pairs(grabInv) do
|
||||||
if itemData and (itemData.name == item) then
|
if itemData and (itemData.name == item) then count += (itemData.count or itemData.amount or 1) end
|
||||||
--if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7: ^2Item^7: '^3"..tostring(item).."^7' ^2Slot^7: ^3"..itemData.slot.." ^7x(^3"..tostring(itemData.count or itemData.amount).."^7)", foundInv) end
|
|
||||||
count += ((itemData.count or itemData.amount) or 1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if count >= amount then
|
|
||||||
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7[^6"..foundInv.."^7]: "..tostring(item).." ^3"..count.."^7/^3"..amount.." ^5FOUND^7") end
|
|
||||||
hasTable[item] = { hasItem = true, count = count, }
|
|
||||||
else
|
|
||||||
if Config.System.Debug then print("^6Bridge^7: ^3HasItem^7[^6"..foundInv.."^7]: "..tostring(item).." ^1"..count.."^7/^3"..amount.." ^1NOT FOUND^7") end
|
|
||||||
hasTable[item] = { hasItem = false, count = count, }
|
|
||||||
end
|
end
|
||||||
|
foundInv = foundInv:gsub("%-", "^7-^6"):gsub("%_", "^7_^6")
|
||||||
|
local foundMessage = "^6Bridge^7: ^3hasItem^7[^6"..foundInv.."^7]: "..tostring(item).." ^3"..count.."^7/^3"..amount
|
||||||
|
if count >= amount then foundMessage = foundMessage.." ^5FOUND^7" else foundMessage = foundMessage .." ^1NOT FOUND^7" end
|
||||||
|
if Config.System.Debug then print(foundMessage) end
|
||||||
|
hasTable[item] = { hasItem = count >= amount, count = count }
|
||||||
end
|
end
|
||||||
for k, v in pairs(hasTable) do if v.hasItem == false then return false, hasTable end end
|
for k, v in pairs(hasTable) do if not v.hasItem then return false, hasTable end end
|
||||||
return true, hasTable
|
return true, hasTable
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -336,18 +389,20 @@ function getStash(stashName) local stashResource = ""
|
|||||||
stashItems = exports[CodeMInv]:GetInventoryItems('Stash', stashName)
|
stashItems = exports[CodeMInv]:GetInventoryItems('Stash', stashName)
|
||||||
|
|
||||||
elseif GetResourceState(OrigenInv):find("start") then stashResource = OrigenInv
|
elseif GetResourceState(OrigenInv):find("start") then stashResource = OrigenInv
|
||||||
stashItems = exports[OrigenInv]:GetStash(stashName)
|
stashItems = exports[OrigenInv]:GetStashItems(stashName)
|
||||||
|
|
||||||
elseif GetResourceState(QBInv):find("start") then stashResource = QBInv
|
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 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[#items+1] = {
|
local indexNum = #items+1 -- Added to help recreate missing slot numbers
|
||||||
|
items[(item.slot and item.slot) or indexNum] = {
|
||||||
name = itemInfo.name or nil,
|
name = itemInfo.name or nil,
|
||||||
amount = tonumber(item.amount) or tonumber(item.count),
|
amount = tonumber(item.amount) or tonumber(item.count),
|
||||||
info = item.info or "",
|
info = item.info or "",
|
||||||
@@ -358,7 +413,7 @@ function getStash(stashName) local stashResource = ""
|
|||||||
unique = itemInfo.unique or nil,
|
unique = itemInfo.unique or nil,
|
||||||
useable = itemInfo.useable or nil,
|
useable = itemInfo.useable or nil,
|
||||||
image = itemInfo.image or nil,
|
image = itemInfo.image or nil,
|
||||||
slot = itemInfo.slot or nil,
|
slot = (item.slot and item.slot) or indexNum,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -373,6 +428,7 @@ 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 k, v in pairs(items) do
|
||||||
for l in pairs(stashItems) do
|
for l in pairs(stashItems) do
|
||||||
@@ -422,7 +478,7 @@ function stashRemoveItem(stashItems, stashName, items) local amount = amount and
|
|||||||
|
|
||||||
elseif GetResourceState(OrigenInv):find("start") then
|
elseif GetResourceState(OrigenInv):find("start") then
|
||||||
for k, v in pairs(items) do
|
for k, v in pairs(items) do
|
||||||
exports[OrigenInv]:RemoveItem(stashName, k, v)
|
exports[OrigenInv]:RemoveFromStash(stashName, nil, k, v)
|
||||||
if Config.System.Debug then print("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..OrigenInv, k, v) end
|
if Config.System.Debug then print("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..OrigenInv, k, v) end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -455,7 +511,15 @@ end
|
|||||||
RegisterNetEvent(GetCurrentResourceName()..":server:stashRemoveItem", stashRemoveItem)
|
RegisterNetEvent(GetCurrentResourceName()..":server:stashRemoveItem", stashRemoveItem)
|
||||||
|
|
||||||
function stashhasItem(stashItems, items, amount)
|
function stashhasItem(stashItems, items, amount)
|
||||||
|
local invs = {OXInv, QSInv, CoreInv, CodeMInv, OrigenInv, QBInv}
|
||||||
local foundInv = ""
|
local foundInv = ""
|
||||||
|
for _, inv in ipairs(invs) do
|
||||||
|
if GetResourceState(inv):find("start") then
|
||||||
|
foundInv = inv:gsub("%-", "^7-^6"):gsub("%_", "^7_^6")
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if type(items) ~= "table" then items = { [items] = amount and amount or 1, } end
|
if type(items) ~= "table" then items = { [items] = amount and amount or 1, } end
|
||||||
local hasTable = {}
|
local hasTable = {}
|
||||||
for item, amount in pairs(items) do
|
for item, amount in pairs(items) do
|
||||||
@@ -465,14 +529,105 @@ function stashhasItem(stashItems, items, amount)
|
|||||||
count += (itemData.amount or 1)
|
count += (itemData.amount or 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if count >= amount then
|
|
||||||
if Config.System.Debug then print("^6Bridge^7: ^3stashHasItem^7: ^5FOUND '"..item.."' ^3"..count.."^7/^3"..amount.."^7") end
|
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)
|
||||||
hasTable[item] = { hasItem = true, count = count, }
|
if Config.System.Debug then print(debugMsg) end
|
||||||
else
|
|
||||||
if Config.System.Debug then print("^6Bridge^7: ^3stashHasItem^7: ^1NOT FOUND^7 '"..item.."' ^1"..count.."^7/^3"..amount.."^7") end
|
hasTable[item] = { hasItem = (count >= amount), count = count }
|
||||||
hasTable[item] = { hasItem = false, count = count, }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
for k, v in pairs(hasTable) do if v.hasItem == false then return false, hasTable end end
|
for k, v in pairs(hasTable) do if v.hasItem == false then return false, hasTable end end
|
||||||
return true, hasTable
|
return true, hasTable
|
||||||
|
end
|
||||||
|
|
||||||
|
if IsDuplicityVersion() then
|
||||||
|
if GetResourceState(OXLibExport):find("start") then
|
||||||
|
createCallback(GetCurrentResourceName()..':server:canCarry', function(source, itemTable) local result = canCarry(itemTable, source) return result end)
|
||||||
|
else
|
||||||
|
createCallback(GetCurrentResourceName()..':server:canCarry', function(source, cb, itemTable) local result = canCarry(itemTable, source) cb(result) end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function canCarry(itemTable, src)
|
||||||
|
local resultTable = {}
|
||||||
|
if src then
|
||||||
|
if GetResourceState(OXInv):find("start") then
|
||||||
|
for k, v in pairs(itemTable) do
|
||||||
|
resultTable[k] = exports[OXInv]:CanCarryItem(src, k, v)
|
||||||
|
end
|
||||||
|
|
||||||
|
elseif GetResourceState(QSInv):find("start") then
|
||||||
|
for k, v in pairs(itemTable) do
|
||||||
|
resultTable[k] = exports[OXInv]:CanCarryItem(src, k, v)
|
||||||
|
end
|
||||||
|
|
||||||
|
elseif GetResourceState(CoreInv):find("start") then
|
||||||
|
--??
|
||||||
|
|
||||||
|
elseif GetResourceState(CodeMInv):find("start") then
|
||||||
|
for k, v in pairs(itemTable) do
|
||||||
|
local weight = Items[k].weight
|
||||||
|
resultTable[k] = exports[CodeMInv]:CanCarryItem(src, weight, v)
|
||||||
|
end
|
||||||
|
|
||||||
|
elseif GetResourceState(OrigenInv):find("start") then
|
||||||
|
for k, v in pairs(itemTable) do
|
||||||
|
resultTable[k] = exports[OrigenInv]:canCarryItem(src, k, v)
|
||||||
|
end
|
||||||
|
|
||||||
|
elseif GetResourceState(QBInv):find("start") then
|
||||||
|
local Player = Core.Functions.GetPlayer(src)
|
||||||
|
local items = Player.PlayerData.items
|
||||||
|
local weight, totalWeight = 0, 0
|
||||||
|
if not items then return false end
|
||||||
|
for _, item in pairs(items) do weight += item.weight * item.amount end
|
||||||
|
totalWeight = tonumber(weight)
|
||||||
|
|
||||||
|
for k, v in pairs(itemTable) do
|
||||||
|
local itemInfo = Items[k]
|
||||||
|
if not itemInfo and not Player.Offline then
|
||||||
|
triggerNotify(nil, 'Item does not exist', 'error', src)
|
||||||
|
resultTable[k] = true
|
||||||
|
else
|
||||||
|
resultTable[k] = (totalWeight + (Items[k]['weight'] * v)) <= 120000
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return resultTable
|
||||||
|
end
|
||||||
|
|
||||||
|
function getRandomReward(itemName) -- intended for job scripts
|
||||||
|
if Config.Rewards.RewardPool then
|
||||||
|
local reward = false
|
||||||
|
if type(Config.Rewards.RewardItem) == "string" then Config.Rewards.RewardItem = { Config.Rewards.RewardItem } end
|
||||||
|
for k, v in pairs(Config.Rewards.RewardItem) do
|
||||||
|
if v == itemName then reward = true break end
|
||||||
|
end
|
||||||
|
if reward then
|
||||||
|
removeItem(itemName, 1)
|
||||||
|
local totalRarity = 0
|
||||||
|
for i=1, #Config.Rewards.RewardPool do
|
||||||
|
totalRarity += Config.Rewards.RewardPool[i].rarity
|
||||||
|
end
|
||||||
|
if Config.System.Debug then
|
||||||
|
print("^6Bridge^7: ^3getRandomReward^7: ^2Total Rarity ^7'^6"..totalRarity.."^7'")
|
||||||
|
end
|
||||||
|
|
||||||
|
local randomNum = math.random(1, totalRarity)
|
||||||
|
if Config.System.Debug then
|
||||||
|
print("^6Bridge^7: ^3getRandomReward^7: ^2Random Number ^7'^6"..randomNum.."^7'")
|
||||||
|
end
|
||||||
|
local currentRarity = 0
|
||||||
|
for i=1, #Config.Rewards.RewardPool do
|
||||||
|
currentRarity += Config.Rewards.RewardPool[i].rarity
|
||||||
|
if randomNum <= currentRarity then
|
||||||
|
if Config.System.Debug then
|
||||||
|
print("^6Bridge^7: ^3getRandomReward^7: ^2Selected toy ^7'^6"..Config.Rewards.RewardPool[i].item.."^7'")
|
||||||
|
end
|
||||||
|
addItem(Config.Rewards.RewardPool[i].item, 1)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
115
functions.lua
115
functions.lua
@@ -8,20 +8,46 @@ function jobCheck(job)
|
|||||||
return canDo
|
return canDo
|
||||||
end
|
end
|
||||||
|
|
||||||
local time = 100
|
local time = 500
|
||||||
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 IsModelValid(model) then print("^6Bridge^7: ^1ERROR^7: ^2Model^7 - '^6"..model.."^7' ^2does not exist in server") return
|
||||||
while not HasModelLoaded(model) do if time > 0 then time -= 1 RequestModel(model)
|
else
|
||||||
else time = 1000 print("^6Bridge^7: ^3LoadModel^7: ^2Timed out loading model ^7'^6"..model.."^7'") break end
|
if not HasModelLoaded(model) then
|
||||||
Wait(10) end
|
if Config.System.Debug then print("^6Bridge^7: ^2Loading Model^7: '^6"..model.."^7'") end
|
||||||
|
while not HasModelLoaded(model) and time > 0 do time -= 1 RequestModel(model) Wait(0) end
|
||||||
|
if not HasModelLoaded(model) then print("^6Bridge^7: ^3LoadModel^7: ^2Timed out loading model ^7'^6"..model.."^7'") end
|
||||||
|
end
|
||||||
|
time = 500
|
||||||
|
end
|
||||||
|
end
|
||||||
|
function unloadModel(model) if Config.System.Debug then print("^6Bridge^7: ^2Removing Model from memory cache^7: '^6"..model.."^7'") end SetModelAsNoLongerNeeded(model) end
|
||||||
|
|
||||||
|
function loadAnimDict(animDict)
|
||||||
|
if not DoesAnimDictExist(animDict) then print("^6Bridge^7: ^1ERROR^7: ^2Anim Dictionary^7 - '^6"..animDict.."^7' ^2does not exist in server") return
|
||||||
|
else
|
||||||
|
if Config.System.Debug then print("^6Bridge^7: ^2Loading Anim Dictionary^7: '^6"..animDict.."^7'") end
|
||||||
|
while not HasAnimDictLoaded(animDict) do RequestAnimDict(animDict) Wait(5) end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
function unloadAnimDict(animDict) if Config.System.Debug then print("^6Bridge^7: ^2Removing Anim Dictionary from memory cache^7: '^6"..animDict.."^7'") end RemoveAnimDict(animDict) end
|
||||||
|
|
||||||
|
function loadPtfxDict(ptFxName)
|
||||||
|
if not HasNamedPtfxAssetLoaded(ptFxName) then
|
||||||
|
if Config.System.Debug then
|
||||||
|
print("^6Bridge^7: ^2Loading Ptfx Dictionary^7: '^6"..ptFxName.."^7'")
|
||||||
|
end
|
||||||
|
while not HasNamedPtfxAssetLoaded(ptFxName) do RequestNamedPtfxAsset(ptFxName) Wait(5) end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function unloadModel(model) if Config.System.Debug then print("^6Bridge^7: ^2Removing Model^7: '^6"..model.."^7'") end SetModelAsNoLongerNeeded(model) end
|
|
||||||
function loadAnimDict(dict) if Config.System.Debug then print("^6Bridge^7: ^2Loading Anim Dictionary^7: '^6"..dict.."^7'") end while not HasAnimDictLoaded(dict) do RequestAnimDict(dict) Wait(5) end end
|
|
||||||
function unloadAnimDict(dict) if Config.System.Debug then print("^6Bridge^7: ^2Removing Anim Dictionary^7: '^6"..dict.."^7'") end RemoveAnimDict(dict) end
|
|
||||||
function loadPtfxDict(dict) if Config.System.Debug then if not HasNamedPtfxAssetLoaded(dict) then print("^6Bridge^7: ^2Loading Ptfx Dictionary^7: '^6"..dict.."^7'") end end while not HasNamedPtfxAssetLoaded(dict) do RequestNamedPtfxAsset(dict) Wait(5) end end
|
|
||||||
function unloadPtfxDict(dict) if Config.System.Debug then print("^6Bridge^7: ^2Removing Ptfx Dictionary^7: '^6"..dict.."^7'") end RemoveNamedPtfxAsset(dict) end
|
function unloadPtfxDict(dict) if Config.System.Debug then print("^6Bridge^7: ^2Removing Ptfx Dictionary^7: '^6"..dict.."^7'") end RemoveNamedPtfxAsset(dict) end
|
||||||
function loadTextureDict(dict) if Config.System.Debug then print("^6Bridge^7: ^2Loading Texture Dictionary^7: '^6"..dict.."^7'") end while not HasStreamedTextureDictLoaded(dict) do RequestNamedPtfxAsset(dict) Wait(5) end end
|
function loadTextureDict(dict)
|
||||||
|
if not HasStreamedTextureDictLoaded(dict) then
|
||||||
|
if Config.System.Debug then
|
||||||
|
print("^6Bridge^7: ^2Loading Texture Dictionary^7: '^6"..dict.."^7'")
|
||||||
|
end
|
||||||
|
while not HasStreamedTextureDictLoaded(dict) do RequestNamedPtfxAsset(dict) Wait(5) end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function countTable(table) local i = 0 for keys in pairs(table) do i += 1 end return i end
|
function countTable(table) local i = 0 for keys in pairs(table) do i += 1 end return i end
|
||||||
|
|
||||||
@@ -32,8 +58,9 @@ function playAnim(animDict, animName, duration, flag, ped)
|
|||||||
TaskPlayAnim(ped and ped or PlayerPedId(), animDict, animName, 8.0, -8.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, ped)
|
||||||
StopAnimTask(PlayerPedId(), animName, animDict)
|
StopAnimTask(ped or PlayerPedId(), animDict, animName, 0.5)
|
||||||
|
StopAnimTask(ped or PlayerPedId(), animName, animDict, 0.5)
|
||||||
unloadAnimDict(animDict)
|
unloadAnimDict(animDict)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -60,7 +87,7 @@ local Peds = {}
|
|||||||
local Props = {}
|
local Props = {}
|
||||||
function makePed(model, coords, freeze, collision, scenario, anim, synced)
|
function makePed(model, coords, freeze, collision, scenario, anim, synced)
|
||||||
loadModel(model)
|
loadModel(model)
|
||||||
local ped = CreatePed(0, model, coords.x, coords.y, coords.z-1.03, coords.w, synced and synced or true, false)
|
local ped = CreatePed(0, model, coords.x, coords.y, coords.z-1.03, coords.w, synced or true, false)
|
||||||
SetEntityInvincible(ped, true)
|
SetEntityInvincible(ped, true)
|
||||||
SetBlockingOfNonTemporaryEvents(ped, true)
|
SetBlockingOfNonTemporaryEvents(ped, true)
|
||||||
FreezeEntityPosition(ped, freeze and freeze or true)
|
FreezeEntityPosition(ped, freeze and freeze or true)
|
||||||
@@ -82,7 +109,7 @@ end
|
|||||||
|
|
||||||
function makeProp(data, freeze, synced)
|
function makeProp(data, freeze, synced)
|
||||||
loadModel(data.prop)
|
loadModel(data.prop)
|
||||||
local prop = CreateObject(data.prop, data.coords.x, data.coords.y, data.coords.z-1.03, synced or false, synced or false, false)
|
local prop = CreateObject(data.prop, data.coords.x, data.coords.y, data.coords.z-1.03, freeze or false, synced or false, false)
|
||||||
SetEntityHeading(prop, data.coords.w + 180.0)
|
SetEntityHeading(prop, data.coords.w + 180.0)
|
||||||
FreezeEntityPosition(prop, freeze and freeze or 0)
|
FreezeEntityPosition(prop, freeze and freeze or 0)
|
||||||
if Config.System.Debug then
|
if Config.System.Debug then
|
||||||
@@ -202,8 +229,9 @@ function ensureNetToVeh(vehNetID)
|
|||||||
return vehicle
|
return vehicle
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local previewTxd = CreateRuntimeTxd(GetCurrentResourceName()..'previewTxd')
|
||||||
function makeBlip(data)
|
function makeBlip(data)
|
||||||
local blip = AddBlipForCoord(data.coords)
|
local blip = AddBlipForCoord(vec3(data.coords.x, data.coords.y, data.coords.z))
|
||||||
SetBlipAsShortRange(blip, true)
|
SetBlipAsShortRange(blip, true)
|
||||||
SetBlipSprite(blip, data.sprite or 106)
|
SetBlipSprite(blip, data.sprite or 106)
|
||||||
SetBlipColour(blip, data.col or 5)
|
SetBlipColour(blip, data.col or 5)
|
||||||
@@ -213,8 +241,23 @@ function makeBlip(data)
|
|||||||
BeginTextCommandSetBlipName('STRING')
|
BeginTextCommandSetBlipName('STRING')
|
||||||
AddTextComponentString(tostring(data.name))
|
AddTextComponentString(tostring(data.name))
|
||||||
EndTextCommandSetBlipName(blip)
|
EndTextCommandSetBlipName(blip)
|
||||||
|
if GetResourceState("blip_info"):find("start") or GetResourceState("blip-info"):find("start") or GetResourceState("blipinfo"):find("start") then
|
||||||
|
if data.preview then
|
||||||
|
local txname = tostring('preview'..keyGen()..keyGen())
|
||||||
|
if data.preview:find("http") then
|
||||||
|
local newTxt = CreateDui(data.preview, 512, 256)
|
||||||
|
local duihandle = GetDuiHandle(newTxt)
|
||||||
|
while not GetDuiHandle(newTxt) do Wait(0) end
|
||||||
|
CreateRuntimeTextureFromDuiHandle(previewTxd, txname, duihandle)
|
||||||
|
else
|
||||||
|
CreateRuntimeTextureFromImage(previewTxd, txname, data.preview)
|
||||||
|
end
|
||||||
|
exports["blip_info"]:SetBlipInfoImage(blip, GetCurrentResourceName()..'previewTxd', txname)
|
||||||
|
exports["blip_info"]:SetBlipInfoTitle(blip, data.name, false)
|
||||||
|
end
|
||||||
|
end
|
||||||
if Config.System.Debug then print("^6Bridge^7: ^6Blip ^2created for location^7: '^6"..data.name.."^7'") end
|
if Config.System.Debug then print("^6Bridge^7: ^6Blip ^2created for location^7: '^6"..data.name.."^7'") end
|
||||||
return blip
|
return blip
|
||||||
end
|
end
|
||||||
|
|
||||||
function makeEntityBlip(data)
|
function makeEntityBlip(data)
|
||||||
@@ -229,6 +272,21 @@ function makeEntityBlip(data)
|
|||||||
BeginTextCommandSetBlipName('STRING')
|
BeginTextCommandSetBlipName('STRING')
|
||||||
AddTextComponentString(tostring(data.name))
|
AddTextComponentString(tostring(data.name))
|
||||||
EndTextCommandSetBlipName(blip)
|
EndTextCommandSetBlipName(blip)
|
||||||
|
if GetResourceState("blip_info"):find("start") or GetResourceState("blip-info"):find("start") or GetResourceState("blipinfo"):find("start") then
|
||||||
|
if data.preview then
|
||||||
|
local txname = tostring('preview'..keyGen()..keyGen())
|
||||||
|
if data.preview:find("http") then
|
||||||
|
local newTxt = CreateDui(data.preview, 512, 256)
|
||||||
|
local duihandle = GetDuiHandle(newTxt)
|
||||||
|
while not GetDuiHandle(newTxt) do Wait(0) end
|
||||||
|
CreateRuntimeTextureFromDuiHandle(previewTxd, txname, duihandle)
|
||||||
|
else
|
||||||
|
CreateRuntimeTextureFromImage(previewTxd, txname, data.preview)
|
||||||
|
end
|
||||||
|
exports["blip_info"]:SetBlipInfoImage(blip, GetCurrentResourceName()..'previewTxd', txname)
|
||||||
|
exports["blip_info"]:SetBlipInfoTitle(blip, data.name, false)
|
||||||
|
end
|
||||||
|
end
|
||||||
if Config.System.Debug then print("^6Bridge^7: ^6Blip ^2created for Entity^7: '^6"..data.name.."^7'") end
|
if Config.System.Debug then print("^6Bridge^7: ^6Blip ^2created for Entity^7: '^6"..data.name.."^7'") end
|
||||||
return blip
|
return blip
|
||||||
end
|
end
|
||||||
@@ -494,7 +552,7 @@ end)
|
|||||||
RegisterNetEvent(GetCurrentResourceName()..":server:setNeed", function(type, amount) local src = source
|
RegisterNetEvent(GetCurrentResourceName()..":server:setNeed", function(type, amount) local src = source
|
||||||
if type == "thirst" then
|
if type == "thirst" then
|
||||||
setThirst(src, amount)
|
setThirst(src, amount)
|
||||||
elseif type == "thirst" then
|
elseif type == "hunger" then
|
||||||
setHunger(src, amount)
|
setHunger(src, amount)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
@@ -531,8 +589,8 @@ end
|
|||||||
-- [[CONSUME]] --
|
-- [[CONSUME]] --
|
||||||
function ConsumeSuccess(itemName, type)
|
function ConsumeSuccess(itemName, type)
|
||||||
ExecuteCommand("e c")
|
ExecuteCommand("e c")
|
||||||
toggleItem(false, itemName, 1)
|
removeItem(itemName, 1)
|
||||||
if GetResourceState(ESXEport):find("start") then
|
if GetResourceState(ESXExport):find("start") then
|
||||||
if Items[itemName].hunger then
|
if Items[itemName].hunger then
|
||||||
TriggerServerEvent(GetCurrentResourceName()..":server:setNeed", "hunger", Items[itemName].hunger * 10000)
|
TriggerServerEvent(GetCurrentResourceName()..":server:setNeed", "hunger", Items[itemName].hunger * 10000)
|
||||||
end
|
end
|
||||||
@@ -548,17 +606,22 @@ function ConsumeSuccess(itemName, type)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if type == "alcohol" then alcoholCount += 1
|
if type == "alcohol" then alcoholCount += 1
|
||||||
if alcoholCount > 1 and alcoholCount < 4 then TriggerEvent("evidence:client:SetStatus", "alcohol", 200) elseif alcoholCount >= 4 then TriggerEvent("evidence:client:SetStatus", "heavyalcohol", 200) AlienEffect() end
|
if alcoholCount > 1 and alcoholCount < 4 then
|
||||||
|
TriggerEvent("evidence:client:SetStatus", "alcohol", 200)
|
||||||
|
elseif alcoholCount >= 4 then
|
||||||
|
TriggerEvent("evidence:client:SetStatus", "heavyalcohol", 200)
|
||||||
|
AlienEffect()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if Config.RewardItem == itemName then toggleItem(true, Config.RewardPool[math.random(1, #Config.RewardPool)], 1) end
|
getRandomReward(itemName) -- check if a reward item should be given
|
||||||
end
|
end
|
||||||
|
|
||||||
function addItem(item, amount, info)
|
function addItem(item, amount, info)
|
||||||
TriggerServerEvent(GetCurrentResourceName()..":server:toggleItem", true, item, amount)
|
TriggerServerEvent(GetCurrentResourceName()..":server:toggleItem", true, item, amount, nil, info)
|
||||||
end
|
end
|
||||||
|
|
||||||
function removeItem(item, amount)
|
function removeItem(item, amount)
|
||||||
TriggerServerEvent(GetCurrentResourceName()..":server:toggleItem", false, item, amount)
|
TriggerServerEvent(GetCurrentResourceName()..":server:toggleItem", false, item, amount, nil, info)
|
||||||
end
|
end
|
||||||
|
|
||||||
RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give, item, amount, newsrc)
|
RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give, item, amount, newsrc)
|
||||||
@@ -620,7 +683,7 @@ RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give,
|
|||||||
print("^4ERROR^7: ^2No Inventory detected ^7- ^2Check ^3exports^1.^2lua^7")
|
print("^4ERROR^7: ^2No Inventory detected ^7- ^2Check ^3exports^1.^2lua^7")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
dupeWarn(src, item) -- if not boot the player
|
dupeWarn(src, item, amount) -- if not boot the player
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local amount = amount and amount or 1
|
local amount = amount and amount or 1
|
||||||
@@ -675,10 +738,10 @@ RegisterNetEvent(GetCurrentResourceName()..":server:toggleItem", function(give,
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
--Item Exploit protection
|
--Item Exploit protection
|
||||||
function dupeWarn(src, item)
|
function dupeWarn(src, item, amount)
|
||||||
print("^5DupeWarn^7: (^1"..tostring(src).."^7) ^2Tried to remove item ^7('^3"..item.."^7')^2 but it wasn't there^7")
|
print("^5DupeWarn^7: (^1"..tostring(src).."^7) ^2Tried to remove item ^7('^3"..item.."^7')^2 but it wasn't there^7")
|
||||||
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 suspected duplicating items:"..item)
|
||||||
end
|
end
|
||||||
print("^5DupeWarn:^7: (^1"..tostring(src).."^7) ^2Dropped from server - exploit protection detected an item not being found in players inventory^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
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
name "Jim_Bridge"
|
name "Jim_Bridge"
|
||||||
author "Jimathy"
|
author "Jimathy"
|
||||||
version "1.0.8"
|
version "1.0.12"
|
||||||
description "Framework Bridge By Jimathy"
|
description "Framework Bridge By Jimathy"
|
||||||
fx_version "cerulean"
|
fx_version "cerulean"
|
||||||
game "gta5"
|
game "gta5"
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
1.0.8
|
1.0.12
|
||||||
|
|||||||
358
wrapper.lua
358
wrapper.lua
@@ -1,6 +1,6 @@
|
|||||||
Items, Vehicles, Jobs, Gangs, Core, ESX = {}, nil, nil, nil, nil, nil
|
Items, Vehicles, Jobs, Gangs, Core, ESX = {}, nil, nil, nil, nil, nil
|
||||||
|
|
||||||
Exports.QBInv = GetResourceState("ps-inventory"):find("start") and "ps-inventory" or GetResourceState("lj-inventory"):find("start") and "lj-inventory" or ""
|
Exports.QBInv = GetResourceState("ps-inventory"):find("start") and "ps-inventory" or GetResourceState("lj-inventory"):find("start") and "lj-inventory" or Exports.QBInv
|
||||||
|
|
||||||
OXLibExport, QBXExport, QBExport, ESXExport, OXCoreExport = Exports.OXLibExport or "", Exports.QBXExport or "", Exports.QBExport or "", Exports.ESXExport or "", Exports.OXCoreExport or ""
|
OXLibExport, QBXExport, QBExport, ESXExport, OXCoreExport = Exports.OXLibExport or "", Exports.QBXExport or "", Exports.QBExport or "", Exports.ESXExport or "", Exports.OXCoreExport or ""
|
||||||
|
|
||||||
@@ -26,135 +26,130 @@ 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
|
||||||
|
|
||||||
local loadItems = function() local itemResource = ""
|
local itemResource, jobResource = "", ""
|
||||||
if GetResourceState(OXInv):find("start") then
|
|
||||||
itemResource = OXInv
|
-- Load item lists
|
||||||
Items = exports[OXInv]:Items()
|
if GetResourceState(OXInv):find("start") then itemResource = OXInv
|
||||||
for k, v in pairs(Items) do
|
Items = exports[OXInv]:Items()
|
||||||
if v.client and v.client.image then
|
for k, v in pairs(Items) do
|
||||||
Items[k].image = (v.client.image):gsub("nui://"..OXInv.."/web/images/", "")
|
if v.client and v.client.image then
|
||||||
else
|
Items[k].image = (v.client.image):gsub("nui://"..OXInv.."/web/images/", "")
|
||||||
Items[k].image = k..".png"
|
else
|
||||||
end
|
Items[k].image = k..".png"
|
||||||
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
|
Items[k].hunger = v.client and v.client.hunger or nil
|
||||||
itemResource = QBExport
|
Items[k].thirst = v.client and v.client.thirst or nil
|
||||||
Core = Core or exports[QBExport]:GetCoreObject()
|
|
||||||
Items = Core and Core.Shared.Items or nil
|
|
||||||
elseif GetResourceState(ESXExport):find("start") then
|
|
||||||
itemResource = ESXExport
|
|
||||||
ESX = exports[ESXExport]:getSharedObject()
|
|
||||||
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
|
||||||
|
|
||||||
|
elseif GetResourceState(QBExport):find("start") then itemResource = QBExport
|
||||||
|
Core = Core or exports[QBExport]:GetCoreObject()
|
||||||
|
Items = Core and Core.Shared.Items or nil
|
||||||
|
|
||||||
|
elseif GetResourceState(ESXExport):find("start") then itemResource = ESXExport
|
||||||
|
ESX = exports[ESXExport]:getSharedObject()
|
||||||
|
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
|
||||||
|
|
||||||
local loadVehicles = function() local vehResource = ""
|
-- Load Vehicles
|
||||||
if GetResourceState(QBXExport):find("start") or GetResourceState(QBExport):find("start") then vehResource = QBExport
|
if GetResourceState(QBXExport):find("start") or GetResourceState(QBExport):find("start") then
|
||||||
Core = Core or exports[QBExport]:GetCoreObject()
|
Core = Core or exports[QBExport]:GetCoreObject()
|
||||||
if GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then
|
if GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then
|
||||||
RegisterNetEvent('QBCore:Client:UpdateObject', function()
|
RegisterNetEvent('QBCore:Client:UpdateObject', function()
|
||||||
Core = Core or exports[QBExport]:GetCoreObject()
|
Core = Core or exports[QBExport]:GetCoreObject()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
Vehicles = Core and Core.Shared.Vehicles
|
||||||
|
print("^6Bridge^7: ^2Loading ^6"..countTable(Vehicles).." ^3Vehicles^2 from ^7"..QBExport)
|
||||||
|
elseif GetResourceState(OXCoreExport):find("start") then
|
||||||
|
Vehicles = {}
|
||||||
|
for k, v in pairs(Ox.GetVehicleData()) do
|
||||||
|
Vehicles[k] = { model = k, price = v.price, name = v.name, brand = v.make }
|
||||||
|
end
|
||||||
|
print("^6Bridge^7: ^2Loading ^6"..countTable(Vehicles).." ^3Vehicles^2 from ^7"..OXCoreExport)
|
||||||
|
elseif GetResourceState(ESXExport):find("start") then
|
||||||
|
print("^6Bridge^7: ^2Loading ^3Vehicles^2 from ^7"..ESXExport)
|
||||||
|
--print("^6Bridge^7: ^2Loading ^6"..countTable(Vehicles).." ^3Vehicles^2 from ^7"..ESXExport)
|
||||||
|
CreateThread(function()
|
||||||
|
if IsDuplicityVersion() then
|
||||||
|
createCallback(GetCurrentResourceName()..":getVehiclesPrices", function(source)
|
||||||
|
Vehicles = MySQL.query.await('SELECT model, price, name FROM vehicles')
|
||||||
|
print("^6Bridge^7: ^3Found ^6"..countTable(Vehicles).." ^3Vehicles^2 from ^7"..ESXExport)
|
||||||
|
return Vehicles
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
Vehicles = Core and Core.Shared.Vehicles
|
if not IsDuplicityVersion() then
|
||||||
elseif GetResourceState(OXCoreExport):find("start") then vehResource = OXCoreExport
|
local TempVehicles = triggerCallback(GetCurrentResourceName()..":getVehiclesPrices")
|
||||||
Vehicles = {}
|
for _, v in pairs(TempVehicles) 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[v.model] = { model = v.model, price = v.price, name = v.name, brand = GetMakeNameFromVehicleModel(v.model):lower():gsub("^%l", string.upper) }
|
||||||
end
|
|
||||||
elseif GetResourceState(ESXExport):find("start") then vehResource = ESXExport
|
|
||||||
CreateThread(function()
|
|
||||||
if IsDuplicityVersion() then
|
|
||||||
createCallback(GetCurrentResourceName()..":getVehiclesPrices", function(source)
|
|
||||||
Vehicles = MySQL.query.await('SELECT model, price, name FROM vehicles')
|
|
||||||
return Vehicles
|
|
||||||
end)
|
|
||||||
else
|
|
||||||
local TempVehicles = triggerCallback(GetCurrentResourceName()..":getVehiclesPrices")
|
|
||||||
for _, v in pairs(TempVehicles) do
|
|
||||||
Vehicles = Vehicles or {}
|
|
||||||
Vehicles[v.model] = { model = v.model, price = v.price, name = v.name, brand = GetMakeNameFromVehicleModel(v.model):lower():gsub("^%l", string.upper) }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end)
|
end
|
||||||
end
|
end)
|
||||||
local timeout = 1000 while not Vehicles and timeout > 0 do timeout -=1 Wait(0) end
|
else
|
||||||
if not Vehicles then
|
print("^4ERROR^7: ^2No Vehicle info detected ^7- ^2Check ^3exports^1.^2lua^7")
|
||||||
print("^4ERROR^7: ^2No Vehicle info detected ^7- ^2Check ^3exports^1.^2lua^7")
|
|
||||||
else
|
|
||||||
print("^6Bridge^7: ^2Loading ^6"..countTable(Vehicles).." ^3Vehicles^2 from ^7"..vehResource)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local loadJobs = function() local jobResource = ""
|
-- Load Jobs
|
||||||
if GetResourceState(QBXExport):find("start") then jobResource = QBXExport
|
local jobResource = ""
|
||||||
Core = Core or exports[QBExport]:GetCoreObject()
|
if GetResourceState(QBXExport):find("start") then jobResource = QBXExport
|
||||||
Jobs, Gangs = exports[QBXExport]:GetJobs(), exports[QBXExport]:GetGangs()
|
Core = Core or exports[QBExport]:GetCoreObject()
|
||||||
|
Jobs, Gangs = exports[QBXExport]:GetJobs(), exports[QBXExport]:GetGangs()
|
||||||
|
|
||||||
elseif GetResourceState(OXCoreExport):find("start") then jobResource = OXExport
|
elseif GetResourceState(OXCoreExport):find("start") then jobResource = OXExport
|
||||||
CreateThread(function()
|
CreateThread(function()
|
||||||
if IsDuplicityVersion() then
|
|
||||||
createCallback(GetCurrentResourceName()..":getOxGroups", function(source)
|
|
||||||
Jobs = MySQL.query.await('SELECT * FROM `ox_groups`') return Jobs
|
|
||||||
end)
|
|
||||||
else
|
|
||||||
local TempJobs = triggerCallback(GetCurrentResourceName()..":getOxGroups")
|
|
||||||
Jobs = TempJobs and {}
|
|
||||||
for k, v in pairs(TempJobs) do
|
|
||||||
local grades = {}
|
|
||||||
for i = 1, #v.grades do grades[i] = { name = v.grades[i], isboss = (i == #v.grades)} end
|
|
||||||
Jobs[v.name] = { label = v.label, grades = grades }
|
|
||||||
end
|
|
||||||
Gangs = Jobs
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
elseif GetResourceState(QBExport):find("start") then jobResource = QBExport
|
|
||||||
Core = Core or Core or exports[QBExport]:GetCoreObject()
|
|
||||||
RegisterNetEvent('QBCore:Client:UpdateObject', function() Core = Core or exports[QBExport]:GetCoreObject() end)
|
|
||||||
Jobs, Gangs = Core.Shared.Jobs, Core.Shared.Gangs
|
|
||||||
|
|
||||||
elseif GetResourceState(ESXExport):find("start") then jobResource = ESXExport
|
|
||||||
ESX = exports[ESXExport]:getSharedObject()
|
|
||||||
if IsDuplicityVersion() then
|
if IsDuplicityVersion() then
|
||||||
Jobs = ESX.GetJobs()
|
createCallback(GetCurrentResourceName()..":getOxGroups", function(source)
|
||||||
for k, v in pairs(Jobs) do
|
Jobs = MySQL.query.await('SELECT * FROM `ox_groups`') return Jobs
|
||||||
local count = countTable(Jobs[k].grades) - 1
|
end)
|
||||||
Jobs[k].grades[tostring(count)].isBoss = true
|
else
|
||||||
|
local TempJobs = triggerCallback(GetCurrentResourceName()..":getOxGroups")
|
||||||
|
Jobs = TempJobs and {}
|
||||||
|
for k, v in pairs(TempJobs) do
|
||||||
|
local grades = {}
|
||||||
|
for i = 1, #v.grades do grades[i] = { name = v.grades[i], isboss = (i == #v.grades)} end
|
||||||
|
Jobs[v.name] = { label = v.label, grades = grades }
|
||||||
end
|
end
|
||||||
Gangs = Jobs
|
Gangs = Jobs
|
||||||
end
|
end
|
||||||
CreateThread(function()
|
end)
|
||||||
while not ESX do Wait(0) end
|
|
||||||
if IsDuplicityVersion() then
|
|
||||||
createCallback(GetCurrentResourceName()..":getJobs", function(source)
|
|
||||||
return Jobs
|
|
||||||
end)
|
|
||||||
else
|
|
||||||
Jobs = triggerCallback(GetCurrentResourceName()..":getJobs")
|
|
||||||
Gangs = Jobs
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
local timeout = 1000 while not Jobs and timeout > 0 do timeout -=1 Wait(0) end
|
|
||||||
if Jobs then
|
|
||||||
print("^6Bridge^7: ^2Loading ^6"..countTable(Jobs).." ^3Jobs^2 from ^7"..jobResource)
|
|
||||||
print("^6Bridge^7: ^2Loading ^6"..countTable(Gangs).." ^3Gangs^2 from ^7"..jobResource)
|
|
||||||
else
|
|
||||||
print("^4ERROR^7: ^2No Job/Gang info detected ^7- ^2Check ^3exports^1.^2lua^7")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
loadItems()
|
elseif GetResourceState(QBExport):find("start") then jobResource = QBExport
|
||||||
loadVehicles()
|
Core = Core or Core or exports[QBExport]:GetCoreObject()
|
||||||
loadJobs()
|
RegisterNetEvent('QBCore:Client:UpdateObject', function() Core = Core or exports[QBExport]:GetCoreObject() end)
|
||||||
|
Jobs, Gangs = Core.Shared.Jobs, Core.Shared.Gangs
|
||||||
|
|
||||||
|
elseif GetResourceState(ESXExport):find("start") then
|
||||||
|
print("^6Bridge^7: ^2Loading ^3Jobs^7/^3Gangs^2 from ^7"..ESXExport)
|
||||||
|
ESX = exports[ESXExport]:getSharedObject()
|
||||||
|
if IsDuplicityVersion() then
|
||||||
|
Jobs = ESX.GetJobs()
|
||||||
|
for k, v in pairs(Jobs) do
|
||||||
|
local count = countTable(Jobs[k].grades)-1
|
||||||
|
Jobs[k].grades[tostring(count)].isBoss = true
|
||||||
|
end
|
||||||
|
Gangs = Jobs
|
||||||
|
end
|
||||||
|
CreateThread(function()
|
||||||
|
while not ESX do Wait(0) end
|
||||||
|
if IsDuplicityVersion() then
|
||||||
|
createCallback(GetCurrentResourceName()..":getJobs", function(source)
|
||||||
|
return Jobs
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
if not IsDuplicityVersion() then
|
||||||
|
Jobs = triggerCallback(GetCurrentResourceName()..":getJobs")
|
||||||
|
Gangs = Jobs
|
||||||
|
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 = {}
|
||||||
@@ -181,11 +176,7 @@ 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
|
else
|
||||||
print("^4ERROR^7: ^2No PolyZone creation script detected ^7- ^2Check ^3exports^1.^2lua^7")
|
print("^4ERROR^7: ^2No PolyZone creation script detected ^7- ^2Check ^3exports^1.^2lua^7")
|
||||||
@@ -1012,31 +1003,58 @@ AddStateBagChangeHandler(GetCurrentResourceName()..':setVehicleProperties', '',
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNetEvent(GetCurrentResourceName()..":server:ChargePlayer", function(cost, type) local src = source
|
RegisterNetEvent(GetCurrentResourceName()..":server:ChargePlayer", function(cost, type, newsrc)
|
||||||
if Config.System.Debug then print("^6Bridge^7: ^2Charging ^2Player: '^6"..cost.."^7'", type) end
|
local src = newsrc or source
|
||||||
|
local fundResource = ""
|
||||||
if type == "cash" then
|
if type == "cash" then
|
||||||
if GetResourceState(OXInv):find("start") then
|
if GetResourceState(OXInv):find("start") then fundResource = OXInv
|
||||||
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") or GetResourceState(QBXExport):find("start") then fundResource = QBExport
|
||||||
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 fundResource = ESXExport
|
||||||
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 fundResource = QBExport
|
||||||
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 fundResource = ESXExport
|
||||||
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 fundResource == "" then print("error - check exports.lua")
|
||||||
|
else
|
||||||
|
if Config.System.Debug then print("^6Bridge^7: ^2Charging ^2Player^7: '^6"..cost.."^7'", type, fundResource) end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
RegisterNetEvent(GetCurrentResourceName()..":server:FundPlayer", function(fund, type, newsrc)
|
||||||
|
local src = newsrc or source
|
||||||
|
local fundResource = ""
|
||||||
|
if type == "cash" then
|
||||||
|
if GetResourceState(OXInv):find("start") then fundResource = OXInv
|
||||||
|
exports[OXInv]:AddItem(src, "money", fund)
|
||||||
|
elseif GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then fundResource = QBExport
|
||||||
|
Core.Functions.GetPlayer(src).Functions.AddMoney("cash", fund)
|
||||||
|
elseif GetResourceState(ESXExport):find("start") then fundResource = ESXExport
|
||||||
|
local Player = ESX.GetPlayerFromId(src)
|
||||||
|
Player.addMoney(fund, "")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if type == "bank" then
|
||||||
|
if GetResourceState(QBExport):find("start") or GetResourceState(QBXExport):find("start") then fundResource = QBExport
|
||||||
|
Core.Functions.GetPlayer(src).Functions.AddMoney("bank", fund)
|
||||||
|
elseif GetResourceState(ESXExport):find("start") then fundResource = ESXExport
|
||||||
|
local Player = ESX.GetPlayerFromId(src)
|
||||||
|
Player.addMoney(fund, "")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if fundResource == "" then print("error - check exports.lua")
|
||||||
|
else
|
||||||
|
if Config.System.Debug then print("^6Bridge^7: ^2Funding ^2Player^7: '^2"..fund.."^7'", type, fundResource) end
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
function createUseableItem(item, funct)
|
function createUseableItem(item, funct)
|
||||||
@@ -1133,6 +1151,7 @@ function hasJob(job, source, grade) local hasJob, duty = false, true
|
|||||||
if ganginfo.name == job then hasJob = true
|
if ganginfo.name == job then hasJob = true
|
||||||
if grade and not (grade <= ganginfo.grade.level) then hasJob = false end
|
if grade and not (grade <= ganginfo.grade.level) then hasJob = false end
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then
|
elseif GetResourceState(QBExport):find("start") and not GetResourceState(QBXExport):find("start") then
|
||||||
local info = nil
|
local info = nil
|
||||||
Core.Functions.GetPlayerData(function(PlayerData)
|
Core.Functions.GetPlayerData(function(PlayerData)
|
||||||
@@ -1148,6 +1167,7 @@ function hasJob(job, source, grade) local hasJob, duty = false, true
|
|||||||
hasJob = true
|
hasJob = true
|
||||||
if grade and not (grade <= ganginfo.grade.level) then hasJob = false end
|
if grade and not (grade <= ganginfo.grade.level) then hasJob = false end
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
print("^4ERROR^7: ^2No Core detected for hasJob() ^7- ^2Check ^3exports^1.^2lua^7")
|
print("^4ERROR^7: ^2No Core detected for hasJob() ^7- ^2Check ^3exports^1.^2lua^7")
|
||||||
end
|
end
|
||||||
@@ -1166,6 +1186,7 @@ function getPlayer(source) local Player = {}
|
|||||||
cash = info.getMoney(),
|
cash = info.getMoney(),
|
||||||
bank = info.getAccount("bank").money,
|
bank = info.getAccount("bank").money,
|
||||||
}
|
}
|
||||||
|
|
||||||
elseif GetResourceState(OXCoreExport):find("start") then
|
elseif GetResourceState(OXCoreExport):find("start") then
|
||||||
local file = ('imports/%s.lua'):format('server')
|
local file = ('imports/%s.lua'):format('server')
|
||||||
local import = LoadResourceFile('ox_core', file)
|
local import = LoadResourceFile('ox_core', file)
|
||||||
@@ -1177,6 +1198,7 @@ function getPlayer(source) local Player = {}
|
|||||||
cash = exports[OXInv]:Search(src, 'count', "money"),
|
cash = exports[OXInv]:Search(src, 'count', "money"),
|
||||||
bank = 0,
|
bank = 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
elseif GetResourceState(QBXExport):find("start") then
|
elseif GetResourceState(QBXExport):find("start") then
|
||||||
local info = exports[QBXExport]:GetPlayer(src)
|
local info = exports[QBXExport]:GetPlayer(src)
|
||||||
Player = {
|
Player = {
|
||||||
@@ -1184,6 +1206,7 @@ function getPlayer(source) local Player = {}
|
|||||||
cash = exports[OXInv]:Search(src, 'count', "money"),
|
cash = exports[OXInv]:Search(src, 'count', "money"),
|
||||||
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
|
||||||
if Core.Functions.GetPlayer ~= nil then -- support older qb-core functions
|
if Core.Functions.GetPlayer ~= nil then -- support older qb-core functions
|
||||||
local info = Core.Functions.GetPlayer(src).PlayerData
|
local info = Core.Functions.GetPlayer(src).PlayerData
|
||||||
@@ -1200,6 +1223,7 @@ function getPlayer(source) local Player = {}
|
|||||||
bank = info.money["bank"],
|
bank = info.money["bank"],
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
print("^4ERROR^7: ^2No Core detected for getPlayer() ^7- ^2Check ^3exports^1.^2lua^7")
|
print("^4ERROR^7: ^2No Core detected for getPlayer() ^7- ^2Check ^3exports^1.^2lua^7")
|
||||||
end
|
end
|
||||||
@@ -1245,6 +1269,60 @@ function getPlayer(source) local Player = {}
|
|||||||
return Player
|
return Player
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function sendPhoneMail(data) local phoneResource = ""
|
||||||
|
if GetResourceState("gksphone"):find("start") then phoneResource = "gksphone"
|
||||||
|
exports["gksphone"]:SendNewMail(data)
|
||||||
|
|
||||||
|
elseif GetResourceState("yflip-phone"):find("start") then phoneResource = "yflip-phone"
|
||||||
|
TriggerServerEvent(GetCurrentResourceName()..":yflip:SendMail", data)
|
||||||
|
|
||||||
|
elseif GetResourceState("qs-smartphone"):find("start") then phoneResource = "qs-smartphone"
|
||||||
|
TriggerServerEvent('qs-smartphone:server:sendNewMail', data)
|
||||||
|
|
||||||
|
elseif GetResourceState("qs-smartphone-pro"):find("start") then phoneResource = "qs-smartphone-pro"
|
||||||
|
TriggerServerEvent('phone:sendNewMail', data)
|
||||||
|
|
||||||
|
elseif GetResourceState("roadphone"):find("start") then phoneResource = "roadphone"
|
||||||
|
data.message = data.message:gsub("%<br>", "\n")
|
||||||
|
exports['roadphone']:sendMail(data)
|
||||||
|
|
||||||
|
elseif GetResourceState("lb-phone"):find("start") then phoneResource = "lb-phone"
|
||||||
|
TriggerServerEvent(GetCurrentResourceName()..":lbphone:SendMail", data)
|
||||||
|
|
||||||
|
elseif GetResourceState("qb-phone"):find("start") then phoneResource = "qb-phone"
|
||||||
|
TriggerServerEvent('qb-phone:server:sendNewMail', data)
|
||||||
|
end
|
||||||
|
|
||||||
|
if phoneResource ~= "" then if Config.System.Debug then print("^6Bridge^7[^3"..phoneResource.."^7]: ^2Sending mail to player") end
|
||||||
|
else print("^6Bridge^7: ^1ERROR ^2Sending mail to player ^7 - ^2No supported phone found") end
|
||||||
|
end
|
||||||
|
|
||||||
|
RegisterNetEvent(GetCurrentResourceName()..":lbphone:SendMail", function(data)
|
||||||
|
local src = source
|
||||||
|
local phoneNumber = exports["lb-phone"]:GetEquippedPhoneNumber(src)
|
||||||
|
local emailAddress = exports["lb-phone"]:GetEmailAddress(phoneNumber)
|
||||||
|
exports["lb-phone"]:SendMail({
|
||||||
|
to = emailAddress,
|
||||||
|
subject = data.subject,
|
||||||
|
message = data.message,
|
||||||
|
--[[attachments = {
|
||||||
|
"https://cdn.discordapp.com/attachments/1035667053115363349/1042500877426110474/upload.png",
|
||||||
|
},]]
|
||||||
|
actions = data.buttons,
|
||||||
|
})
|
||||||
|
end)
|
||||||
|
|
||||||
|
RegisterNetEvent(GetCurrentResourceName()..":yflip:SendMail", function(data)
|
||||||
|
local src = source
|
||||||
|
exports["yflip-phone"]:SendMail({
|
||||||
|
title = data.subject,
|
||||||
|
sender = data.sender,
|
||||||
|
senderDisplayName = data.sender,
|
||||||
|
content = data.message,
|
||||||
|
actions = data.buttons,
|
||||||
|
}, 'source', src)
|
||||||
|
end)
|
||||||
|
|
||||||
function registerCommand(command, options)
|
function registerCommand(command, options)
|
||||||
if GetResourceState(OXLibExport):find("start") then
|
if GetResourceState(OXLibExport):find("start") then
|
||||||
if Config.System.Debug then print("^6Bridge^7: ^2Registering ^3Command^2 with ^7"..OXLibExport, command) end
|
if Config.System.Debug then print("^6Bridge^7: ^2Registering ^3Command^2 with ^7"..OXLibExport, command) end
|
||||||
@@ -1260,13 +1338,13 @@ function invImg(item)
|
|||||||
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 or "")
|
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 or "")
|
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 or "")
|
imgLink = "nui://"..CoreInv.."/html/img/"..(Items[item].image or "")
|
||||||
elseif GetResourceState(OrigenInv and OrigenInv or ""):find("start") then
|
elseif GetResourceState(OrigenInv):find("start") then
|
||||||
imgLink = "nui://"..OrigenInv.."/html/img/"..(Items[item].image or "")
|
imgLink = "nui://"..OrigenInv.."/html/img/"..(Items[item].image or "")
|
||||||
elseif GetResourceState(QBInv and QBInv or ""):find("start") then
|
elseif GetResourceState(QBInv):find("start") then
|
||||||
imgLink = "nui://"..QBInv.."/html/images/"..(Items[item].image or "")
|
imgLink = "nui://"..QBInv.."/html/images/"..(Items[item].image or "")
|
||||||
else
|
else
|
||||||
print("^4ERROR^7: ^2No Inventory detected for invImg ^7- ^2Check ^3exports^1.^2lua^7")
|
print("^4ERROR^7: ^2No Inventory detected for invImg ^7- ^2Check ^3exports^1.^2lua^7")
|
||||||
@@ -1275,13 +1353,13 @@ function invImg(item)
|
|||||||
return imgLink
|
return imgLink
|
||||||
end
|
end
|
||||||
|
|
||||||
function registerStash(name, label)
|
function registerStash(name, label, slots, weight)
|
||||||
if GetResourceState(OXInv):find("start") then
|
if GetResourceState(OXInv):find("start") then
|
||||||
--print("Registering OX Stash:", name, label)
|
--print("Registering OX Stash:", name, label)
|
||||||
exports[OXInv]:RegisterStash(name, label, 50, 4000000)
|
exports[OXInv]:RegisterStash(name, label, slots or 50, weight or 4000000)
|
||||||
elseif GetResourceState(QSInv):find("start") then
|
elseif GetResourceState(QSInv):find("start") then
|
||||||
--print("Registering QS Stash:", name, label)
|
--print("Registering QS Stash:", name, label)
|
||||||
exports[QSInv]:RegisterStash(name, 50, 4000000)
|
exports[QSInv]:RegisterStash(name, slots or 50, weight or 4000000)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- IN NO WAY PERFECT --
|
-- IN NO WAY PERFECT --
|
||||||
|
|||||||
Reference in New Issue
Block a user