Asset streaming — loading models, animations, textures and collision before you use them.

GTA loads almost nothing up front. Spawning a vehicle whose model isn't resident produces handle 0; playing an animation from an unloaded dictionary silently does nothing. Every request here blocks the calling coroutine until the asset is resident and returns whether it succeeded:

if (Streaming.requestAnimDict("amb@world_human_smoking@male@male_a@base")) {
    ped.playAnim("amb@world_human_smoking@male@male_a@base", "base", 49);
}

The Vehicle.create / Ped.create / Prop.create helpers already do this for you; call these directly for animations, textures and collision.

Every loaded asset holds memory until released. The create helpers release the model as soon as the entity exists — the entity keeps its own reference, so this is safe and stops the resource from pinning every model it has ever spawned.

Static methods

staticinlineisModelLoaded(model:Hash):Bool

staticinlineisModelValid(model:Hash):Bool

Whether the hash names a model the game actually ships or a resource streams.

staticinlinereleaseAnimDict(dict:String):Void

staticinlinereleaseModel(model:Hash):Void

Tells the game the model can be evicted once nothing references it. Safe to call immediately after spawning — the spawned entity holds its own reference.

@:value({ timeoutMs : 5000 })staticrequestAnimDict(dict:String, timeoutMs:Int = 5000):Bool

Streams an animation dictionary in.

@:value({ timeoutMs : 5000 })staticrequestCollisionAt(position:Vector3, ?entity:Entity, timeoutMs:Int = 5000):Bool

Forces the collision mesh around a point to load, then waits for it.

Worth doing before teleporting a player somewhere distant: without collision the ground isn't there yet and they fall through the map. Pass the entity being moved so the wait can check the right thing.

@:value({ timeoutMs : 10000 })staticrequestModel(model:Hash, timeoutMs:Int = 10000):Bool

Streams a model in.

Parameters:

timeoutMs

How long to wait before giving up. The default is generous because a cold disk on a slow client genuinely takes seconds for large vehicle models.

Returns:

False if the model is invalid or didn't load in time.

@:value({ timeoutMs : 5000 })staticrequestPtfxAsset(assetName:String, timeoutMs:Int = 5000):Bool

Streams a particle effect asset in, for use with the PTFX natives.

@:value({ timeoutMs : 5000 })staticrequestTextureDict(dict:String, timeoutMs:Int = 5000):Bool

Streams a texture dictionary in — needed before drawing sprites or textured markers.