GetWaterLevel: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client function}}  
{{Client function}}  
This function allows you to retrieve the water level from a certain position.
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).


==Syntax==  
==Syntax==  
Line 14: Line 14:


===Returns===
===Returns===
Returns ''false'' if there's no water or an ''integer'' which tells you how far away is the surface of the water from the specified position.
Returns ''false'' if there's no water in that location or the water level as an ''integer''.


==Example==
==Example==

Revision as of 12:42, 26 August 2007

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).

Syntax

bool/float getWaterLevel ( float posX, float posY, float posZ )

Required Arguments

  • x: The X axis position
  • y: The Y axis position
  • z: The Z axis position

Returns

Returns false if there's no water in that location or the water level as an integer.

Example

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 = getPlayerFromNick ( 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 )
        outputChatBox( "You are " .. level .. " units away from the water!", source )
  else outputChatBox ( "Player does not exist" )
  end
end
addCommandHandler( "getlevel", scriptGetLevel ) -- add a command "getloc" which

See Also