Merge pull request #31 from The-Order-Of-The-Sacred-Framework/dev

Dev Branch Sync
This commit is contained in:
MrNewb authored and GitHub committed 2025-02-17 10:34:58 -05:00
commit c233fae2a7
17 files changed
+175 -35

No files matched your search

+27 -1
View File
@@ -1,5 +1,6 @@
Scaleform = {}
local function SetupScaleform(scaleform, Buttons)
function SetupScaleform(scaleform, Buttons)
local scaleform = RequestScaleformMovie(scaleform)
local timeout = 5000
while not HasScaleformMovieLoaded(scaleform) and timeout > 0 do
@@ -46,8 +47,33 @@ function Scaleform.SetupInstructionalButtons(buttons)
-- {type = "SET_BACKGROUND_COLOUR"},
}
local scaleform = SetupScaleform("instructional_buttons", buttons)
return scaleform
end
local runningScaleform = nil
function Scaleform.Run(scaleform, onUpdate)
if runningScaleform then return end
runningScaleform = scaleform
CreateThread(function()
while runningScaleform do
DrawScaleformMovieFullscreen(scaleform, 255, 255, 255, 255, 0)
if onUpdate then
shouldQuit = onUpdate()
if shouldQuit then
Scaleform.Stop()
break
end
end
Wait(2)
end
end)
end
function Scaleform.Stop()
runningScaleform = nil
end
exports("Scaleform", Scaleform)
return Scaleform
-1
View File
@@ -113,7 +113,6 @@ function Callback.Trigger(name, func, ...)
cbData[name] = nil
end
end)
print('Triggered')
return Citizen.Await(p)
end
+16 -6
View File
@@ -14,10 +14,9 @@ function ReboundEntities.RemoveFunction(id)
registeredFunctions[id] = false
end
local function FireFunctions(...)
function FireFunctions(...)
for _, func in pairs(registeredFunctions) do
print(func)
if func then func(...) end
func(...)
end
end
@@ -25,7 +24,6 @@ function ReboundEntities.Register(entityData)
assert(entityData and entityData.position, "Invalid entity data")
entityData.id = entityData.id or Ids.CreateUniqueId(Entities)
entityData.isServer = isServer
entityData.id = tostring(entityData.id)
setmetatable(entityData, { __tostring = function() return entityData.id end })
Entities[entityData.id] = entityData
FireFunctions(entityData)
@@ -97,11 +95,13 @@ function ReboundEntities.Create(entityData, src)
return entity
end
function ReboundEntities.SetCheckRestricted(entityData, cb)
assert(type(cb) == "function", "Check restricted is not a function")
entityData.restricted = cb
end
function ReboundEntities.CheckRestricted(src, entityData)
return entityData.restricted and entityData.restricted(tonumber(src), entityData) or false
end
@@ -115,6 +115,15 @@ function ReboundEntities.Delete(id)
TriggerClientEvent(GetCurrentResourceName() .. ":client:DeleteReboundEntity", -1, id)
end
function ReboundEntities.DeleteMultiple(entityDatas)
local ids = {}
for _, data in pairs(entityDatas) do
Unregister(data.id)
table.insert(ids, data.id)
end
TriggerClientEvent(GetCurrentResourceName() .. ":client:DeleteReboundEntities", -1, ids)
end
function ReboundEntities.CreateMultiple(entityDatas, src, restricted)
local _entityDatas = {}
for _, data in pairs(entityDatas) do
@@ -218,7 +227,8 @@ function ReboundEntities.SpawnLoop(distanceToCheck, waitTime)
while spawnLoopRunning do
for _, entity in pairs(Entities) do
local pos = GetEntityCoords(PlayerPedId())
local dist = #(pos - entity.position)
local position = vector3(entity.position.x, entity.position.y, entity.position.z)
local dist = #(pos - position)
if dist <= distanceToCheck and not entity.entity then
entity.entity, entity.inRange = ReboundEntities.Spawn(entity)
elseif dist > distanceToCheck and entity.entity then
@@ -292,7 +302,7 @@ RegisterNetEvent(GetCurrentResourceName() .. ":client:CreateReboundEntities", fu
end)
RegisterNetEvent(GetCurrentResourceName() .. ":client:DeleteReboundEntities", function(ids)
DeleteMultipleFromServer(ids)
ReboundEntities.DeleteMultipleClient(ids)
end)
RegisterNetEvent(GetCurrentResourceName() .. ":client:SetReboundSyncData", function(id, key, value)
+20 -2
View File
@@ -54,14 +54,32 @@ function OxToQBInput(data)
end
function OpenInput(title, data, isQBFormat, submitText)
print("Opening input", json.encode(data))
local input = data.inputs
if not isQBFormat then
input = OxToQBInput(data)
end
return exports['qb-input']:ShowInput({
local returnData = exports['qb-input']:ShowInput({
header = title,
submitText = submitText or "Submit",
inputs = input
})
if not returnData then return end
if returnData[1] then return returnData end
--converting to standard format (ox)
local convertedData = {}
if isQBFormat then
for i, v in pairs(input) do
for k, j in pairs(returnData) do
if k == v.text then
convertedData[tonumber(i)] = j
end
end
end
return convertedData
end
for i, v in pairs(returnData) do
convertedData[tonumber(i)] = v
end
return convertedData
end
@@ -1,7 +0,0 @@
if GetResourceState('core_inventory') ~= 'started' then return end
Inventory = Inventory or {}
Inventory.TestFunction = function(item)
return 'test funct client inv'
end
@@ -1,7 +0,0 @@
if GetResourceState('core_inventory') ~= 'started' then return end
Inventory = Inventory or {}
Inventory.TestFunction = function(item)
return 'test funct server inv'
end
@@ -22,4 +22,16 @@ Inventory.GetItemBySlot = function(src, slot)
local slotData = jpr:GetItemBySlot(src, slot)
if not slotData then return {} end
return { name = slotData.name, label = slotData.label, weight = slotData.weight, slot = slot, count = slotData.amount, metadata = slotData.info, stack = slotData.unique, description = slotData.description }
end
Inventory.UpdatePlate = function(oldplate, newplate)
local queries = {
'UPDATE gloveboxitems SET plate = @newplate WHERE plate = @oldplate',
'UPDATE trunkitems SET plate = @newplate WHERE plate = @oldplate',
}
local values = { newplate = newplate, oldplate = oldplate }
MySQL.transaction.await(queries, values)
if GetResourceState('jg-mechanic') ~= 'started' then return true end
exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate)
return true
end
@@ -98,4 +98,16 @@ Inventory.GetImagePath = function(item)
local file = LoadResourceFile("origen_inventory", string.format("html/images/%s.png", item))
local imagePath = file and string.format("nui://origen_inventory/html/images/%s.png", item)
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
end
Inventory.UpdatePlate = function(oldplate, newplate)
local queries = {
'UPDATE gloveboxitems SET plate = @newplate WHERE plate = @oldplate',
'UPDATE trunkitems SET plate = @newplate WHERE plate = @oldplate',
}
local values = { newplate = newplate, oldplate = oldplate }
MySQL.transaction.await(queries, values)
if GetResourceState('jg-mechanic') ~= 'started' then return true end
exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate)
return true
end
+12
View File
@@ -35,3 +35,15 @@ Inventory.RemoveItem = function(src, item, amount, slot, metadata)
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "remove", item = item, count = amount, slot = slot, metadata = metadata})
return exports['ps-inventory']:RemoveItem(src, item, amount, slot, 'community_bridge')
end
Inventory.UpdatePlate = function(oldplate, newplate)
local queries = {
'UPDATE gloveboxitems SET plate = @newplate WHERE plate = @oldplate',
'UPDATE trunkitems SET plate = @newplate WHERE plate = @oldplate',
}
local values = { newplate = newplate, oldplate = oldplate }
MySQL.transaction.await(queries, values)
if GetResourceState('jg-mechanic') ~= 'started' then return true end
exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate)
return true
end
+28 -2
View File
@@ -5,8 +5,7 @@ local qbInventory = exports['qb-inventory']
Inventory = Inventory or {}
local function getInventoryNewVersion()
local version = GetResourceMetadata("qb-inventory", "version", 0)
if version and tonumber(version) < 2.0 then
if tonumber(string.sub(GetResourceMetadata("qb-inventory", "version", 0), 1, 1)) >= 2 then
return true
else
return false
@@ -42,6 +41,33 @@ Inventory.GetItemBySlot = function(src, slot)
}
end
Inventory.UpdatePlate = function(oldplate, newplate)
local newVersion = getInventoryNewVersion()
if newVersion then
local gloveboxInv = exports['qb-inventory']:GetInventory('glovebox-'..oldplate) or {slots = 5, maxweight = 10000, items = {}}
local storedGloveBox = Bridge.Tables.DeepClone(gloveboxInv, nil, nil)
local trunkInv = exports['qb-inventory']:GetInventory('trunk-'..oldplate) or {slots = 5, maxweight = 10000, items = {}}
local storedTrunk = Bridge.Tables.DeepClone(trunkInv, nil, nil)
exports['qb-inventory']:ClearStash('glovebox-'..oldplate)
exports['qb-inventory']:ClearStash('trunk-'..oldplate)
exports['qb-inventory']:CreateInventory('glovebox-'..newplate, {label = 'glovebox-'..newplate, slots = storedGloveBox.slots, maxweight = storedGloveBox.maxweight})
exports['qb-inventory']:SetInventory('glovebox-'..newplate, storedGloveBox.items, "Community Bridge Moving Items In GloveBox")
exports['qb-inventory']:CreateInventory('trunk-'..newplate, {label = 'trunk-'..newplate, slots = storedTrunk.slots, maxweight = storedTrunk.maxweight})
exports['qb-inventory']:SetInventory('trunk-'..newplate, storedTrunk.items, "Community Bridge Moving Items In Trunk")
return true
else
local queries = {
'UPDATE inventory_glovebox SET plate = @newplate WHERE plate = @oldplate',
'UPDATE inventory_trunk SET plate = @newplate WHERE plate = @oldplate',
}
local values = { newplate = newplate, oldplate = oldplate }
MySQL.transaction.await(queries, values)
end
if GetResourceState('jg-mechanic') ~= 'started' then return true end
exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate)
return true
end
Inventory.AddItem = function(src, item, amount, slot, metadata)
TriggerClientEvent('qb-inventory:client:ItemBox', src, QBCore.Shared.Items[item], 'add')
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "add", item = item, count = amount, slot = slot, metadata = metadata})
+12
View File
@@ -87,4 +87,16 @@ Inventory.GetImagePath = function(item)
local file = LoadResourceFile("qs-inventory", string.format("html/images/%s.png", item))
local imagePath = file and string.format("nui://qs-inventory/html/images/%s.png", item)
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
end
Inventory.UpdatePlate = function(oldplate, newplate)
local queries = {
'UPDATE inventory_trunk SET plate = @newplate WHERE plate = @oldplate',
'UPDATE inventory_glovebox SET plate = @newplate WHERE plate = @oldplate',
}
local values = { newplate = newplate, oldplate = oldplate }
MySQL.transaction.await(queries, values)
if GetResourceState('jg-mechanic') ~= 'started' then return true end
exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate)
return true
end
@@ -75,4 +75,16 @@ Inventory.GetImagePath = function(item)
local webpPath = LoadResourceFile("inventory_images", string.format("html/images/%s.webp", item))
local imagePath = pngPath and string.format("nui://inventory_images/html/images/%s.png", item) or webpPath and string.format("nui://inventory_images/html/images/%s.webp", item)
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
end
Inventory.UpdatePlate = function(oldplate, newplate)
local queries = {
'UPDATE tgiann_inventory_trunkitems SET plate = @newplate WHERE plate = @oldplate',
'UPDATE tgiann_inventory_gloveboxitems SET plate = @newplate WHERE plate = @oldplate',
}
local values = { newplate = newplate, oldplate = oldplate }
MySQL.transaction.await(queries, values)
if GetResourceState('jg-mechanic') ~= 'started' then return true end
exports["jg-mechanic"]:vehiclePlateUpdated(oldplate, newplate)
return true
end
+1 -3
View File
@@ -47,9 +47,7 @@ OpenMenu = function(id, data, useQBinput)
if useQBinput then
data = QBToOxMenu(id, data)
end
if not Menus[id] then
lib.registerContext(data)
end
lib.registerContext(data)
lib.showContext(id)
return data
end
@@ -2,7 +2,7 @@ if GetResourceState('MrNewbVehicleKeys') ~= 'started' then return end
VehicleKey = VehicleKey or {}
VehicleKey.GiveKeys = function(vehicle, plate)
if not DoesEntityExist(vehicle) then return false end
if not DoesEntityExist(vehicle) and not plate then return false end
return exports.MrNewbVehicleKeys:GiveKeys(vehicle)
end
@@ -2,9 +2,19 @@ if GetResourceState('MrNewbVehicleKeys') ~= 'started' then return end
VehicleKey = VehicleKey or {}
VehicleKey.GiveKeys = function(src, vehicle, plate)
--wip
if vehicle then
local netId = NetworkGetNetworkIdFromEntity(vehicle)
return exports.MrNewbVehicleKeys:GiveKeys(src, netId)
elseif plate then
return exports.MrNewbVehicleKeys:GiveKeysByPlate(src, plate)
end
end
VehicleKey.RemoveKeys = function(src, vehicle, plate)
-- wip
if vehicle then
local netId = NetworkGetNetworkIdFromEntity(vehicle)
return exports.MrNewbVehicleKeys:RemoveKeys(src, netId)
elseif plate then
return exports.MrNewbVehicleKeys:RemoveKeysByPlate(src, plate)
end
end
@@ -3,9 +3,12 @@ if GetResourceState('qbx_vehiclekeys') == 'started' then return end
VehicleKey = VehicleKey or {}
VehicleKey.GiveKeys = function(vehicle, plate)
if plate == nil and vehicle and DoesEntityExist(vehicle) then
plate = GetVehicleNumberPlateText(vehicle)
end
TriggerServerEvent('qb-vehiclekeys:server:AcquireVehicleKeys', plate)
end
VehicleKey.RemoveKeys = function(vehicle, plate)
return true
TriggerEvent('qb-vehiclekeys:client:RemoveKeys', plate)
end
@@ -3,9 +3,13 @@ if GetResourceState('qbx_vehiclekeys') == 'started' then return end
VehicleKey = VehicleKey or {}
VehicleKey.GiveKeys = function(src, vehicle, plate)
--wip
if plate then
return exports["qb-vehiclekeys"]:GiveKeys(src, plate)
end
end
VehicleKey.RemoveKeys = function(src, vehicle, plate)
-- wip
if plate then
return exports["qb-vehiclekeys"]:RemoveKeys(src, plate)
end
end