Squirrel/Server/Functions/Spheres/GetSphereCount

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
m
 
Line 11: Line 11:
  
 
== Example ==
 
== Example ==
 
<code lang="squirrel">
 
  
 
This example command returns the count of checkpoints ingame (global and local checkpoints).
 
This example command returns the count of checkpoints ingame (global and local checkpoints).
 +
 +
<code lang="squirrel">
 
function onPlayerCommand( player, command, text )
 
function onPlayerCommand( player, command, text )
 
{
 
{

Latest revision as of 01:15, 17 August 2011

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

This function returns the number of spheres on the server. If the optional player argument is used, the function will return how many client-side spheres does the given player have. Without the argument it will return the number of global spheres.

[edit] Syntax

  1. int GetSphereCount( [ Player plr ] )

[edit] Arguments

  • plr - If you want to get the number of the spheres for a specific client, use this argument to indicate the player. If you don't use this argument the global sphere count will be returned

[edit] Example

This example command returns the count of checkpoints ingame (global and local checkpoints).

  1.  
  2. function onPlayerCommand( player, command, text )
  3. {
  4. if ( command == "spheres" )
  5. {
  6. local spheres = GetCheckpointCount();
  7. local Plrspheres = GetCheckpointCount( player );
  8. MessagePlayer( "There are currently " + spheres + " global spheres in-game.", player );
  9. MessagePlayer( "There are also " + Plrspheres + " spheres which belong to you!", player );
  10. }
  11. }
  12.  

This command will give the player info about global spheres and spheres belonging to them.

[edit] Notes

The call onPlayerCommand was used in in this example. More info about this in the corresponding page.

[edit] Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox