GetWaterLevel: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 12: | Line 12: | ||
*'''y:''' The Y axis position | *'''y:''' The Y axis position | ||
*'''z:''' The Z axis position | *'''z:''' The Z axis position | ||
===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. | ||
==Example== | ==Example== | ||
This example will tell you what's the water level where the specified player is located. | This example will tell you what's the water level where the specified player is located. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function scriptGetLevel ( command, playername ) --when getlevel is called | function scriptGetLevel ( command, playername ) --when getlevel is called | ||
local thePlayer = getPlayerFromNick ( playername ) --get the player from nickname | local thePlayer = getPlayerFromNick ( playername ) --get the player from nickname | ||
if ( thePlayer ~= false ) then --if there is a player from the 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 ) | local level = getWaterLevel ( x, y, z ) | ||
outputChatBox( "You are " .. level .. " units away from the water!", source ) | |||
else outputChatBox ( "Player does not exist" ) | else outputChatBox ( "Player does not exist" ) | ||
end | end | ||
end | end | ||
addCommandHandler( "getlevel", scriptGetLevel ) -- add a command "getloc" which | |||
addCommandHandler( "getlevel", scriptGetLevel ) -- add a command "getloc" which | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Client_world_functions}} | {{Client_world_functions}} |
Revision as of 12:20, 11 August 2007
This function allows you to retrieve the water level from a certain position.
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 or an integer which tells you how far away is the surface of the water from the specified position.
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
- createSWATRope
- getBirdsEnabled
- getCoronaReflectionsEnabled
- getGarageBoundingBox
- getGaragePosition
- getGarageSize
- getGroundPosition
- getInteriorFurnitureEnabled
- getNearClipDistance
- getPedsLODDistance
- getRoofPosition
- getScreenFromWorldPosition
- getVehiclesLODDistance
- getWorldFromScreenPosition
- isAmbientSoundEnabled
- isLineOfSightClear
- isWorldSoundEnabled
- processLineOfSight
- resetAmbientSounds
- resetBlurLevel
- resetColorFilter
- resetCoronaReflectionsEnabled
- resetNearClipDistance
- resetPedsLODDistance
- resetVehiclesLODDistance
- resetWorldSounds
- setAmbientSoundEnabled
- setBirdsEnabled
- setColorFilter
- setCoronaReflectionsEnabled
- setInteriorFurnitureEnabled
- setInteriorSoundsEnabled
- setNearClipDistance
- setPedsLODDistance
- setVehiclesLODDistance
- setWorldSoundEnabled
- testLineAgainstWater
- areTrafficLightsLocked
- getAircraftMaxHeight
- getAircraftMaxVelocity
- getCloudsEnabled
- getFarClipDistance
- getFogDistance
- getGameSpeed
- getGravity
- getHeatHaze
- getInteriorSoundsEnabled
- getJetpackMaxHeight
- getMinuteDuration
- getMoonSize
- getOcclusionsEnabled
- getRainLevel
- getSunColor
- getSunSize
- getTime
- getTrafficLightState
- getWeather
- getWindVelocity
- getSkyGradient
- getPlayerBlurLevel
- getZoneName
- isGarageOpen
- removeWorldModel
- resetFarClipDistance
- resetFogDistance
- resetHeatHaze
- resetMoonSize
- resetRainLevel
- resetSkyGradient
- resetSunColor
- resetSunSize
- resetWindVelocity
- restoreAllWorldModels
- restoreWorldModel
- setAircraftMaxHeight
- setAircraftMaxVelocity
- setCloudsEnabled
- setFarClipDistance
- setFogDistance
- setGameSpeed
- setGarageOpen
- setGravity
- setHeatHaze
- setInteriorSoundsEnabled
- setMinuteDuration
- setMoonSize
- setOcclusionsEnabled
- setRainLevel
- setSkyGradient
- setSunColor
- setSunSize
- setTime
- setTrafficLightState
- setTrafficLightsLocked
- setWeather
- setWeatherBlended
- setWindVelocity
- setJetpackMaxHeight
- setPlayerBlurLevel