IsPlayerInWater: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m (Change deprecated function alternative.) |
||
(12 intermediate revisions by 11 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
This function is used to determine whether or not a player is | {{Server client function}} | ||
{{Deprecated|isElementInWater}} | |||
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== | ||
<syntaxhighlight lang="lua">bool isPlayerInWater ( player thePlayer )</syntaxhighlight> | <syntaxhighlight lang="lua">bool isPlayerInWater ( player thePlayer )</syntaxhighlight> | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''thePlayer''' | *'''thePlayer:''' The [[player]] you are checking. | ||
===Returns=== | ===Returns=== | ||
Returns ''true'' if the player is in water, ''false'' otherwise. | Returns ''true'' if the player is in water, ''false'' otherwise. | ||
==Example== | ==Example== | ||
<section name="Serverside example" class="server" show="true"> | |||
This example shows all players that are in water in a list to the player who enters the 'playersInWater' command. | This example shows all players that are in water in a list to the player who enters the 'playersInWater' command. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function showPlayersInWater( | function showPlayersInWater(sourcePlayer, command) | ||
local players = getElementsByType("player") | local players = getElementsByType("player") | ||
local list = "" | local list = "" | ||
for k,v in ipairs(players) do | for k,v in ipairs(players) do | ||
if | if isPlayerInWater(v) then | ||
list = list.." "..getClientName(v) | list = list .. " " .. getClientName(v) | ||
end | end | ||
end | end | ||
outputChatBox("Players pretending to be trouts:"..list, | outputChatBox("Players pretending to be trouts: " .. list, sourcePlayer) | ||
end | end | ||
addCommandHandler("playersInWater",showPlayersInWater) | addCommandHandler("playersInWater", showPlayersInWater) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | |||
==See Also== | ==See Also== | ||
{{Player functions}} | {{Player functions}} |
Latest revision as of 06:08, 22 September 2021
This function is deprecated. This means that its use is discouraged and that it might not exist in future versions. | |
Please use isElementInWater 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 exampleThis example shows all players that are in water in a list to the player who enters the 'playersInWater' command.
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
- getPlayerTeam
- getPlayerBlurLevel
- setPlayerBlurLevel
- getPlayerSerial
- forcePlayerMap
- getPlayerScriptDebugLevel
- getPlayerFromName
- getPlayerMoney
- getPlayerName
- getPlayerNametagColor
- getPlayerNametagText
- getPlayerPing
- getPlayerWantedLevel
- givePlayerMoney
- isPlayerMapForced
- isPlayerNametagShowing
- setPlayerHudComponentVisible
- setPlayerMoney
- setPlayerNametagColor
- setPlayerNametagShowing
- setPlayerNametagText
- takePlayerMoney
- countPlayersInTeam
- getPlayersInTeam
- isVoiceEnabled
- setControlState
- getControlState