setWaterLevel | Multi Theft Auto: Wiki Skip to content

setWaterLevel

Client-side
Server-side
Shared
Needs checking

This function was partially migrated from the old wiki. Please review manually:

  • Missing section: Alternate client-only syntax

Pair: getWaterLevel

Manual Review Required

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


Sets the height of some or all the water in the game world.

Note

When the water level is 0, the standard GTA rendering is performed so that water is visible when viewed through translucent surfaces, such as vehicle windows. However, some MTA custom objects placed underwater will appear in front of the water. Setting the water level to any non-zero value (i.e. setWaterLevel(0.001) ) forces alternative rendering and MTA custom objects placed underwater will be drawn correctly.

OOP Syntax Help! I don't understand this!

  • Method:water:setLevel(...)
  • Variable: .level

Syntax

bool setWaterLevel ( water theWater, float level )
Required Arguments
  • theWater: the water element to change.
  • level: the new Z coordinate of the water surface. All water in the game world is set to this height.

Returns

  • bool: value

Returns true if successful, false in case of failure.

Code Examples

shared

This example code will slowly drain away all rivers and seas.

local level = 0
function drainSomeWater()
level = level - 0.01
setWaterLevel ( level )
end
setTimer ( drainSomeWater, 100, 15000 )