Squirrel/Server/Functions/Server/GetPlayers

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
Line 15: Line 15:
  
 
<code lang="squirrel">
 
<code lang="squirrel">
function OnPlayerCommand( id, cmd, text )
+
function onPlayerCommand( id, cmd, text )
 
{
 
{
 
     if ( cmd == "players" )
 
     if ( cmd == "players" )
Line 26: Line 26:
 
=== Notes ===
 
=== Notes ===
  
The function [[Squirrel/Functions/Misc/MessagePlayer|MessagePlayer]] and call [[Squirrel/Events/Player/OnPlayerCommand|OnPlayerCommand]] were used in in this example. More info about them in corresponding pages.
+
The function [[Squirrel/Functions/Misc/MessagePlayer|MessagePlayer]] and call [[Squirrel/Events/Player/onPlayerCommand|onPlayerCommand]] were used in in this example. More info about them in corresponding pages.
  
 
== Related Functions ==
 
== Related Functions ==
  
 
{{Squirrel/Functions/Server}}
 
{{Squirrel/Functions/Server}}

Revision as of 11:10, 11 October 2010

Home   |   Squirrel Scripting   |   Server Functions   |   Server Events   |   Client Functions   |   Client Events

This returns the number of players currently playing on the server.

Syntax

  1. string GetPlayers()

Arguments

  • None

Example

This command will return the number of players in the server when someone types /players'.

  1.  
  2. function onPlayerCommand( id, cmd, text )
  3. {
  4. if ( cmd == "players" )
  5. {
  6. Message( "There are currently " + GetPlayers() + " players in-game.", id );
  7. }
  8. }
  9.  

Notes

The function MessagePlayer and call onPlayerCommand were used in in this example. More info about them in corresponding pages.

Related Functions

Template:Squirrel/Functions/Server

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox