Squirrel/Server/Functions/Spheres/GetSphereCount

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(New page: __NOTOC__ 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 ha...)
 
(Example)
Line 12: Line 12:
 
== Example ==
 
== Example ==
  
{{Squirrel/NeedsExample}}
 
 
<code lang="squirrel">
 
<code lang="squirrel">
-- todo
+
 
 +
This example command returns the count of checkpoints ingame (global and local checkpoints).
 +
function onPlayerCommand( player, command, text )
 +
{
 +
        if ( command == "spheres" )
 +
        {
 +
                  local spheres = GetCheckpointCount();
 +
                  local Plrspheres = GetCheckpointCount( player );
 +
                 
 +
                  MessagePlayer( "There are currently " + spheres + " global spheres in-game.", player );
 +
                  MessagePlayer( "There are also " + Plrspheres + " spheres which belong to you!", player );
 +
        }
 +
}
 
</code>
 
</code>
 +
 +
This command will give the player info about global spheres and spheres belonging to them.
  
 
=== Notes ===
 
=== Notes ===
  
-- Example notes here
+
The call [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] was used in in this example. More info about this in the corresponding page.
  
 
== Related Functions ==
 
== Related Functions ==
  
 
{{Squirrel/Server/Functions/Spheres}}
 
{{Squirrel/Server/Functions/Spheres}}

Revision as of 04:05, 8 March 2010

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.

Syntax

  1. int GetSphereCount( [ Player plr ] )

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

Example

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

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

Notes

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

Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox