mirror of
https://github.com/jimathy/jim_bridge.git
synced 2026-08-17 05:56:02 +01:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e9bbdd4ce0 | ||
|
|
f5a7ec9291 | ||
|
|
d80ea38a39 | ||
|
|
e64912622b | ||
|
|
04b25e2c06 |
@@ -1,6 +1,6 @@
|
|||||||
name "Jim_Bridge"
|
name "Jim_Bridge"
|
||||||
author "Jimathy"
|
author "Jimathy"
|
||||||
version "2.0.09"
|
version "2.0.10"
|
||||||
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.'
|
||||||
|
|||||||
@@ -50,7 +50,13 @@ function onPlayerLoaded(func, onStart)
|
|||||||
AddEventHandler('QBCore:Client:OnPlayerLoaded', tempFunc)
|
AddEventHandler('QBCore:Client:OnPlayerLoaded', tempFunc)
|
||||||
elseif isStarted(ESXExport) then
|
elseif isStarted(ESXExport) then
|
||||||
onPlayerFramework = ESXExport
|
onPlayerFramework = ESXExport
|
||||||
AddEventHandler('esx:playerLoaded', tempFunc)
|
AddEventHandler('esx:playerLoaded', function()
|
||||||
|
if waitForSharedLoad() then
|
||||||
|
if isStarted(ESXExport) then Wait(11000) end
|
||||||
|
tempFunc()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
)
|
||||||
elseif isStarted(OXCoreExport) then
|
elseif isStarted(OXCoreExport) then
|
||||||
onPlayerFramework = OXCoreExport
|
onPlayerFramework = OXCoreExport
|
||||||
AddEventHandler('ox:playerLoaded', tempFunc)
|
AddEventHandler('ox:playerLoaded', tempFunc)
|
||||||
@@ -103,7 +109,11 @@ function onResourceStart(func, thisScript)
|
|||||||
debugPrint("^6Bridge^7: ^2Registering ^3onResourceStart^7()")
|
debugPrint("^6Bridge^7: ^2Registering ^3onResourceStart^7()")
|
||||||
AddEventHandler('onResourceStart', function(resourceName)
|
AddEventHandler('onResourceStart', function(resourceName)
|
||||||
if getScript() == resourceName and (thisScript or true) then
|
if getScript() == resourceName and (thisScript or true) then
|
||||||
func()
|
if waitForSharedLoad() then
|
||||||
|
print("^6Bridge^7: ^2Shared Load Detected^7.")
|
||||||
|
if isStarted(ESXExport) then Wait(10000) end
|
||||||
|
func()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
@@ -174,4 +184,26 @@ function waitForLogin()
|
|||||||
debugPrint("^6Bridge^7: ^2Player Login Detected^7.")
|
debugPrint("^6Bridge^7: ^2Player Login Detected^7.")
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function waitForSharedLoad()
|
||||||
|
local timeout = 100000 -- 10 seconds in milliseconds
|
||||||
|
local startTime = GetGameTimer()
|
||||||
|
local loaded = true
|
||||||
|
while ((not Jobs or not next(Jobs)) and (not Items or not next(Items)) and (not Vehicles or not next(Vehicles))) and (GetGameTimer() - startTime) < timeout do
|
||||||
|
print((GetGameTimer() - startTime) < timeout)
|
||||||
|
Wait(1000)
|
||||||
|
debugPrint("Waiting for Jobs, Items, and Vehicles to be loaded")
|
||||||
|
if Jobs and Items and Vehicles then
|
||||||
|
print("^6Bridge^7: ^2Jobs, Items, and Vehicles Loaded^7.")
|
||||||
|
loaded = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not loaded then
|
||||||
|
print("^4Error^7: ^2Timeout reached while waiting for shared load^7.")
|
||||||
|
return false
|
||||||
|
else
|
||||||
|
return true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
@@ -353,8 +353,8 @@ function makeItem(data)
|
|||||||
Wait(200)
|
Wait(200)
|
||||||
end
|
end
|
||||||
if isInventoryOpen() then
|
if isInventoryOpen() then
|
||||||
print("^1Error^7: ^2Inventory is open, you tried to break things")
|
--print("^1Error^7: ^2Inventory is open, you tried to break things")
|
||||||
crafted, crafting = false, false
|
crafted, crafting, CraftLock = false, false, false
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if crafted then
|
if crafted then
|
||||||
@@ -368,8 +368,9 @@ function makeItem(data)
|
|||||||
PlaySoundFromEntity(s.soundId, s.audioName, PlayerPedId(), s.audioRef, true, 0)
|
PlaySoundFromEntity(s.soundId, s.audioName, PlayerPedId(), s.audioRef, true, 0)
|
||||||
end
|
end
|
||||||
if isInventoryOpen() then
|
if isInventoryOpen() then
|
||||||
print("^1Error^7: ^2Inventory is open, you tried to break things")
|
--print("^1Error^7: ^2Inventory is open, you tried to break things")
|
||||||
crafted, crafting = false, false
|
crafted, crafting = false, false
|
||||||
|
crafted, crafting, CraftLock = false, false, false
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if crafting and progressBar({
|
if crafting and progressBar({
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ end
|
|||||||
--- ```
|
--- ```
|
||||||
function countTable(tbl)
|
function countTable(tbl)
|
||||||
local i = 0
|
local i = 0
|
||||||
for _ in pairs(tbl) do i = i + 1 end
|
for _ in pairs(tbl) do i += 1 end
|
||||||
return i
|
return i
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,8 @@ function getPlayerInv(src)
|
|||||||
if src then
|
if src then
|
||||||
grabInv = exports[QSInv]:GetInventory(src)
|
grabInv = exports[QSInv]:GetInventory(src)
|
||||||
else
|
else
|
||||||
grabInv = exports[QSInv]:getUserInventory()
|
--grabInv = exports[QSInv]:getUserInventory()
|
||||||
|
grabInv = triggerCallback(getScript().."getServerInvData", GetPlayerServerId(PlayerId()))
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif isStarted(OrigenInv) then
|
elseif isStarted(OrigenInv) then
|
||||||
@@ -171,6 +172,10 @@ function getPlayerInv(src)
|
|||||||
return grabInv, foundInv
|
return grabInv, foundInv
|
||||||
end
|
end
|
||||||
|
|
||||||
|
createCallback(getScript()..":getServerInvData", function(source)
|
||||||
|
local src = source
|
||||||
|
return getPlayerInv(src)
|
||||||
|
end)
|
||||||
|
|
||||||
function isInventoryOpen()
|
function isInventoryOpen()
|
||||||
if isStarted(OXInv) then
|
if isStarted(OXInv) then
|
||||||
|
|||||||
@@ -48,7 +48,9 @@ function sellMenu(data)
|
|||||||
header = k,
|
header = k,
|
||||||
txt = "Amount of items: "..countTable(v.Items),
|
txt = "Amount of items: "..countTable(v.Items),
|
||||||
onSelect = function()
|
onSelect = function()
|
||||||
v.onBack = function() sellMenu(origData) end
|
v.onBack = function()
|
||||||
|
sellMenu(origData)
|
||||||
|
end
|
||||||
v.sellTable = data.sellTable[k]
|
v.sellTable = data.sellTable[k]
|
||||||
sellMenu(v)
|
sellMenu(v)
|
||||||
end,
|
end,
|
||||||
@@ -57,8 +59,8 @@ function sellMenu(data)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
openMenu(Menu, {
|
openMenu(Menu, {
|
||||||
header = data.sellTable.Header or "Amount of items: "..countTable(data.sellTable.Items),
|
header = data.sellTable.Header or "Amount of items: "..countTable(data.sellTable.Items or data.sellTable),
|
||||||
headertxt = data.sellTable.Header and "Amount of items: "..countTable(data.sellTable.Items) or "",
|
headertxt = data.sellTable.Header and "Amount of items: "..countTable(data.sellTable.Items or data.sellTable),
|
||||||
canClose = true,
|
canClose = true,
|
||||||
onBack = data.onBack,
|
onBack = data.onBack,
|
||||||
})
|
})
|
||||||
@@ -105,12 +107,14 @@ function sellAnim(data)
|
|||||||
TriggerServerEvent(getScript().."Sellitems", data)
|
TriggerServerEvent(getScript().."Sellitems", data)
|
||||||
lookEnt(data.ped)
|
lookEnt(data.ped)
|
||||||
local dict = "mp_common"
|
local dict = "mp_common"
|
||||||
playAnim(dict, "givetake2_a", 0.3, 2)
|
playAnim(dict, "givetake2_a", 0.3, 48)
|
||||||
playAnim(dict, "givetake2_b", 0.3, 2, data.ped)
|
playAnim(dict, "givetake2_b", 0.3, 48, data.ped)
|
||||||
Wait(2000)
|
Wait(2000)
|
||||||
StopAnimTask(PlayerPedId(), dict, "givetake2_a", 0.5)
|
StopAnimTask(PlayerPedId(), dict, "givetake2_a", 0.5)
|
||||||
StopAnimTask(data.ped, dict, "givetake2_b", 0.5)
|
StopAnimTask(data.ped, dict, "givetake2_b", 0.5)
|
||||||
if data.onBack then data.onBack() end
|
if data.onBack then
|
||||||
|
data.onBack()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Server event handler for processing item sales.
|
--- Server event handler for processing item sales.
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
2.0.09
|
2.0.10
|
||||||
Reference in New Issue
Block a user