ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Shared functions
  3. isElementInWater

Function

isElementInWater

Server and clientElementsIdentical to MTA:SA

Checks whether an element is in water.

Syntax

bool isElementInWater(element theElement)

Arguments

theElementelement
The element.

Returns

true if in water.

Example

setTimer(function()
    for _, veh in ipairs(getElementsByType("vehicle")) do
        if isElementInWater(veh) then
            respawnVehicle(veh)
        end
    end
end, 10000, 0)

Notes

Client. In a client script: your own ped and streamed vehicles - from the game; other elements - position below the water surface.

Server. A player - from their game (swimming). A vehicle - from players within 80 m who see it; when nobody is nearby, the last known state stays (a sunk and abandoned car still returns true).