GetRandomPlayer: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
(8 intermediate revisions by 8 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{server function}}
{{Server function}}
This function returns a random [[player]]. It is useful for assigning objectives to random players in a Manhunt mode, for example.
This function returns a random [[player]].


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">player getRandomPlayer ( )</syntaxhighlight>
<syntaxhighlight lang="lua">
 
player getRandomPlayer ( )
===Required Arguments===
</syntaxhighlight>
''This function has no arguments.''
{{OOP||[[Player]].getRandom}}
===Returns===
Returns a random [[player]], ''false'' if the server is empty.


==Example==
==Example==
This code outputs a random's player name.
This code outputs a random player's name.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
randomPlayer = getRandomPlayer ( )
local randomPlayer = getRandomPlayer ( )
outputChatBox ( getClientName ( randomPlayer ).." is now the fugitive!" )
outputChatBox ( getPlayerName ( randomPlayer ).." is now the fugitive!" )
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Player functions}}
{{Player functions}}
[[pl:getRandomPlayer]]

Latest revision as of 10:27, 16 November 2017