SetElementLighting: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (Update note)
No edit summary
 
(One intermediate revision by the same user not shown)
Line 19: Line 19:


==Example==
==Example==
{{Needs Example}}
This example sets the lighting value of all players and vehicles to 10
<syntaxhighlight lang="lua">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)</syntaxhighlight>
This example sets the lighting value to 10 only for our player, while keeping other players at the default value.
<syntaxhighlight lang="lua">addEventHandler("onClientPedsProcessed",root,function()
    setElementLighting(localPlayer, 10)
end)</syntaxhighlight>


==See Also==
==See Also==
{{Client element functions}}
{{Client element functions}}

Latest revision as of 09:24, 6 January 2025

ADDED/UPDATED IN VERSION 1.6.0 r22862:
This function changes the lighting value for the specified element. This can be a player, ped, vehicle, object, weapon.
[[{{{image}}}|link=|]] 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 vehicles and objects.

Syntax

bool setElementLighting ( element theElement, float lighting )

OOP Syntax Help! I don't understand this!

Method: element:setLighting(...)
Variable: .lighting
Counterpart: getElementLighting


Required Arguments

  • theElement: The element whose lighting you want to change.
  • lighting: The lighting value that you want to set.

Returns

Returns true if the function was successful, false otherwise. This function can fail if called right after element creation.

Example

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)

This example sets the lighting value to 10 only for our player, while keeping other players at the default value.

addEventHandler("onClientPedsProcessed",root,function()
    setElementLighting(localPlayer, 10)
end)

See Also