getWaterLevel
Manual Review Required
Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.
This function allows you to retrieve the water level from a certain location. The water level is 0 in most places though it can vary (e.g. it's higher near the dam).
Some small water areas within parts of the city do not count as water to be used with this function. For example, the shallow water area in Northwest San Fierro.
Syntax
float getWaterLevel ( float posX, float posY, float posZ, [ bool ignoreDistanceToWaterThreshold = false ] )Required Arguments
- posX: MISSING_PARAM_DESC
- posY: MISSING_PARAM_DESC
- posZ: MISSING_PARAM_DESC
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.
- ignoreDistanceToWaterThreshold (default: false): If set to false, this function returns false, if the difference between water level (without waves) and posZ is greater than 3.0
Returns
- float: value
Returns an integer of the water level if the localPlayer /position is near the water (-3 to 20 on the Z coordinate) else false if there's no water near the localPlayer /position.
Code Examples
This example will tell you what's the water level where the specified player is located.
function scriptGetLevel ( command, playername ) --when getlevel is called local thePlayer = getPlayerFromName ( playername ) --get the player from nickname if ( thePlayer ~= false ) then --if there is a player from the nickname local x, y, z = getElementPosition ( thePlayer ) -- get his position local level = getWaterLevel ( x, y, z ) if level then -- if it's not false level = z - level -- calculate how far away is he from the water outputChatBox( "You are " .. level .. " units away from the water!", source ) else outputChatBox ( "There's no sign of water" ) end else outputChatBox ( "Player does not exist" ) endendaddCommandHandler( "getlevel", scriptGetLevel ) -- add a command "getloc" which