IsPlayerInWater: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 4: Line 4:


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


===Required Arguments===
===Required Arguments===
*'''thePlayer''': The [[player]] you are checking.
*'''thePlayer:''' The [[player]] you are checking.


===Returns===
===Returns===
Line 14: Line 14:
</section>
</section>


<section name="Client" class="client">
<section name="Client" class="client" show="true">
<syntaxhighlight lang="lua">bool isPlayerInWater (  )</syntaxhighlight>
<syntaxhighlight lang="lua">bool isPlayerInWater (  )</syntaxhighlight>


Line 24: Line 24:
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"> [lua]
<syntaxhighlight lang="lua"> [lua]
function showPlayersInWater(player)
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 (isPlayerUnderWater(v) == true) then
if isPlayerInWater(v) then
list = list.." "..getClientName(v)
list = list .. " " .. getClientName(v)
end
end
end
end
outputChatBox("Players pretending to be trouts:"..list,player)
outputChatBox("Players pretending to be trouts: " .. list, sourcePlayer)
end
end
addCommandHandler("playersInWater",showPlayersInWater)
addCommandHandler("playersInWater", showPlayersInWater)
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Player functions}}
{{Player functions}}

Revision as of 20:24, 16 August 2007

This function is used to determine whether or not a player is currenlty in water.

Syntax

Click to collapse [-]
Server
bool isPlayerInWater ( player thePlayer )

Required Arguments

  • thePlayer: The player you are checking.

Returns

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

Click to collapse [-]
Client
bool isPlayerInWater (  )

Returns

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

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