engineSetModelLODDistance | Multi Theft Auto: Wiki Skip to content

engineSetModelLODDistance

Client-side
Server-side
Shared

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


This function sets a custom LOD distance for any object / model ID. This is the distance at which objects of that model ID are switched to their LOD model, or (if there is no LOD model) become invisible.

OOP Syntax Help! I don't understand this!

  • Method: Engine.setModelLODDistance(...)

Syntax

bool engineSetModelLODDistance ( int model, float distance, [ bool extendedLod = false ] )
Required Arguments
  • model: The model / object ID number you want to change the LOD distance of.
  • distance: New LOD distance value in San Andreas units.
Optional Arguments

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

  • extendedLod (default: false): MISSING_PARAM_DESC

Returns

  • bool: value

Returns true if the function executed succesfully, false otherwise.

Code Examples

shared

This example will set the LOD distance of all script-created objects.

-- Client-side
-- WARNING: Can cause significant lag.
-- Adjusts LOD for all objects.
function setAllObjectsLOD()
-- Get all current objects.
local objects = getElementsByType("object", root, false)
for _, theObject in ipairs(objects) do
local modelID = getElementModel(theObject)
local lodLevel = 325 -- Distance value
-- Set LOD for this model ID.
-- The 'true' enables extended range.
engineSetModelLODDistance(modelID, lodLevel, true)
end
end
-- Command to run the function.
addCommandHandler("setAllObjectsLOD", setAllObjectsLOD)

See Also

Engine Functions
Engine Elements