Talk:Useful Functions: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(9 intermediate revisions by 4 users not shown)
Line 1: Line 1:
there i wrote isElementInPhotograph()
enjoy
[[User:Drline|Drline]] 04:44, 30 October 2012 (UTC)


== countPlayersInWater ==
==Syntax==
<syntaxhighlight lang="lua">int countPlayersInWater( )</syntaxhighlight>
===Returns===
Returns an integer containing the number of players in the water.
==Code==
<syntaxhighlight lang="lua">
function countPlayersInWater( )
    local count = 0
for i,player in ipairs(getElementsByType("player")) do
if isElementInWater(player) then
count = count + 1
end
end
    return count
end
</syntaxhighlight>
==Example==
<section name="Example" class="both" show="true">
This example adds a command in the console to find out how many players are on your team, clientside
<syntaxhighlight lang="lua">
outputChatBox("Number of Players in Water : ".. countPlayersInWater( ))
</syntaxhighlight>
</section>
== countPlayersInWater ==
This function is for returning the number of players in the water.
==Syntax==
<syntaxhighlight lang="lua">int countPlayersInWater( )</syntaxhighlight>
===Returns===
Returns an integer containing the number of players in the water.
==Code==
<syntaxhighlight lang="lua">
function countPlayersInWater( )
    local count = 0
for i,player in ipairs(getElementsByType("player")) do
if isElementInWater(player) then
count = count + 1
end
end
    return count
end
</syntaxhighlight>
==Example==
<section name="Example" class="both" show="true">
This example adds a command in the console to find out how many players are on your team, clientside
<syntaxhighlight lang="lua">
outputChatBox("Number of Players in Water : ".. countPlayersInWater( ))
</syntaxhighlight>
</section>
==See Also==
{{Useful_Functions}}

Revision as of 22:15, 21 May 2018