IsPlayerInWater: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (Replaced template deprecated with DeprecatedWithAlt)
m (Changed "DeprecatedWithAlt" template to "Deprecated" and removed an unnecessary section)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Server client function}}
{{Server client function}}
{{DeprecatedWithAlt|isPedInWater|}}
{{Deprecated|isPedInWater|}}


This function is used to determine whether or not a player is currently in water. Player is in water only if breath bar appears.
This function is used to determine whether or not a player is currently in water. Player is in water only if breath bar appears.


==Syntax==
==Syntax==
<section name="Server and client" class="both" show="true">
<syntaxhighlight lang="lua">bool isPlayerInWater ( player thePlayer )</syntaxhighlight>
<syntaxhighlight lang="lua">bool isPlayerInWater ( player thePlayer )</syntaxhighlight>


Line 14: Line 13:
===Returns===
===Returns===
Returns ''true'' if the player is in water, ''false'' otherwise.
Returns ''true'' if the player is in water, ''false'' otherwise.
</section>


==Example==
==Example==

Revision as of 16:30, 13 February 2015

Emblem-important.png This function is deprecated. This means that its use is discouraged and that it might not exist in future versions.

Please use isPedInWater instead.


This function is used to determine whether or not a player is currently in water. Player is in water only if breath bar appears.

Syntax

bool isPlayerInWater ( player thePlayer )

Required Arguments

  • thePlayer: The player you are checking.

Returns

Returns true if the player is in water, false otherwise.

Example

Click to collapse [-]
Serverside example

This example shows all players that are in water in a list to the player who enters the 'playersInWater' command.

 [lua]
function showPlayersInWater(sourcePlayer, command)
	local players = getElementsByType("player")
	local list = ""
	for k,v in ipairs(players) do
		if isPlayerInWater(v) then
			list = list .. " " .. getClientName(v)
		end
	end
	outputChatBox("Players pretending to be trouts: " .. list, sourcePlayer)
end
addCommandHandler("playersInWater", showPlayersInWater)

See Also