isElementInWater | Multi Theft Auto: Wiki Skip to content

isElementInWater

Client-side
Server-side
Shared

This function checks whether an element is submerged in water.

Note

This function returns true only when the pivot point (usually the center of the model) is in water. This means it will return true if, for example, a ped is submerged halfway in water.

OOP Syntax Help! I don't understand this!

  • Method:element:isInWater(...)
  • Variable: .inWater

Syntax

bool isElementInWater ( ​element theElement )
Required Arguments
  • theElement: The element to check.

Returns

  • bool: result

Returns true if the passed element is in water, false if it isn't, or if the element is invalid.

Code Examples

client

Function which checks if player is in water, which is triggered when player dies.

function diedInWater()
if isElementInWater(source) then
local name = source == localPlayer and "You are" or getPlayerName(source).." is"
outputChatBox(name.." sleeping with the fishies!")
end
end
addEventHandler("onClientPlayerWasted", root, diedInWater)

See Also

Element Functions