SetGrainLevel

From Multi Theft Auto: Wiki
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