GetPlayerCount: Difference between revisions
Jump to navigation
Jump to search
m (Example section using.) |
m (Syntax section) |
||
Line 6: | Line 6: | ||
==Syntax== | ==Syntax== | ||
<section show="true" name="Server" class="server"> | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
int getPlayerCount ( ) | int getPlayerCount ( ) | ||
Line 12: | Line 13: | ||
===Returns=== | ===Returns=== | ||
Returns the number of players connected to the server as an [[int]]. | Returns the number of players connected to the server as an [[int]]. | ||
</section> | |||
==Example== | ==Example== |
Revision as of 22:29, 14 November 2011
This function returns the number of players currently connected to the server.
Note: #getElementsByType("player") works the same as this function but also works client side unlike this function.
Syntax
Click to collapse [-]
ServerExample
Click to collapse [-]
ServerThis example displays a chat message with the number of players connected to the server when a player joins or quits.
function playerCount ( ) outputChatBox ( "There are now " .. getPlayerCount() .. " players on this server!" ) end addEventHandler ( "onPlayerJoin", getRootElement(), playerCount ) addEventHandler ( "onPlayerQuit", getRootElement(), playerCount )
See Also
- getPlayerTeam
- getPlayerBlurLevel
- setPlayerBlurLevel
- getPlayerSerial
- forcePlayerMap
- getPlayerScriptDebugLevel
- getPlayerFromName
- getPlayerMoney
- getPlayerName
- getPlayerNametagColor
- getPlayerNametagText
- getPlayerPing
- getPlayerWantedLevel
- givePlayerMoney
- isPlayerMapForced
- isPlayerNametagShowing
- setPlayerHudComponentVisible
- setPlayerMoney
- setPlayerNametagColor
- setPlayerNametagShowing
- setPlayerNametagText
- takePlayerMoney
- countPlayersInTeam
- getPlayersInTeam
- isVoiceEnabled
- setControlState
- getControlState