GetRandomPlayer: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
m (Minor changes)
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 ( )
</syntaxhighlight>


===Required Arguments===
===Returns===
''This function has no arguments.''
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's player name.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
randomPlayer = getRandomPlayer ( )
local randomPlayer = getRandomPlayer ( )
outputChatBox ( getClientName ( randomPlayer ).." is now the fugitive!" )
outputChatBox ( getClientName ( randomPlayer ).." is now the fugitive!" )
</syntaxhighlight>
</syntaxhighlight>

Revision as of 12:33, 13 August 2007

This function returns a random player.

Syntax

player getRandomPlayer ( )

Returns

Returns a random player, false if the server is empty.

Example

This code outputs a random's player name.

local randomPlayer = getRandomPlayer ( )
outputChatBox ( getClientName ( randomPlayer ).." is now the fugitive!" )

See Also