mirror of
https://github.com/jimathy/jim_bridge.git
synced 2026-08-18 14:26:03 +01:00
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b4aa1b3eda | ||
|
|
0f9bab00ef | ||
|
|
9d8706e8c6 | ||
|
|
6ba1e14888 | ||
|
|
0454f8c0a9 | ||
|
|
e17d8f2b93 | ||
|
|
b44dfa91e5 | ||
|
|
51d4c88694 | ||
|
|
f5f502875e | ||
|
|
9c769f4e8e | ||
|
|
87cdd5502e | ||
|
|
68d713a8dc | ||
|
|
dd34f8aab1 | ||
|
|
4a3fb8db4d | ||
|
|
59733de08e | ||
|
|
2b7a1c2e6d | ||
|
|
5db9e88bb9 | ||
|
|
a5b1f750dd |
@@ -1,10 +1,11 @@
|
|||||||
--[[
|
--[[
|
||||||
Cached Resource Initialization Module
|
Cached Resource Initialization Module
|
||||||
--------------------------------------
|
--------------------------------------
|
||||||
This module initializes shared data (Items, Vehicles, Jobs, Gangs)
|
Initializes shared resource data (Items, Vehicles, Jobs, Gangs) once and caches it
|
||||||
only once and stores it in _G.__jimBridgeDataCache for reuse across scripts.
|
to improve performance and reduce redundant data fetching across scripts.
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
-- Define resource names used in different frameworks
|
||||||
local Exports = {
|
local Exports = {
|
||||||
QBExport = "qb-core",
|
QBExport = "qb-core",
|
||||||
QBXExport = "qbx_core",
|
QBXExport = "qbx_core",
|
||||||
@@ -19,6 +20,7 @@ local Exports = {
|
|||||||
CodeMInv = "codem-inventory",
|
CodeMInv = "codem-inventory",
|
||||||
OrigenInv = "origen_inventory",
|
OrigenInv = "origen_inventory",
|
||||||
TgiannInv = "tgiann-inventory",
|
TgiannInv = "tgiann-inventory",
|
||||||
|
JPRInv = "jpr-inventory",
|
||||||
|
|
||||||
OXLibExport = "ox_lib",
|
OXLibExport = "ox_lib",
|
||||||
|
|
||||||
@@ -32,17 +34,20 @@ local Exports = {
|
|||||||
RSGInv = "rsg-inventory"
|
RSGInv = "rsg-inventory"
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Ensure cache only runs once
|
-- Prevent reloading if cache is already initialized
|
||||||
if _G.__jimBridgeDataCache then return end
|
if _G.__jimBridgeDataCache then return end
|
||||||
_G.__jimBridgeDataCache = {}
|
_G.__jimBridgeDataCache = {}
|
||||||
local cache = _G.__jimBridgeDataCache
|
local cache = _G.__jimBridgeDataCache
|
||||||
|
|
||||||
function checkExists(resourceName)
|
-- Helper function to check if resource exists in server (instead of if it is already started)
|
||||||
|
local function checkExists(resourceName)
|
||||||
return GetResourceState(resourceName):find("start") or GetResourceState(resourceName):find("stopped")
|
return GetResourceState(resourceName):find("start") or GetResourceState(resourceName):find("stopped")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Ensure oxmysql resource is loaded
|
||||||
local fileLoader = assert(load(LoadResourceFile("oxmysql", ('lib/MySQL.lua')), ('@@oxmysql/lib/MySQL.lua')))
|
local fileLoader = assert(load(LoadResourceFile("oxmysql", ('lib/MySQL.lua')), ('@@oxmysql/lib/MySQL.lua')))
|
||||||
fileLoader()
|
fileLoader()
|
||||||
|
|
||||||
if checkExists(Exports.OXCoreExport) then
|
if checkExists(Exports.OXCoreExport) then
|
||||||
-- Detected OX_Core in server, wait for it to be started if needed
|
-- Detected OX_Core in server, wait for it to be started if needed
|
||||||
while GetResourceState(Exports.OXCoreExport) ~= "started" do Wait(100) end
|
while GetResourceState(Exports.OXCoreExport) ~= "started" do Wait(100) end
|
||||||
@@ -56,7 +61,7 @@ if checkExists(Exports.ESXExport) then
|
|||||||
fileLoader()
|
fileLoader()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Init variables
|
-- Initialize variables for caching
|
||||||
local Items, Vehicles, Jobs, Gangs, Core = nil, nil, nil, nil, nil
|
local Items, Vehicles, Jobs, Gangs, Core = nil, nil, nil, nil, nil
|
||||||
local itemResource, jobResource, vehResource = "", "", ""
|
local itemResource, jobResource, vehResource = "", "", ""
|
||||||
|
|
||||||
@@ -70,32 +75,20 @@ end
|
|||||||
---------------------
|
---------------------
|
||||||
---- Load Items -----
|
---- Load Items -----
|
||||||
---------------------
|
---------------------
|
||||||
|
-- Items initialization based on detected inventory system
|
||||||
if checkExists(Exports.OXInv) then
|
if checkExists(Exports.OXInv) then
|
||||||
-- Wait for OX Inventory to start if it's not already started
|
-- Wait for OX Inventory to start if it's not already started
|
||||||
while GetResourceState(Exports.OXInv) ~= "started" do Wait(100) end
|
while GetResourceState(Exports.OXInv) ~= "started" do Wait(100) end
|
||||||
itemResource = Exports.OXInv
|
itemResource = Exports.OXInv
|
||||||
Items = exports[Exports.OXInv]:Items()
|
Items = exports[Exports.OXInv]:Items()
|
||||||
-- IF QBX-Core is running, merge items from there
|
|
||||||
if checkExists(Exports.QBExport)then
|
-- Get Weapon info and duplicate them if they are uppercase
|
||||||
local tempWeapons = exports[Exports.QBExport]:GetCoreObject().Shared.Weapons
|
-- (duplicate incase anything checks for the uppercase version)
|
||||||
for k, v in pairs(tempWeapons) do
|
|
||||||
local info = exports[Exports.OXInv]:Items(v.name)
|
|
||||||
local weight = info and info.weight or 0
|
|
||||||
if not Items[v.name] then
|
|
||||||
Items[v.name] = {
|
|
||||||
name = v.name,
|
|
||||||
label = v.label,
|
|
||||||
type = "weapon",
|
|
||||||
ammotype = v.ammotype or "AMMO_PISTOL",
|
|
||||||
weight = weight,
|
|
||||||
image = v.image or (v.name..".png"),
|
|
||||||
description = v.label or "",
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
-- tidy info into something jim_bridge can use
|
|
||||||
for k, v in pairs(Items) do
|
for k, v in pairs(Items) do
|
||||||
|
if k:find("WEAPON") then
|
||||||
|
Items[k:lower()] = Items[k]
|
||||||
|
Items[k:lower()].image = k..".png"
|
||||||
|
end
|
||||||
Items[k].image = (v.client and v.client.image) and v.client.image:gsub("nui://"..Exports.OXInv.."/web/images/", "") or k..".png"
|
Items[k].image = (v.client and v.client.image) and v.client.image:gsub("nui://"..Exports.OXInv.."/web/images/", "") or k..".png"
|
||||||
Items[k].hunger = v.client and v.client.hunger
|
Items[k].hunger = v.client and v.client.hunger
|
||||||
Items[k].thirst = v.client and v.client.thirst
|
Items[k].thirst = v.client and v.client.thirst
|
||||||
@@ -106,6 +99,10 @@ elseif checkExists(Exports.QBExport) then
|
|||||||
itemResource = Exports.QBExport
|
itemResource = Exports.QBExport
|
||||||
Core = exports[Exports.QBExport]:GetCoreObject()
|
Core = exports[Exports.QBExport]:GetCoreObject()
|
||||||
Items = Core.Shared.Items
|
Items = Core.Shared.Items
|
||||||
|
if Items == nil then
|
||||||
|
print("^1ERROR^7: ^1Can NOT find shared ^7Items ^1table^7, ^1possible error in that file^7?")
|
||||||
|
Items = {} -- Fallback to an empty table
|
||||||
|
end
|
||||||
|
|
||||||
elseif checkExists(Exports.ESXExport) then
|
elseif checkExists(Exports.ESXExport) then
|
||||||
itemResource = Exports.ESXExport
|
itemResource = Exports.ESXExport
|
||||||
@@ -124,15 +121,25 @@ elseif checkExists(Exports.RSGExport) then
|
|||||||
itemResource = Exports.RSGExport
|
itemResource = Exports.RSGExport
|
||||||
Core = exports[Exports.RSGExport]:GetCoreObject()
|
Core = exports[Exports.RSGExport]:GetCoreObject()
|
||||||
Items = Core.Shared.Items
|
Items = Core.Shared.Items
|
||||||
|
if Items == nil then
|
||||||
|
print("^1ERROR^7: ^1Can NOT find shared ^7Items ^1table^7, ^1possible error in that file^7?")
|
||||||
|
Items = {} -- Fallback to an empty table
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---------------------
|
---------------------
|
||||||
--- Load Vehicles ---
|
--- Load Vehicles ---
|
||||||
---------------------
|
---------------------
|
||||||
|
-- Vehicle loading depending on framework
|
||||||
if checkExists(Exports.QBXExport) or checkExists(Exports.QBExport) then
|
if checkExists(Exports.QBXExport) or checkExists(Exports.QBExport) then
|
||||||
vehResource = Exports.QBExport
|
vehResource = Exports.QBExport
|
||||||
Core = Core or exports[Exports.QBExport]:GetCoreObject()
|
Core = Core or exports[Exports.QBExport]:GetCoreObject()
|
||||||
Vehicles = Core.Shared.Vehicles
|
Vehicles = Core.Shared.Vehicles
|
||||||
|
if Vehicles == nil then
|
||||||
|
print("^1ERROR^7: ^1Can NOT find shared ^7Vehicles ^1table^7, ^1possible error in that file^7?")
|
||||||
|
Vehicles = {} -- Fallback to an empty table
|
||||||
|
end
|
||||||
|
|
||||||
elseif checkExists(Exports.OXCoreExport) then
|
elseif checkExists(Exports.OXCoreExport) then
|
||||||
vehResource = Exports.OXCoreExport
|
vehResource = Exports.OXCoreExport
|
||||||
@@ -163,15 +170,25 @@ elseif checkExists(Exports.RSGExport) then
|
|||||||
vehResource = Exports.RSGExport
|
vehResource = Exports.RSGExport
|
||||||
Core = Core or exports[Exports.RSGExport]:GetCoreObject()
|
Core = Core or exports[Exports.RSGExport]:GetCoreObject()
|
||||||
Vehicles = Core.Shared.Vehicles
|
Vehicles = Core.Shared.Vehicles
|
||||||
|
if Vehicles == nil then
|
||||||
|
print("^1ERROR^7: ^1Can NOT find shared ^7Vehicles ^1table^7, ^1possible error in that file^7?")
|
||||||
|
Vehicles = {} -- Fallback to an empty table
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---------------------
|
---------------------
|
||||||
----- Load Jobs -----
|
----- Load Jobs -----
|
||||||
---------------------
|
---------------------
|
||||||
|
-- Jobs loading based on framework
|
||||||
if checkExists(Exports.QBXExport) then
|
if checkExists(Exports.QBXExport) then
|
||||||
jobResource = Exports.QBXExport
|
jobResource = Exports.QBXExport
|
||||||
Core = Core or exports[Exports.QBXExport]:GetCoreObject()
|
Core = Core or exports[Exports.QBXExport]:GetCoreObject()
|
||||||
Jobs, Gangs = exports[Exports.QBXExport]:GetJobs(), exports[Exports.QBXExport]:GetGangs()
|
Jobs, Gangs = exports[Exports.QBXExport]:GetJobs(), exports[Exports.QBXExport]:GetGangs()
|
||||||
|
if Jobs == nil then
|
||||||
|
print("^1ERROR^7: ^1Can NOT find shared ^7Jobs ^1table^7, ^1possible error in that file^7?")
|
||||||
|
Jobs = {} -- Fallback to an empty table
|
||||||
|
end
|
||||||
|
|
||||||
elseif checkExists(Exports.OXCoreExport) then
|
elseif checkExists(Exports.OXCoreExport) then
|
||||||
jobResource = Exports.OXCoreExport
|
jobResource = Exports.OXCoreExport
|
||||||
@@ -225,7 +242,6 @@ elseif checkExists(Exports.ESXExport) then
|
|||||||
end
|
end
|
||||||
|
|
||||||
if highestGrade then
|
if highestGrade then
|
||||||
print("found boss for", Role)
|
|
||||||
Jobs[Role].grades[tostring(highestGrade)].isBoss = true
|
Jobs[Role].grades[tostring(highestGrade)].isBoss = true
|
||||||
end
|
end
|
||||||
::continue::
|
::continue::
|
||||||
@@ -236,6 +252,11 @@ elseif checkExists(Exports.RSGExport) then
|
|||||||
jobResource = Exports.RSGExport
|
jobResource = Exports.RSGExport
|
||||||
Core = Core or exports[Exports.RSGExport]:GetCoreObject()
|
Core = Core or exports[Exports.RSGExport]:GetCoreObject()
|
||||||
Jobs, Gangs = Core.Shared.Jobs, Core.Shared.Gangs
|
Jobs, Gangs = Core.Shared.Jobs, Core.Shared.Gangs
|
||||||
|
if Jobs == nil then
|
||||||
|
print("^1ERROR^7: ^1Can NOT find shared ^7Jobs ^1table^7, ^1possible error in that file^7?")
|
||||||
|
Jobs = {} -- Fallback to an empty table
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Save to global cache
|
-- Save to global cache
|
||||||
@@ -262,14 +283,11 @@ CreateThread(function()
|
|||||||
print("^6FrameworkCache^7: ^2Loaded ^5"..tostring(counts.Gangs).."^2 Gangs from ^7"..jobResource)
|
print("^6FrameworkCache^7: ^2Loaded ^5"..tostring(counts.Gangs).."^2 Gangs from ^7"..jobResource)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--print(json.encode(cache.Items , { indent = true}))
|
|
||||||
|
|
||||||
RegisterNetEvent("jim_bridge:requestCache", function()
|
RegisterNetEvent("jim_bridge:requestCache", function()
|
||||||
local src = source
|
local src = source
|
||||||
TriggerClientEvent("jim_bridge:receiveCache", src, _G.__jimBridgeDataCache)
|
TriggerClientEvent("jim_bridge:receiveCache", src, _G.__jimBridgeDataCache)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
exports("GetSharedData", function()
|
exports("GetSharedData", function()
|
||||||
-- Wait for data to be ready before returning it
|
-- Wait for data to be ready before returning it
|
||||||
local timeout = GetGameTimer() + 5000
|
local timeout = GetGameTimer() + 5000
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
name "Jim_Bridge"
|
name "Jim_Bridge"
|
||||||
author "Jimathy"
|
author "Jimathy"
|
||||||
version "2.0.15"
|
version "2.0.16"
|
||||||
description "Framework Bridge By Jimathy"
|
description "Framework Bridge By Jimathy"
|
||||||
fx_version "cerulean"
|
fx_version "cerulean"
|
||||||
rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships.'
|
rdr3_warning 'I acknowledge that this is a prerelease build of RedM, and I am aware my resources *will* become incompatible once RedM ships.'
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ OXLibExport, QBXExport, QBExport, ESXExport, OXCoreExport =
|
|||||||
Exports.ESXExport or "",
|
Exports.ESXExport or "",
|
||||||
Exports.OXCoreExport or ""
|
Exports.OXCoreExport or ""
|
||||||
|
|
||||||
OXInv, QBInv, PSInv, QSInv, CoreInv, CodeMInv, OrigenInv, TgiannInv =
|
OXInv, QBInv, PSInv, QSInv, CoreInv, CodeMInv, OrigenInv, TgiannInv, JPRInv =
|
||||||
Exports.OXInv or "",
|
Exports.OXInv or "",
|
||||||
Exports.QBInv or "",
|
Exports.QBInv or "",
|
||||||
Exports.PSInv or "",
|
Exports.PSInv or "",
|
||||||
@@ -18,7 +18,8 @@ OXInv, QBInv, PSInv, QSInv, CoreInv, CodeMInv, OrigenInv, TgiannInv =
|
|||||||
Exports.CoreInv or "",
|
Exports.CoreInv or "",
|
||||||
Exports.CodeMInv or "",
|
Exports.CodeMInv or "",
|
||||||
Exports.OrigenInv or "",
|
Exports.OrigenInv or "",
|
||||||
Exports.TgiannInv or ""
|
Exports.TgiannInv or "",
|
||||||
|
Exports.JPRInv or ""
|
||||||
|
|
||||||
RSGExport, RSGInv = Exports.RSGExport or "", Exports.RSGInv or ""
|
RSGExport, RSGInv = Exports.RSGExport or "", Exports.RSGInv or ""
|
||||||
QBMenuExport = Exports.QBMenuExport or ""
|
QBMenuExport = Exports.QBMenuExport or ""
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ function craftingMenu(data)
|
|||||||
|
|
||||||
-- Check if the player can carry the required items (server callback).
|
-- Check if the player can carry the required items (server callback).
|
||||||
local canCarryTable = triggerCallback(getScript()..':server:canCarry', tempCarryTable)
|
local canCarryTable = triggerCallback(getScript()..':server:canCarry', tempCarryTable)
|
||||||
|
|
||||||
-- Process each recipe to create menu entries.
|
-- Process each recipe to create menu entries.
|
||||||
for i = 1, #Recipes do
|
for i = 1, #Recipes do
|
||||||
if not Recipes[i]["amount"] then Recipes[i]["amount"] = 1 end
|
if not Recipes[i]["amount"] then Recipes[i]["amount"] = 1 end
|
||||||
@@ -106,10 +107,13 @@ function craftingMenu(data)
|
|||||||
local metaTable = {}
|
local metaTable = {}
|
||||||
-- Build ingredient details.
|
-- Build ingredient details.
|
||||||
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 "")
|
local label = Items[l] and Items[l].label or "error - "..l
|
||||||
|
local hasItem = checkStashItem(data.stashName, { [l] = b })
|
||||||
|
local missingMark = not hasItem and " ❌" or " "
|
||||||
|
settext = settext..(settext ~= "" and br or "").."[ x"..b.." ] - "..label..(b > 1 and " x"..b or "")..missingMark
|
||||||
|
|
||||||
metaTable[Items[l] and Items[l].label or "error - "..l] = b
|
metaTable[Items[l] and Items[l].label or "error - "..l] = b
|
||||||
itemTable[l] = b
|
itemTable[l] = b
|
||||||
--Wait(0)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
while not canCarryTable do Wait(0) end
|
while not canCarryTable do Wait(0) end
|
||||||
@@ -117,17 +121,17 @@ function craftingMenu(data)
|
|||||||
setheader = ((metadata and metadata.label) or (Items[tostring(k)] and Items[tostring(k)].label) or "error - "..tostring(k))
|
setheader = ((metadata and metadata.label) or (Items[tostring(k)] and Items[tostring(k)].label) or "error - "..tostring(k))
|
||||||
..(Recipes[i]["amount"] > 1 and " x"..Recipes[i]["amount"] or "")
|
..(Recipes[i]["amount"] > 1 and " x"..Recipes[i]["amount"] or "")
|
||||||
|
|
||||||
local statusEmoji = disable and " ❌" or not canCarryTable[k] and " 📦" or " ✔️"
|
local statusEmoji = disable and " " or not canCarryTable[k] and " 📦" or " ✔️"
|
||||||
local isNew = (Recipes[i]["hasCrafted"] ~= nil and craftedItems[k] == nil) and "✨ " or ""
|
local isNew = (Recipes[i]["hasCrafted"] ~= nil and craftedItems[k] == nil) and "✨ " or ""
|
||||||
setheader = isNew .. setheader .. statusEmoji
|
setheader = isNew .. setheader .. statusEmoji
|
||||||
|
|
||||||
Menu[#Menu + 1] = {
|
Menu[#Menu + 1] = {
|
||||||
arrow = not disable and canCarryTable[k],
|
arrow = isOx() and (not disable and canCarryTable[k]),
|
||||||
isMenuHeader = disable or not canCarryTable[k],
|
isMenuHeader = disable or not canCarryTable[k],
|
||||||
icon = invImg((metadata and metadata.image) or tostring(k)),
|
icon = invImg((metadata and metadata.image) or tostring(k)),
|
||||||
image = invImg((metadata and metadata.image) or tostring(k)),
|
image = invImg((metadata and metadata.image) or tostring(k)),
|
||||||
header = setheader,
|
header = setheader,
|
||||||
txt = (isStarted(QBMenuExport) or disable) and settext or nil,
|
txt = settext or nil,
|
||||||
metadata = metaTable,
|
metadata = metaTable,
|
||||||
onSelect = (not disable and canCarryTable[k]) and function()
|
onSelect = (not disable and canCarryTable[k]) and function()
|
||||||
local transdata = {
|
local transdata = {
|
||||||
|
|||||||
@@ -56,6 +56,25 @@ function isServer()
|
|||||||
return IsDuplicityVersion()
|
return IsDuplicityVersion()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function checkExportExists(resource, export)
|
||||||
|
if not resource or not export then return false end
|
||||||
|
|
||||||
|
local exists = false
|
||||||
|
local ok, result = pcall(function()
|
||||||
|
exists = type(exports[resource][export]) == "function"
|
||||||
|
end)
|
||||||
|
|
||||||
|
if ok and exists then
|
||||||
|
debugPrint(("^3Export Check^7: ^5exports^7['^5%s^7']:^5%s^7() ^2Exists^7"):format(resource, export))
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
debugPrint(("^3Export Check^7: ^5exports^7['^5%s^7']:^5%s^7() ^1Doesn^7'^1t Exist^7"):format(resource, export))
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-------------------------------------------------------------
|
-------------------------------------------------------------
|
||||||
-- Debugging and JSON Utilities
|
-- Debugging and JSON Utilities
|
||||||
-------------------------------------------------------------
|
-------------------------------------------------------------
|
||||||
@@ -474,7 +493,7 @@ end
|
|||||||
--- end
|
--- end
|
||||||
--- ```
|
--- ```
|
||||||
function ensureNetToVeh(vehNetID)
|
function ensureNetToVeh(vehNetID)
|
||||||
debugPrint("^6Bridge^7: ^3ensureNetToVeh^7: ^2Requesting NetworkDoesNetworkIdExist^7(^6"..vehNetID.."^7)")
|
--debugPrint("^6Bridge^7: ^3ensureNetToVeh^7: ^2Requesting NetworkDoesNetworkIdExist^7(^6"..vehNetID.."^7)")
|
||||||
local timeout = 100
|
local timeout = 100
|
||||||
while not NetworkDoesNetworkIdExist(vehNetID) and timeout > 0 do
|
while not NetworkDoesNetworkIdExist(vehNetID) and timeout > 0 do
|
||||||
timeout -= 1
|
timeout -= 1
|
||||||
@@ -502,7 +521,7 @@ end
|
|||||||
--- end
|
--- end
|
||||||
--- ```
|
--- ```
|
||||||
function ensureNetToEnt(entNetID)
|
function ensureNetToEnt(entNetID)
|
||||||
debugPrint("^6Bridge^7: ^3ensureNetToEnt^7: ^2Requesting NetworkDoesNetworkIdExist^7(^6"..entNetID.."^7)")
|
--debugPrint("^6Bridge^7: ^3ensureNetToEnt^7: ^2Requesting NetworkDoesNetworkIdExist^7(^6"..entNetID.."^7)")
|
||||||
local timeout = 100
|
local timeout = 100
|
||||||
while not NetworkDoesNetworkIdExist(entNetID) and timeout > 0 do
|
while not NetworkDoesNetworkIdExist(entNetID) and timeout > 0 do
|
||||||
timeout -= 1
|
timeout -= 1
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ function hasItem(items, amount, src)
|
|||||||
|
|
||||||
local count = 0
|
local count = 0
|
||||||
for _, itemData in pairs(grabInv) do
|
for _, itemData in pairs(grabInv) do
|
||||||
jsonPrint(itemData)
|
--jsonPrint(itemData)
|
||||||
if itemData and itemData.name == item then
|
if itemData and itemData.name == item then
|
||||||
count += (itemData.amount or itemData.count or 1)
|
count += (itemData.amount or itemData.count or 1)
|
||||||
end
|
end
|
||||||
@@ -138,6 +138,14 @@ function getPlayerInv(src)
|
|||||||
grabInv = exports[TgiannInv]:GetPlayerItems()
|
grabInv = exports[TgiannInv]:GetPlayerItems()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
elseif isStarted(JPRInv) then
|
||||||
|
foundInv = JPRInv
|
||||||
|
if src then
|
||||||
|
grabInv = Core.Functions.GetPlayer(src).PlayerData.items
|
||||||
|
else
|
||||||
|
grabInv = Core.Functions.GetPlayerData().items
|
||||||
|
end
|
||||||
|
|
||||||
elseif isStarted(QBInv) then
|
elseif isStarted(QBInv) then
|
||||||
foundInv = QBInv
|
foundInv = QBInv
|
||||||
if src then
|
if src then
|
||||||
@@ -148,8 +156,11 @@ function getPlayerInv(src)
|
|||||||
|
|
||||||
elseif isStarted(PSInv) then
|
elseif isStarted(PSInv) then
|
||||||
foundInv = PSInv
|
foundInv = PSInv
|
||||||
if src then grabInv = Core.Functions.GetPlayer(src).PlayerData.items
|
if src then
|
||||||
else grabInv = Core.Functions.GetPlayerData().items end
|
grabInv = Core.Functions.GetPlayer(src).PlayerData.items
|
||||||
|
else
|
||||||
|
grabInv = Core.Functions.GetPlayerData().items
|
||||||
|
end
|
||||||
|
|
||||||
elseif ESX and isStarted(ESXExport) then
|
elseif ESX and isStarted(ESXExport) then
|
||||||
foundInv = ESX
|
foundInv = ESX
|
||||||
@@ -179,41 +190,6 @@ function isInventoryOpen()
|
|||||||
|
|
||||||
return IsNuiFocused()
|
return IsNuiFocused()
|
||||||
|
|
||||||
--if isStarted(OXInv) then
|
|
||||||
-- return LocalPlayer.state.invBusy
|
|
||||||
|
|
||||||
--elseif isStarted(QSInv) then
|
|
||||||
-- return exports[QSInv]:inInventory()
|
|
||||||
|
|
||||||
--elseif isStarted(OrigenInv) then
|
|
||||||
-- return exports[OrigenInv]:IsInventoryOpen()
|
|
||||||
|
|
||||||
--elseif isStarted(CoreInv) then
|
|
||||||
-- return exports[CoreInv]:isInventoryOpen()
|
|
||||||
|
|
||||||
--elseif isStarted(CodeMInv) then
|
|
||||||
-- return false
|
|
||||||
-- -- CodeM doesn't have a function to check if the inventory is open
|
|
||||||
-- -- No idea what it uses, so it just skips the check
|
|
||||||
|
|
||||||
--elseif isStarted(TgiannInv) then
|
|
||||||
-- return IsNuiFocused()
|
|
||||||
|
|
||||||
--elseif isStarted(QBInv) then
|
|
||||||
-- return LocalPlayer.state.inv_busy
|
|
||||||
|
|
||||||
--elseif isStarted(PSInv) then
|
|
||||||
-- return LocalPlayer.state.inv_busy
|
|
||||||
|
|
||||||
--elseif ESX and isStarted(ESXExport) then
|
|
||||||
-- return false
|
|
||||||
|
|
||||||
--elseif isStarted(RSGInv) then
|
|
||||||
-- return LocalPlayer.state.inv_busy
|
|
||||||
|
|
||||||
--end
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------
|
-------------------------------------------------------------
|
||||||
@@ -248,12 +224,14 @@ function invImg(item)
|
|||||||
elseif isStarted(OrigenInv) then
|
elseif isStarted(OrigenInv) then
|
||||||
imgLink = "nui://"..OrigenInv.."/html/img/"..(Items[item].image or "")
|
imgLink = "nui://"..OrigenInv.."/html/img/"..(Items[item].image or "")
|
||||||
|
|
||||||
|
elseif isStarted(JPRInv) then
|
||||||
|
imgLink = "nui://"..JPRInv.."/html/images/"..(Items[item].image or "")
|
||||||
|
|
||||||
elseif isStarted(QBInv) then
|
elseif isStarted(QBInv) then
|
||||||
imgLink = "nui://"..QBInv.."/html/images/"..(Items[item].image or "")
|
imgLink = "nui://"..QBInv.."/html/images/"..(Items[item].image or "")
|
||||||
|
|
||||||
elseif isStarted(PSInv) then
|
elseif isStarted(PSInv) then
|
||||||
imgLink = "nui://"..PSInv.."/html/images/"..(Items[item].image or "")
|
imgLink = "nui://"..PSInv.."/html/images/"..(Items[item].image or "")
|
||||||
|
|
||||||
elseif isStarted(TgiannInv) then
|
elseif isStarted(TgiannInv) then
|
||||||
imgLink = "nui://inventory_images/images/"..(Items[item].image or "")
|
imgLink = "nui://inventory_images/images/"..(Items[item].image or "")
|
||||||
|
|
||||||
|
|||||||
@@ -186,6 +186,20 @@ RegisterNetEvent(getScript()..":server:toggleItem", function(give, item, amount,
|
|||||||
invName = TgiannInv
|
invName = TgiannInv
|
||||||
exports[TgiannInv]:RemoveItem(src, item, remamount)
|
exports[TgiannInv]:RemoveItem(src, item, remamount)
|
||||||
|
|
||||||
|
elseif isStarted(JPRInv) then
|
||||||
|
invName = JPRInv
|
||||||
|
while remamount > 0 do
|
||||||
|
if Core.Functions.GetPlayer(src).Functions.RemoveItem(item, 1, slot) then
|
||||||
|
remamount -= 1
|
||||||
|
else
|
||||||
|
print("^1Error removing "..item.." Amount left: "..remamount)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if Config.Crafting ~= nil and Config.Crafting.showItemBox then
|
||||||
|
TriggerClientEvent("inventory:client:ItemBox", src, Items[item], "remove", amount or 1)
|
||||||
|
end
|
||||||
|
|
||||||
elseif isStarted(QBInv) then
|
elseif isStarted(QBInv) then
|
||||||
invName = QBInv
|
invName = QBInv
|
||||||
while remamount > 0 do
|
while remamount > 0 do
|
||||||
@@ -196,7 +210,7 @@ RegisterNetEvent(getScript()..":server:toggleItem", function(give, item, amount,
|
|||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if Config.Crafting.showItemBox then
|
if Config.Crafting ~= nil and Config.Crafting.showItemBox then
|
||||||
TriggerClientEvent((isStarted(QBInv) and QBInvNew and "qb-" or "").."inventory:client:ItemBox", src, Items[item], "remove", amount or 1)
|
TriggerClientEvent((isStarted(QBInv) and QBInvNew and "qb-" or "").."inventory:client:ItemBox", src, Items[item], "remove", amount or 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -210,7 +224,7 @@ RegisterNetEvent(getScript()..":server:toggleItem", function(give, item, amount,
|
|||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if Config.Crafting.showItemBox then
|
if Config.Crafting ~= nil and Config.Crafting.showItemBox then
|
||||||
TriggerClientEvent("inventory:client:ItemBox", src, Items[item], "remove", amount or 1)
|
TriggerClientEvent("inventory:client:ItemBox", src, Items[item], "remove", amount or 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -223,7 +237,7 @@ RegisterNetEvent(getScript()..":server:toggleItem", function(give, item, amount,
|
|||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if Config.Crafting.showItemBox then
|
if Config.Crafting ~= nil and Config.Crafting.showItemBox then
|
||||||
TriggerClientEvent("rsg-inventory:client:ItemBox", src, Items[item], "remove", amount or 1)
|
TriggerClientEvent("rsg-inventory:client:ItemBox", src, Items[item], "remove", amount or 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -270,6 +284,13 @@ RegisterNetEvent(getScript()..":server:toggleItem", function(give, item, amount,
|
|||||||
elseif isStarted(TgiannInv) then invName = TgiannInv
|
elseif isStarted(TgiannInv) then invName = TgiannInv
|
||||||
exports[TgiannInv]:AddItem(src, item, amountToAdd, slot, info)
|
exports[TgiannInv]:AddItem(src, item, amountToAdd, slot, info)
|
||||||
|
|
||||||
|
elseif isStarted(JPRInv) then invName = JPRInv
|
||||||
|
if Core.Functions.GetPlayer(src).Functions.AddItem(item, amountToAdd, nil, info) then
|
||||||
|
if Config.Crafting ~= nil and Config.Crafting.showItemBox then
|
||||||
|
TriggerClientEvent("ps-inventory:client:ItemBox", src, Items[item], "add", amountToAdd)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
elseif isStarted(QBInv) then invName = QBInv
|
elseif isStarted(QBInv) then invName = QBInv
|
||||||
if Core.Functions.GetPlayer(src).Functions.AddItem(item, amountToAdd, nil, info) then
|
if Core.Functions.GetPlayer(src).Functions.AddItem(item, amountToAdd, nil, info) then
|
||||||
TriggerClientEvent((isStarted(QBInv) and QBInvNew and "qb-" or "").."inventory:client:ItemBox", src, Items[item], "add", amountToAdd)
|
TriggerClientEvent((isStarted(QBInv) and QBInvNew and "qb-" or "").."inventory:client:ItemBox", src, Items[item], "add", amountToAdd)
|
||||||
@@ -277,7 +298,7 @@ RegisterNetEvent(getScript()..":server:toggleItem", function(give, item, amount,
|
|||||||
|
|
||||||
elseif isStarted(PSInv) then invName = PSInv
|
elseif isStarted(PSInv) then invName = PSInv
|
||||||
if Core.Functions.GetPlayer(src).Functions.AddItem(item, amountToAdd, nil, info) then
|
if Core.Functions.GetPlayer(src).Functions.AddItem(item, amountToAdd, nil, info) then
|
||||||
if Config.Crafting.showItemBox then
|
if Config.Crafting ~= nil and Config.Crafting.showItemBox then
|
||||||
TriggerClientEvent("ps-inventory:client:ItemBox", src, Items[item], "add", amountToAdd)
|
TriggerClientEvent("ps-inventory:client:ItemBox", src, Items[item], "add", amountToAdd)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -379,7 +400,7 @@ end
|
|||||||
function getDurability(item)
|
function getDurability(item)
|
||||||
local lowestSlot = 100
|
local lowestSlot = 100
|
||||||
local durability = nil
|
local durability = nil
|
||||||
if isStarted(QBInv) or isStarted(PSInv) or isStarted(RSGInv) then
|
if isStarted(QBInv) or isStarted(PSInv) or isStarted(RSGInv) or isStarted(JPRInv) then
|
||||||
local itemcheck = Core.Functions.GetPlayerData().items
|
local itemcheck = Core.Functions.GetPlayerData().items
|
||||||
for k, v in pairs(itemcheck) do
|
for k, v in pairs(itemcheck) do
|
||||||
if v.name == item then
|
if v.name == item then
|
||||||
@@ -488,7 +509,7 @@ end
|
|||||||
--- ```
|
--- ```
|
||||||
RegisterNetEvent(getScript()..":server:setMetaData", function(data)
|
RegisterNetEvent(getScript()..":server:setMetaData", function(data)
|
||||||
local src = source
|
local src = source
|
||||||
if isStarted(QBInv) or isStarted(PSInv) or isStarted(RSGInv) then
|
if isStarted(QBInv) or isStarted(PSInv) or isStarted(RSGInv) or isStarted(JPRInv) then
|
||||||
debugPrint(src, data.item, 1, data.slot)
|
debugPrint(src, data.item, 1, data.slot)
|
||||||
local Player = Core.Functions.GetPlayer(src)
|
local Player = Core.Functions.GetPlayer(src)
|
||||||
Player.PlayerData.items[data.slot].info = data.metadata
|
Player.PlayerData.items[data.slot].info = data.metadata
|
||||||
@@ -626,6 +647,22 @@ function canCarry(itemTable, src)
|
|||||||
resultTable[k] = exports[TgiannInv]:CanCarryItem(source, k, v)
|
resultTable[k] = exports[TgiannInv]:CanCarryItem(source, k, v)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
elseif isStarted(JPRInv) then
|
||||||
|
local items = getPlayerInv(src)
|
||||||
|
local totalWeight = 0
|
||||||
|
if not items then return false end
|
||||||
|
for _, item in pairs(items) do
|
||||||
|
totalWeight += (item.weight * item.amount)
|
||||||
|
end
|
||||||
|
for k, v in pairs(itemTable) do
|
||||||
|
local itemInfo = Items[k]
|
||||||
|
if not itemInfo then
|
||||||
|
resultTable[k] = true
|
||||||
|
else
|
||||||
|
resultTable[k] = (totalWeight + (itemInfo.weight * v)) <= InventoryWeight
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
elseif isStarted(QBInv) then
|
elseif isStarted(QBInv) then
|
||||||
if QBInvNew then
|
if QBInvNew then
|
||||||
for k, v in pairs(itemTable) do
|
for k, v in pairs(itemTable) do
|
||||||
|
|||||||
@@ -231,3 +231,16 @@ function useDoor(data)
|
|||||||
DoScreenFadeIn(1000)
|
DoScreenFadeIn(1000)
|
||||||
Wait(100)
|
Wait(100)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function openBossMenu(isGang, group)
|
||||||
|
if isStarted("qb-management") then
|
||||||
|
if isGang then
|
||||||
|
TriggerEvent("qb-gangmenu:client:OpenMenu")
|
||||||
|
else
|
||||||
|
TriggerEvent("qb-bossmenu:client:OpenMenu")
|
||||||
|
end
|
||||||
|
elseif isStarted("qbx_management") then
|
||||||
|
exports["qbx_management"]:OpenBossMenu(isGang and "gang" or "job")
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -73,6 +73,11 @@ function sendPhoneMail(data)
|
|||||||
TriggerServerEvent('qb-phone:server:sendNewMail', mailData)
|
TriggerServerEvent('qb-phone:server:sendNewMail', mailData)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
{ name = "npwd_qbx_mail",
|
||||||
|
send = function(mailData)
|
||||||
|
TriggerServerEvent('qb-phone:server:sendNewMail', mailData)
|
||||||
|
end,
|
||||||
|
},
|
||||||
{ name = "jpr-phonesystem",
|
{ name = "jpr-phonesystem",
|
||||||
send = function(mailData)
|
send = function(mailData)
|
||||||
TriggerServerEvent(getScript()..":jpr:SendMail", mailData)
|
TriggerServerEvent(getScript()..":jpr:SendMail", mailData)
|
||||||
@@ -85,23 +90,125 @@ function sendPhoneMail(data)
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local activePhone = nil
|
|
||||||
-- Check each phone system in order and use the first active one.
|
-- Check each phone system in order and use the first active one.
|
||||||
for _, phone in ipairs(phoneSystems) do
|
for _, phone in ipairs(phoneSystems) do
|
||||||
if isStarted(phone.name) then
|
if isStarted(phone.name) then
|
||||||
activePhone = phone.name
|
debugPrint("^6Bridge^7[^3"..phone.name.."^7]: ^2Sending mail to player")
|
||||||
phone.send(data)
|
phone.send(data)
|
||||||
break
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if activePhone then
|
|
||||||
debugPrint("^6Bridge^7[^3"..activePhone.."^7]: ^2Sending mail to player")
|
|
||||||
else
|
|
||||||
print("^6Bridge^7: ^1ERROR ^2Sending mail to player ^7- ^2No supported phone found")
|
print("^6Bridge^7: ^1ERROR ^2Sending mail to player ^7- ^2No supported phone found")
|
||||||
end
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function sendPhoneInvoice(data)
|
||||||
|
if not data.src then return end
|
||||||
|
-- Define each supported phone system and its corresponding mail-sending function.
|
||||||
|
local phoneSystems = {
|
||||||
|
{
|
||||||
|
name = "qb-phone",
|
||||||
|
send = function(mailData)
|
||||||
|
-- Defensive check for required fields
|
||||||
|
local required = { "billedCitizenid", "amount", "job", "name", "billerCitizenid", "src" }
|
||||||
|
for _, field in ipairs(required) do
|
||||||
|
if mailData[field] == nil then
|
||||||
|
print("^1[jim-payments] ERROR:^0 Missing field '" .. field .. "' in mailData")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Safe insert with all parameters present
|
||||||
|
MySQL.Async.insert(
|
||||||
|
'INSERT INTO phone_invoices (citizenid, amount, society, sender, sendercitizenid) VALUES (?, ?, ?, ?, ?)',
|
||||||
|
{
|
||||||
|
mailData.billedCitizenid,
|
||||||
|
mailData.amount,
|
||||||
|
mailData.job,
|
||||||
|
mailData.name,
|
||||||
|
mailData.billerCitizenid
|
||||||
|
},
|
||||||
|
function(id)
|
||||||
|
if id then
|
||||||
|
TriggerClientEvent('qb-phone:client:AcceptorDenyInvoice', mailData.src, id, mailData.name, mailData.job, mailData.billerCitizenid, mailData.amount, GetInvokingResource())
|
||||||
|
end
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
|
TriggerClientEvent('qb-phone:RefreshPhone', mailData.src)
|
||||||
|
end
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = "codem-phone",
|
||||||
|
send = function(mailData)
|
||||||
|
-- Defensive check for required fields
|
||||||
|
local required = { "billedCitizenid", "amount", "job", "name", "billerCitizenid", "src" }
|
||||||
|
for _, field in ipairs(required) do
|
||||||
|
if mailData[field] == nil then
|
||||||
|
print("^1[jim-payments] ERROR:^0 Missing field '" .. field .. "' in mailData")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Safe insert with all parameters present
|
||||||
|
MySQL.Async.insert(
|
||||||
|
'INSERT INTO phone_invoices (citizenid, amount, society, sender, sendercitizenid) VALUES (?, ?, ?, ?, ?)',
|
||||||
|
{
|
||||||
|
mailData.billedCitizenid,
|
||||||
|
mailData.amount,
|
||||||
|
mailData.job,
|
||||||
|
mailData.name,
|
||||||
|
mailData.billerCitizenid
|
||||||
|
},
|
||||||
|
function(id)
|
||||||
|
-- if id then
|
||||||
|
-- TriggerClientEvent('qb-phone:client:AcceptorDenyInvoice', mailData.src, id, mailData.name, mailData.job, mailData.billerCitizenid, mailData.amount, GetInvokingResource())
|
||||||
|
-- end
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = "gks-phone",
|
||||||
|
send = function(mailData)
|
||||||
|
-- Defensive check for required fields
|
||||||
|
local required = { "billedCitizenid", "amount", "job", "name", "billerCitizenid", "label" }
|
||||||
|
for _, field in ipairs(required) do
|
||||||
|
if mailData[field] == nil then
|
||||||
|
print("^1[jim-payments] ERROR:^0 Missing field '" .. field .. "' in mailData")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
MySQL.Async.execute(
|
||||||
|
'INSERT INTO gksphone_invoices (citizenid, amount, society, sender, sendercitizenid, label) VALUES (@citizenid, @amount, @society, @sender, @sendercitizenid, @label)',
|
||||||
|
{
|
||||||
|
['@citizenid'] = mailData.billedCitizenid,
|
||||||
|
['@amount'] = mailData.amount,
|
||||||
|
['@society'] = mailData.job,
|
||||||
|
['@sender'] = mailData.name,
|
||||||
|
['@sendercitizenid'] = mailData.billerCitizenid,
|
||||||
|
['@label'] = mailData.label
|
||||||
|
}
|
||||||
|
)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
-- Check each phone system in order and use the first active one.
|
||||||
|
for _, phone in ipairs(phoneSystems) do
|
||||||
|
if isStarted(phone.name) then
|
||||||
|
debugPrint("^6Bridge^7[^3"..phone.name.."^7]: ^2Sending mail to player^7", data.src)
|
||||||
|
phone.send(data)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
print("^6Bridge^7: ^1ERROR ^2Sending mail to player ^7- ^2No supported phone found")
|
||||||
|
return false
|
||||||
|
end
|
||||||
-------------------------------------------------------------
|
-------------------------------------------------------------
|
||||||
-- Phone System Event Handlers
|
-- Phone System Event Handlers
|
||||||
-------------------------------------------------------------
|
-------------------------------------------------------------
|
||||||
|
|||||||
@@ -109,19 +109,18 @@ end)
|
|||||||
--- setThirst(playerId, 80)
|
--- setThirst(playerId, 80)
|
||||||
--- ```
|
--- ```
|
||||||
function setThirst(src, thirst)
|
function setThirst(src, thirst)
|
||||||
|
|
||||||
|
debugPrint("^4Debug^7: ^2Adding thirst^7: ^3"..thirst.." ^2to player^7: ^3"..src.."^7")
|
||||||
if isStarted(ESXExport) then
|
if isStarted(ESXExport) then
|
||||||
TriggerClientEvent('esx_status:add', src, 'thirst', thirst)
|
TriggerClientEvent('esx_status:add', src, 'thirst', thirst)
|
||||||
|
|
||||||
elseif isStarted(QBExport) or isStarted(QBXExport) then
|
elseif isStarted(QBExport) or isStarted(QBXExport) or isStarted(RSGExport) then
|
||||||
local Player = Core.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, Player.PlayerData.metadata.hunger, thirst)
|
||||||
|
|
||||||
elseif isStarted(RSGExport) then
|
|
||||||
local Player = Core.Functions.GetPlayer(src)
|
|
||||||
Player.Functions.SetMetaData('thirst', thirst)
|
|
||||||
TriggerClientEvent("hud:client:UpdateNeeds", src, thirst, Player.PlayerData.metadata.thirst)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Sets the player's hunger level.
|
--- Sets the player's hunger level.
|
||||||
@@ -134,18 +133,16 @@ end
|
|||||||
--- setHunger(playerId, 60)
|
--- setHunger(playerId, 60)
|
||||||
--- ```
|
--- ```
|
||||||
function setHunger(src, hunger)
|
function setHunger(src, hunger)
|
||||||
|
|
||||||
|
debugPrint("^4Debug^7: ^2Adding hunger^7: ^3"..hunger.." ^2to player^7: ^3"..src.."^7")
|
||||||
if isStarted(ESXExport) then
|
if isStarted(ESXExport) then
|
||||||
TriggerClientEvent('esx_status:add', src, 'hunger', hunger)
|
TriggerClientEvent('esx_status:add', src, 'hunger', hunger)
|
||||||
|
|
||||||
elseif isStarted(QBExport) or isStarted(QBXExport) then
|
elseif isStarted(QBExport) or isStarted(QBXExport) or isStarted(RSGExport) then
|
||||||
local Player = Core.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.thirst)
|
||||||
|
|
||||||
elseif isStarted(RSGExport) then
|
|
||||||
local Player = Core.Functions.GetPlayer(src)
|
|
||||||
Player.Functions.SetMetaData('hunger', hunger)
|
|
||||||
TriggerClientEvent("hud:client:UpdateNeeds", src, hunger, Player.PlayerData.metadata.hunger)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -153,6 +150,18 @@ end
|
|||||||
-- Economy Event Handlers
|
-- Economy Event Handlers
|
||||||
-------------------------------------------------------------
|
-------------------------------------------------------------
|
||||||
|
|
||||||
|
--- BillPlayer
|
||||||
|
function billPlayer(data)
|
||||||
|
if not Config.System.Billing or Config.System.Billing == "jim" then
|
||||||
|
TriggerEvent("jim-payments:client:Charge", {
|
||||||
|
job = data.job,
|
||||||
|
gang = data.gang,
|
||||||
|
coords = data.coords.xyz,
|
||||||
|
img = data.img
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--- Charges a player by removing money from their account.
|
--- Charges a player by removing money from their account.
|
||||||
---
|
---
|
||||||
--- @param cost number The amount to charge.
|
--- @param cost number The amount to charge.
|
||||||
|
|||||||
@@ -164,12 +164,16 @@ function openShop(data)
|
|||||||
elseif isStarted(OXInv) then
|
elseif isStarted(OXInv) then
|
||||||
exports[OXInv]:openInventory('shop', { type = data.shop })
|
exports[OXInv]:openInventory('shop', { type = data.shop })
|
||||||
|
|
||||||
elseif isStarted(QSInv) or isStarted(CodeMInv) then
|
elseif isStarted(QSInv) then
|
||||||
TriggerServerEvent("inventory:server:OpenInventory", "shop", data.items.label, data.items)
|
TriggerServerEvent("inventory:server:OpenInventory", "shop", data.items.label, data.items)
|
||||||
|
|
||||||
elseif isStarted(TgiannInv) then
|
elseif isStarted(TgiannInv) then
|
||||||
TriggerServerEvent(getScript()..':server:openServerShop', data.shop)
|
TriggerServerEvent(getScript()..':server:openServerShop', data.shop)
|
||||||
|
|
||||||
|
elseif isStarted(CodeMInv) then
|
||||||
|
--print(data.shop)
|
||||||
|
TriggerEvent("codem-inventory:openshop", data.shop)
|
||||||
|
|
||||||
elseif isStarted(QBInv) then
|
elseif isStarted(QBInv) then
|
||||||
if QBInvNew then
|
if QBInvNew then
|
||||||
TriggerServerEvent(getScript()..':server:openServerShop', data.shop)
|
TriggerServerEvent(getScript()..':server:openServerShop', data.shop)
|
||||||
|
|||||||
@@ -151,6 +151,22 @@ function openStash(data)
|
|||||||
slots = data.slots or 40
|
slots = data.slots or 40
|
||||||
})
|
})
|
||||||
|
|
||||||
|
elseif isStarted(JPRInv) then
|
||||||
|
if QBInvNew then
|
||||||
|
TriggerServerEvent(getScript()..':server:openServerStash', {
|
||||||
|
stashName = data.stash,
|
||||||
|
label = data.label,
|
||||||
|
maxweight = data.maxWeight or 600000,
|
||||||
|
slots = data.slots or 40
|
||||||
|
})
|
||||||
|
else
|
||||||
|
TriggerEvent("inventory:client:SetCurrentStash", data.stash)
|
||||||
|
TriggerServerEvent("inventory:server:OpenInventory", "stash", data.stash, {
|
||||||
|
slots = data.slots or 50,
|
||||||
|
maxWeight = data.maxWeight or 600000
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
elseif isStarted(QBInv) then
|
elseif isStarted(QBInv) then
|
||||||
if QBInvNew then
|
if QBInvNew then
|
||||||
TriggerServerEvent(getScript()..':server:openServerStash', {
|
TriggerServerEvent(getScript()..':server:openServerStash', {
|
||||||
@@ -211,6 +227,9 @@ RegisterNetEvent(getScript()..":server:openServerStash", function(data)
|
|||||||
if isStarted(TgiannInv) then
|
if isStarted(TgiannInv) then
|
||||||
exports[TgiannInv]:OpenInventory(source, 'stash', data.stashName, data)
|
exports[TgiannInv]:OpenInventory(source, 'stash', data.stashName, data)
|
||||||
end
|
end
|
||||||
|
if isStarted(JPRInv) then
|
||||||
|
exports[JPRInv]:OpenInventory(source, data.stashName, data)
|
||||||
|
end
|
||||||
if isStarted(QBInv) then
|
if isStarted(QBInv) then
|
||||||
exports[QBInv]:OpenInventory(source, data.stashName, data)
|
exports[QBInv]:OpenInventory(source, data.stashName, data)
|
||||||
end
|
end
|
||||||
@@ -223,7 +242,18 @@ RegisterNetEvent(getScript()..":server:openServerStash", function(data)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
function clearStash(stashId)
|
function clearStash(stashId)
|
||||||
if isStarted(QBInv) then
|
if isStarted(JPRInv) then
|
||||||
|
debugPrint("^5Bridge^7: ^2Cleared ^3"..JPRInv.."^2 Stash^7", stashId)
|
||||||
|
if QBInvNew then
|
||||||
|
exports[JPRInv]:ClearStash(stashId)
|
||||||
|
else
|
||||||
|
MySQL.Async.insert('INSERT INTO stashitems (stash, items) VALUES (:stash, :items) ON DUPLICATE KEY UPDATE items = :items', {
|
||||||
|
['stash'] = stashId,
|
||||||
|
['items'] = json.encode({})
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
elseif isStarted(QBInv) then
|
||||||
debugPrint("^5Bridge^7: ^2Cleared ^3"..QBInv.."^2 Stash^7", stashId)
|
debugPrint("^5Bridge^7: ^2Cleared ^3"..QBInv.."^2 Stash^7", stashId)
|
||||||
if QBInvNew then
|
if QBInvNew then
|
||||||
exports[QBInv]:ClearStash(stashId)
|
exports[QBInv]:ClearStash(stashId)
|
||||||
@@ -241,7 +271,7 @@ function clearStash(stashId)
|
|||||||
elseif isStarted(PSInv) then
|
elseif isStarted(PSInv) then
|
||||||
debugPrint("^5Bridge^7: ^2Cleared ^3"..PSInv.."^2 Stash^7", stashId)
|
debugPrint("^5Bridge^7: ^2Cleared ^3"..PSInv.."^2 Stash^7", stashId)
|
||||||
if QBInvNew then
|
if QBInvNew then
|
||||||
exports[QBInv]:ClearStash(stashId)
|
exports[PSInv]:ClearStash(stashId)
|
||||||
else
|
else
|
||||||
MySQL.Async.insert('INSERT INTO stashitems (stash, items) VALUES (:stash, :items) ON DUPLICATE KEY UPDATE items = :items', {
|
MySQL.Async.insert('INSERT INTO stashitems (stash, items) VALUES (:stash, :items) ON DUPLICATE KEY UPDATE items = :items', {
|
||||||
['stash'] = stashId,
|
['stash'] = stashId,
|
||||||
@@ -249,6 +279,7 @@ function clearStash(stashId)
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
elseif isStarted(QSInv) then
|
elseif isStarted(QSInv) then
|
||||||
debugPrint("^5Bridge^7: ^2Cleared ^3"..QSInv.."^2 Stash^7", stashId)
|
debugPrint("^5Bridge^7: ^2Cleared ^3"..QSInv.."^2 Stash^7", stashId)
|
||||||
exports[QSInv]:ClearOtherInventory('stash', stashId)
|
exports[QSInv]:ClearOtherInventory('stash', stashId)
|
||||||
@@ -331,6 +362,11 @@ function getStash(stashName)
|
|||||||
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
|
||||||
|
|
||||||
|
elseif isStarted(JPRInv) then
|
||||||
|
stashResource = JPRInv
|
||||||
|
local result = MySQL.scalar.await('SELECT items FROM stashitems WHERE stash = ?', { stashName })
|
||||||
|
if result then stashItems = json.decode(result) end
|
||||||
|
|
||||||
elseif isStarted(QBInv) then
|
elseif isStarted(QBInv) then
|
||||||
stashResource = QBInv
|
stashResource = QBInv
|
||||||
if QBInvNew then
|
if QBInvNew then
|
||||||
@@ -449,6 +485,29 @@ function stashRemoveItem(stashItems, stashName, items)
|
|||||||
debugPrint("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..TgiannInv, k, v)
|
debugPrint("^6Bridge^7: ^2Removing item from ^3Stash^2 with ^7"..TgiannInv, k, v)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
elseif isStarted(JPRInv) then
|
||||||
|
if not stashItems or not next(stashItems) then
|
||||||
|
stashItems = getStash(stashName[1])
|
||||||
|
end
|
||||||
|
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
|
||||||
|
debugPrint("^6Bridge^7: ^2None of this item left in stash ^3Stash^7", k, v)
|
||||||
|
stashItems[l] = nil
|
||||||
|
else
|
||||||
|
debugPrint("^6Bridge^7: ^2Removing item from ^3Stash^2 with "..JPRInv, k, v)
|
||||||
|
stashItems[l].amount -= v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
debugPrint("^6Bridge^7: ^3saveStash^7: ^2Saving ^3JPR^2 stash '^6"..stashName[1].."^7'")
|
||||||
|
MySQL.Async.insert('INSERT INTO stashitems (stash, items) VALUES (:stash, :items) ON DUPLICATE KEY UPDATE items = :items', {
|
||||||
|
['stash'] = stashName[1],
|
||||||
|
['items'] = json.encode(stashItems)
|
||||||
|
})
|
||||||
|
|
||||||
elseif isStarted(QBInv) then
|
elseif isStarted(QBInv) then
|
||||||
if QBInvNew then
|
if QBInvNew then
|
||||||
for k, v in pairs(items) do
|
for k, v in pairs(items) do
|
||||||
@@ -531,7 +590,7 @@ RegisterNetEvent(getScript()..":server:stashRemoveItem", stashRemoveItem)
|
|||||||
--- local hasAll, details = stashhasItem(currentStashItems, { iron = 2, wood = 5 })
|
--- local hasAll, details = stashhasItem(currentStashItems, { iron = 2, wood = 5 })
|
||||||
--- ```
|
--- ```
|
||||||
function stashhasItem(stashItems, items, amount)
|
function stashhasItem(stashItems, items, amount)
|
||||||
local invs = { OXInv, QSInv, CoreInv, CodeMInv, OrigenInv, TgiannInv, QBInv, PSInv, RSGInv }
|
local invs = { OXInv, QSInv, CoreInv, CodeMInv, OrigenInv, TgiannInv, JPRInv, QBInv, PSInv, RSGInv }
|
||||||
local foundInv = ""
|
local foundInv = ""
|
||||||
for _, inv in ipairs(invs) do
|
for _, inv in ipairs(invs) do
|
||||||
if isStarted(inv) then
|
if isStarted(inv) then
|
||||||
|
|||||||
15
starter.lua
15
starter.lua
@@ -14,6 +14,7 @@ Exports = {
|
|||||||
CodeMInv = "codem-inventory",
|
CodeMInv = "codem-inventory",
|
||||||
OrigenInv = "origen_inventory",
|
OrigenInv = "origen_inventory",
|
||||||
TgiannInv = "tgiann-inventory",
|
TgiannInv = "tgiann-inventory",
|
||||||
|
JPRInv = "jpr-inventory",
|
||||||
|
|
||||||
OXLibExport = "ox_lib",
|
OXLibExport = "ox_lib",
|
||||||
|
|
||||||
@@ -189,3 +190,17 @@ for _, v in pairs({ -- This is a specific load order
|
|||||||
print("^5CoreLoader^7: ^2loaded file^7: ^3"..(v):gsub("/", "^7/^3"):gsub("%.lua", "^7.lua").."^7")
|
print("^5CoreLoader^7: ^2loaded file^7: ^3"..(v):gsub("/", "^7/^3"):gsub("%.lua", "^7.lua").."^7")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if isStarted(QBInv) then
|
||||||
|
if not checkExportExists(QBInv, "HasItem") then
|
||||||
|
print("^6Bridge^7: ^2Can^7'^2t ^2find new QBInv export^7, ^2forcing ^1QBInvNew ^2to ^1false^7")
|
||||||
|
QBInvNew = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if isStarted(PSInv) then
|
||||||
|
if not checkExportExists(PSInv, "HasItem") then
|
||||||
|
print("^6Bridge^7: ^2Can^7't ^2find new PSInv export^7, ^2forcing ^1QBInvNew ^2to ^1false^7")
|
||||||
|
QBInvNew = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
20
version.txt
20
version.txt
@@ -1,12 +1,14 @@
|
|||||||
2.0.15
|
2.0.16
|
||||||
|
|
||||||
- Fix old PSInv/QBInv stashes being wiped when it should be updating them
|
- Fix weapon item caching for ox_inv
|
||||||
- Better breakout from opening inventory while crafting
|
- add checkExportExist() function
|
||||||
- Unify isInventoryOpen() function to simply check for IsNuiFocused()
|
- Start adding a `billPlayer()` function for multi-billing script support
|
||||||
- Add clearStash() and doesItemExist() functions for future use
|
- Add support for sending mails to npwd_qbx_mail addon
|
||||||
- Add warmenu.lua file for gta scaleform menus (loading is disabled by default)
|
- Add "support" for CoreM's shop integration
|
||||||
- Move custom GTA native notify, skillcheck, target to separate files, can be used outside the script
|
- Add Auto check for QBInvNew variable for older inventories
|
||||||
- Complete refactor of framework shared info loading, now only does it once and then shares to scripts
|
- Add warnings for if theres an error in your shared vehicles, items or jobs file
|
||||||
- Added extra checks for ESX loading, should hopefully stop the coreloader line 317 error
|
- Add full support for JPR-Inventory
|
||||||
|
- Changes to crafting menu ui
|
||||||
|
- Fixes to setThirst() and setHunger() functions
|
||||||
|
|
||||||
https://github.com/jimathy/jim_bridge
|
https://github.com/jimathy/jim_bridge
|
||||||
Reference in New Issue
Block a user