setElementLighting | Multi Theft Auto: Wiki Skip to content

setElementLighting

Client-side
Server-side
Shared

Pair: getElementLighting

Added in 1.6.0 r22862

This function changes the lighting value for the specified element. This can be a player, ped, vehicle, object or a weapon.

Note

Lighting is calculated in real-time every frame. Therefore, to correctly override the lighting, you should use this function in combination with the onClientPedsProcessed event, not only for peds, but also for other element types.

OOP Syntax Help! I don't understand this!

  • Method:element:setLighting(...)
  • Variable: .lighting

Syntax

bool setElementLighting ( ​element theElement, ​float lighting )
Required Arguments
  • theElement: The element whose lighting you want to change.
  • lighting: The lighting value that you want to set.

Returns

  • bool: result

Returns true if the function was successful, false otherwise.

Code Examples

client

This example sets the lighting value of all players and vehicles to 10

addEventHandler("onClientPedsProcessed", root, function()
for _, v in pairs(getElementsByType('player')) do
setElementLighting(v, 10)
end
for _, v in pairs(getElementsByType('vehicle')) do
setElementLighting(v, 10)
end
end)

See Also

Element Functions