GetRandomPlayer: Difference between revisions

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


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


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


==Example==
==See Also==
player = [[GetRandomPlayer]] ( 1 )
{{Player functions|server}}
[[ serverChat ]] ( [[GetPlayerName]] ( player ) , " is now the fugitive!" )
[[pl:getRandomPlayer]]

Latest revision as of 22:42, 6 September 2024