Squirrel/Server/Functions/Server/GetPlayers

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
 
Line 1: Line 1:
 
{{Squirrel/Title|GetPlayers}}
 
{{Squirrel/Title|GetPlayers}}
This returns the number of players currently playing on the server.
+
This returns the number of players currently playing on the server. (This function also has an alias ''GetPlayerCount'')
  
 
== Syntax ==
 
== Syntax ==
  
<code>string GetPlayers()</code>
+
<code>int GetPlayers()</code>
  
 
== Arguments ==
 
== Arguments ==
Line 12: Line 12:
 
== Example ==
 
== Example ==
  
This command will return the number of players in the server when someone types /players'.
+
This command will return the number of players in-game when someone types /players'.
  
 
<code lang="squirrel">
 
<code lang="squirrel">
function onPlayerCommand( id, cmd, text )
+
function onPlayerCommand( plr, cmd, text )
 
{
 
{
 
     if ( cmd == "players" )
 
     if ( cmd == "players" )
 
     {
 
     {
           Message( "There are currently " + GetPlayers() + " players in-game.", id );
+
           Message( "There are currently " + GetPlayers() + " players in-game.", lpr );
 
     }
 
     }
 +
   
 +
    return 1;
 
}
 
}
 
</code>
 
</code>
Line 26: Line 28:
 
=== Notes ===
 
=== Notes ===
  
The function [[Squirrel/Functions/Misc/MessagePlayer|MessagePlayer]] and call [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] were used in in this example. More info about them in corresponding pages.
+
The function [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]] and call [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] were used in this example. More info about them can be found in corresponding pages.
  
 
== Related Functions ==
 
== Related Functions ==
  
{{Squirrel/Functions/Server}}
+
{{Squirrel/Server/Functions/Server}}

Latest revision as of 23:16, 9 June 2011

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

This returns the number of players currently playing on the server. (This function also has an alias GetPlayerCount)

[edit] Syntax

  1. int GetPlayers()

[edit] Arguments

  • None

[edit] Example

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

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

[edit] Notes

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

[edit] Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox