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 = {}
|
||||
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
|
||||
@@ -113,7 +113,6 @@ function Callback.Trigger(name, func, ...)
|
||||
cbData[name] = nil
|
||||
end
|
||||
end)
|
||||
print('Triggered')
|
||||
return Citizen.Await(p)
|
||||
end
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
Reference in new issue
Block a user