Talk:Useful Functions: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
(12 intermediate revisions by 4 users not shown)
Line 1: Line 1:
there i wrote isElementInPhotograph()
== Pending functions ==
enjoy
Here are some functions that were developed as part of the MTA forums scripting section but have not yet been added to the list. Those could be useful to advanced resource crafters.
[[User:Drline|Drline]] 04:44, 30 October 2012 (UTC)


== countPlayersInWater ==
* https://forum.mtasa.com/topic/122958-getworldfrommapposition/ - calculating the world position on a map image
* https://forum.mtasa.com/topic/122823-help-getscreenfromworldposition/ - more powerful screen coordinate function with border support


==Syntax==
--[[User:Quiret|Quiret]] ([[User talk:Quiret|talk]]) 18:58, 17 March 2020 (UTC)
<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}}

Latest revision as of 18:59, 17 March 2020

Pending functions

Here are some functions that were developed as part of the MTA forums scripting section but have not yet been added to the list. Those could be useful to advanced resource crafters.

--Quiret (talk) 18:58, 17 March 2020 (UTC)