SetGrainLevel

From Multi Theft Auto: Wiki
Revision as of 01:46, 26 July 2023 by TEDERIs (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

ADDED/UPDATED IN VERSION 1.6.0 r21902:
This function sets a level of the overlay grain effect. The game will draw it on top of other 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