streamingRequest
The generic "request an asset, wait until ready, throw on timeout" engine behind every request* helper.
The generic "request an asset, wait until ready, throw on timeout" engine behind every request* helper.
lib.streamingRequest(request, hasLoaded, assetType, asset, timeout?, ...) is the generic engine behind
requestModel, requestAnimDict and requestAnimSet. Use it directly for any Request* /
Has*Loaded native pair that isn't wrapped yet — IPLs, streamed texture dicts, and so on.
-- An asset not covered by the wrappers
lib.streamingRequest(RequestIpl, IsIplActive, 'ipl', 'GTAO_Pen_Int_Yacht_Bar', 10000)
-- Streamed texture dict (flag passed as a variadic arg)
lib.streamingRequest(
RequestStreamedTextureDict, HasStreamedTextureDictLoaded,
'textureDict', 'commonmenu', 5000, false
)requestfunctionrequiredThe Request* native to call, e.g. RequestIpl.
hasLoadedfunctionrequiredThe matching Has*Loaded native, e.g. IsIplActive.
assetTypestringrequiredLabel used in the error message ('model', 'ipl', 'textureDict'…).
assetanyrequiredThe asset handle / name to load (model hash, dict name…).
timeoutnumberoptionalMax wait in ms before it throws. Default 30000.
...anyoptionalExtra args forwarded to request — useful for natives that take flags.
It runs three steps: short-circuit if the asset is already loaded (no redundant native call), call
request, then poll each frame via lib.waitFor until hasLoaded returns true or the timeout fires.
Returns the asset once loaded.
It only loads — releasing the asset (SetModelAsNoLongerNeeded, RemoveAnimDict…) is up to you.
It must run inside a Citizen thread (CreateThread, event handler), since it yields via lib.waitFor.
The default 30000 ms timeout is long: lower it to fail fast on light assets, and wrap the call in
pcall if a timeout must be caught instead of killing the thread.