isPedInWater
Shared
Tells whether a ped or player is in the water.
bool isPedInWater(element ped)
Parameters
| Name | Type | Description |
|---|---|---|
| ped | element | The ped or player. Any other element returns false. |
Returns
true if it is in the water. false if not or if the element is not a ped.
On the client, a ped on foot is in the water when it is swimming, and a ped in a vehicle when the vehicle is in the water. On the server, the last state the client synced is used: the ped is swimming.
Example
setTimer(function()
for _, player in ipairs(getElementsByType("player")) do
if isPedInWater(player) then
outputDebugString(getPlayerName(player) .. " is swimming")
end
end
end, 1000, 0)