resonable changes
minor tweeks for qol and some bug fixes Registering menus caused data to not be updated when retrieving new info/variables func check was redundent removed some prints added scaleform run loop for qol
This commit is contained in:
1 parent
6e93ac2b47
commit
0212c21487
4 files changed
+44
-11
No files matched your search
@@ -1,5 +1,6 @@
|
|||||||
Scaleform = {}
|
Scaleform = {}
|
||||||
local function SetupScaleform(scaleform, Buttons)
|
|
||||||
|
function SetupScaleform(scaleform, Buttons)
|
||||||
local scaleform = RequestScaleformMovie(scaleform)
|
local scaleform = RequestScaleformMovie(scaleform)
|
||||||
local timeout = 5000
|
local timeout = 5000
|
||||||
while not HasScaleformMovieLoaded(scaleform) and timeout > 0 do
|
while not HasScaleformMovieLoaded(scaleform) and timeout > 0 do
|
||||||
@@ -46,8 +47,33 @@ function Scaleform.SetupInstructionalButtons(buttons)
|
|||||||
-- {type = "SET_BACKGROUND_COLOUR"},
|
-- {type = "SET_BACKGROUND_COLOUR"},
|
||||||
}
|
}
|
||||||
local scaleform = SetupScaleform("instructional_buttons", buttons)
|
local scaleform = SetupScaleform("instructional_buttons", buttons)
|
||||||
|
|
||||||
return scaleform
|
return scaleform
|
||||||
end
|
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)
|
exports("Scaleform", Scaleform)
|
||||||
return Scaleform
|
return Scaleform
|
||||||
@@ -113,7 +113,6 @@ function Callback.Trigger(name, func, ...)
|
|||||||
cbData[name] = nil
|
cbData[name] = nil
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
print('Triggered')
|
|
||||||
return Citizen.Await(p)
|
return Citizen.Await(p)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -14,10 +14,9 @@ function ReboundEntities.RemoveFunction(id)
|
|||||||
registeredFunctions[id] = false
|
registeredFunctions[id] = false
|
||||||
end
|
end
|
||||||
|
|
||||||
local function FireFunctions(...)
|
function FireFunctions(...)
|
||||||
for _, func in pairs(registeredFunctions) do
|
for _, func in pairs(registeredFunctions) do
|
||||||
print(func)
|
func(...)
|
||||||
if func then func(...) end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -25,7 +24,6 @@ function ReboundEntities.Register(entityData)
|
|||||||
assert(entityData and entityData.position, "Invalid entity data")
|
assert(entityData and entityData.position, "Invalid entity data")
|
||||||
entityData.id = entityData.id or Ids.CreateUniqueId(Entities)
|
entityData.id = entityData.id or Ids.CreateUniqueId(Entities)
|
||||||
entityData.isServer = isServer
|
entityData.isServer = isServer
|
||||||
entityData.id = tostring(entityData.id)
|
|
||||||
setmetatable(entityData, { __tostring = function() return entityData.id end })
|
setmetatable(entityData, { __tostring = function() return entityData.id end })
|
||||||
Entities[entityData.id] = entityData
|
Entities[entityData.id] = entityData
|
||||||
FireFunctions(entityData)
|
FireFunctions(entityData)
|
||||||
@@ -97,11 +95,13 @@ function ReboundEntities.Create(entityData, src)
|
|||||||
return entity
|
return entity
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function ReboundEntities.SetCheckRestricted(entityData, cb)
|
function ReboundEntities.SetCheckRestricted(entityData, cb)
|
||||||
assert(type(cb) == "function", "Check restricted is not a function")
|
assert(type(cb) == "function", "Check restricted is not a function")
|
||||||
entityData.restricted = cb
|
entityData.restricted = cb
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function ReboundEntities.CheckRestricted(src, entityData)
|
function ReboundEntities.CheckRestricted(src, entityData)
|
||||||
return entityData.restricted and entityData.restricted(tonumber(src), entityData) or false
|
return entityData.restricted and entityData.restricted(tonumber(src), entityData) or false
|
||||||
end
|
end
|
||||||
@@ -115,6 +115,15 @@ function ReboundEntities.Delete(id)
|
|||||||
TriggerClientEvent(GetCurrentResourceName() .. ":client:DeleteReboundEntity", -1, id)
|
TriggerClientEvent(GetCurrentResourceName() .. ":client:DeleteReboundEntity", -1, id)
|
||||||
end
|
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)
|
function ReboundEntities.CreateMultiple(entityDatas, src, restricted)
|
||||||
local _entityDatas = {}
|
local _entityDatas = {}
|
||||||
for _, data in pairs(entityDatas) do
|
for _, data in pairs(entityDatas) do
|
||||||
@@ -218,7 +227,8 @@ function ReboundEntities.SpawnLoop(distanceToCheck, waitTime)
|
|||||||
while spawnLoopRunning do
|
while spawnLoopRunning do
|
||||||
for _, entity in pairs(Entities) do
|
for _, entity in pairs(Entities) do
|
||||||
local pos = GetEntityCoords(PlayerPedId())
|
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
|
if dist <= distanceToCheck and not entity.entity then
|
||||||
entity.entity, entity.inRange = ReboundEntities.Spawn(entity)
|
entity.entity, entity.inRange = ReboundEntities.Spawn(entity)
|
||||||
elseif dist > distanceToCheck and entity.entity then
|
elseif dist > distanceToCheck and entity.entity then
|
||||||
@@ -292,7 +302,7 @@ RegisterNetEvent(GetCurrentResourceName() .. ":client:CreateReboundEntities", fu
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNetEvent(GetCurrentResourceName() .. ":client:DeleteReboundEntities", function(ids)
|
RegisterNetEvent(GetCurrentResourceName() .. ":client:DeleteReboundEntities", function(ids)
|
||||||
DeleteMultipleFromServer(ids)
|
ReboundEntities.DeleteMultipleClient(ids)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNetEvent(GetCurrentResourceName() .. ":client:SetReboundSyncData", function(id, key, value)
|
RegisterNetEvent(GetCurrentResourceName() .. ":client:SetReboundSyncData", function(id, key, value)
|
||||||
|
|||||||
@@ -47,9 +47,7 @@ OpenMenu = function(id, data, useQBinput)
|
|||||||
if useQBinput then
|
if useQBinput then
|
||||||
data = QBToOxMenu(id, data)
|
data = QBToOxMenu(id, data)
|
||||||
end
|
end
|
||||||
if not Menus[id] then
|
lib.registerContext(data)
|
||||||
lib.registerContext(data)
|
|
||||||
end
|
|
||||||
lib.showContext(id)
|
lib.showContext(id)
|
||||||
return data
|
return data
|
||||||
end
|
end
|
||||||
Reference in new issue
Block a user