engineSetElementMaterial
Client
Replaces the chosen materials of a single vehicle, ped or object with a material.
bool engineSetElementMaterial(element element, int|string selector, material material [, int priority = 0])
Parameters
| Name | Type | Description |
|---|---|---|
| element | element | A vehicle, ped, player or object. |
| selector | int|string | Which material: its index from 1 or its name, as engineGetModelMaterials lists them. The name ignores case and takes the * and ? wildcards. |
| material | material | The material drawn in their place. |
| priority | int | When several resources pick the same material, the highest priority wins; between equals, the newest.default 0 |
Returns
true when it was applied.
It applies over what the model already draws, materials set with engineSetModelMaterial included. It holds while the element lives, streamed in or out.
Example
local gold = engineCreateMaterial("surface")
engineSetMaterialValue(gold, "metallicFactor", 1)
addCommandHandler("gold", function()
local vehicle = getPedOccupiedVehicle(localPlayer)
if vehicle then
engineSetElementMaterial(vehicle, 1, gold)
end
end)NoteAn element that is not a vehicle, ped, player or object is an error.