engineStreamingRequestModel | Multi Theft Auto: Wiki Skip to content

engineStreamingRequestModel

Client-side
Server-side
Shared

Pair: engineStreamingReleaseModel

Added in 1.6.0 r22676

This function sends a loading request to the game model streamer.

Note

This function has individual references counter for each resource. If you called engineStreamingRequestModel with increasing the counter twice, you should call engineStreamingReleaseModel twice to decrease the counter. MTA resets the counter after stopping a resource and calling engineFreeModel.

Syntax

bool engineStreamingRequestModel ( ​number modelID, [ ​bool addRef = false, ​bool isBlocking = false ] )
Required Arguments
  • modelID: ID of the model you want to load.
Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.

  • addRef (default: false): Increase references counter to prevent the model from unloading.
  • isBlocking (default: false): Load model immediately or use async loading.

Returns

  • bool: result

Returns true if a new request was created, false otherwise and throws error if invalid model ID is passed.

Code Examples

client

This example draws a model.

local modelId = 1337
local function drawMyModel()
dxDrawModel3D(modelId, 0, 0, 4, 0, 0, 0)
end
local function startDraw()
engineStreamingRequestModel(modelId, true, true)
addEventHandler("onClientPreRender", root, drawMyModel)
end
local function stopDraw()
engineStreamingReleaseModel(modelId, true)
removeEventHandler("onClientPreRender", root, drawMyModel)
end

See Also

Engine Functions