M MY Multiplayer: Wiki
Side
Kind

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

NameTypeDescription
elementelementA vehicle, ped, player or object.
selectorint|stringWhich material: its index from 1 or its name, as engineGetModelMaterials lists them. The name ignores case and takes the * and ? wildcards.
materialmaterialThe material drawn in their place.
priorityintWhen 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.

See also