SetGrainLevel

From Multi Theft Auto: Wiki
Revision as of 15:22, 25 July 2023 by TEDERIs (talk | contribs) (Created page with "__NOTOC__ {{Client function}} {{New feature/item|3.0161|1.6.0|21894|This function sets the level of the overlay grain effect. The game will draw it on top of another grain effects. It can be used to imitate an effect of radiation or electromagnetic disturbances, for example.}} ==Syntax== <syntaxhighlight lang="lua"> bool setGrainLevel ( int level ) </syntaxhighlight> ===Required Arguments=== *'''level:''' The amount of grain (0-255). ===Returns=== Returns ''true''...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

ADDED/UPDATED IN VERSION 1.6.0 r21894:
This function sets the level of the overlay grain effect. The game will draw it on top of another grain effects. It can be used to imitate an effect of radiation or electromagnetic disturbances, for example.

Syntax

bool setGrainLevel ( int level  )

Required Arguments

  • level: The amount of grain (0-255).

Returns

Returns true if the grain level was set, false otherwise.

Example

This example creates a radioactive zone at Missionary Hills:

setTimer( function()
	local zx, zy, zz = -2405.49268, -599.97339, 132.64844 -- Zone position
	local radius = 20 -- Zone radius

	local x, y, z = getElementPosition( localPlayer )
	local dist = getDistanceBetweenPoints3D( x, y, z, zx, zy, zz )
	local intensity = math.max( radius - dist, 0 ) / radius

	setGrainLevel( intensity * 255 )
end, 100, 0 )

See Also