setGrainLevel | Multi Theft Auto: Wiki Skip to content

setGrainLevel

Client-side
Server-side
Shared

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


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

  • bool: value

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

Code Examples

shared

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

World Functions