GetPlayerCount: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 1: Line 1:
__NOTOC__
__NOTOC__
==Description==
This function returns the number of players currently connected to the server.
This function returns the number of players currently connected to the server.


==Syntax==
==Syntax==
int getPlayerCount ()
<syntaxhighlight lang="lua">
int getPlayerCount ()
</syntaxhighlight>


==Required Arguments==
===Returns===
''This function has no arguments.''
Returns the number of players connected to the server as an [[int]].


==Example==
==Example==
playercount = '''getPlayerCount''' ()
This example displays a chat message with the number of players connected to the server.
serverChat ( "There are currently ", playercount, " players playing in the server" )
<syntaxhighlight lang="lua">
-- Retrieve the number of players connected to the server and store the number in the playercount variable
playercount = getPlayerCount ()
-- Display a chat message informing everyone on the server how many people are playing.
serverChat ( "There are currently ", playercount, " players playing in the server" )
</syntaxhighlight>
 
==See Also==
{{Player_Functions}}

Revision as of 00:52, 18 May 2006

This function returns the number of players currently connected to the server.

Syntax

int getPlayerCount ()

Returns

Returns the number of players connected to the server as an int.

Example

This example displays a chat message with the number of players connected to the server.

-- Retrieve the number of players connected to the server and store the number in the playercount variable
playercount = getPlayerCount ()
-- Display a chat message informing everyone on the server how many people are playing.
serverChat ( "There are currently ", playercount, " players playing in the server" )

See Also

Template:Player Functions