GetElementLighting: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "{{Client function}} __NOTOC__ {{Added feature/item|1.5.9|1.5.9|21367|This function returns the lighting value for the specified element. This can be a player, ped, vehicle, object.}} ==Syntax== <syntaxhighlight lang="lua"> float getElementLighting ( element theElement ) </syntaxhighlight> {{OOP||element:getLighting|lighting}} ===Required Arguments=== *'''theElement:''' The element whose lighting you want to retrieve. ===Returns=== Returns a...")
 
m (Fix "See Also")
Line 34: Line 34:


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

Revision as of 13:50, 22 October 2022

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

Syntax

float getElementLighting ( element theElement )

OOP Syntax Help! I don't understand this!

Method: element:getLighting(...)
Variable: .lighting


Required Arguments

  • theElement: The element whose lighting you want to retrieve.

Returns

Returns a float (0.0-0.5; 0 = dark; 0.5 = light) indicating the element's lighting, or false if invalid arguments were passed. This function will fail if called right after element creation.

Example

Click to collapse [-]
Clientside example

This example displays lighting values of streamed in players.

addEventHandler("onClientRender", root, function()
	for _, pl in ipairs(getElementsByType("player", root, true)) do
		local sX, sY = getScreenFromWorldPosition(getElementPosition(pl))
		if sX then
			dxDrawText("Lighting: "..tostring(getElementLighting(pl)), sX, sY)
		end
	end
end)

Requirements

This template will be deleted.

See Also