Squirrel/Server/Functions/Checkpoints/GetCheckpointCount

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
 
Line 1: Line 1:
__NOTOC__
+
{{Squirrel/Title|GetCheckpointCount}}
 
This function returns the number of checkpoints in the server. If the optional player argument is used, the function will return how many client-side checkpoints does the given player have. Without the argument it will return the number of global checkpoints.
 
This function returns the number of checkpoints in the server. If the optional player argument is used, the function will return how many client-side checkpoints does the given player have. Without the argument it will return the number of global checkpoints.
  
Line 8: Line 8:
 
== Arguments ==
 
== Arguments ==
  
* '''plr''' - If you want to get the number of the checkpoints for a specific client, use this argument to indicate the player. If you don't use this argument the global checkpoint count will be returned
+
* '''plr''' - If you want to get the number of local checkpoints for a specific client, use this argument to indicate the player. If you don't use this argument the global checkpoint count will be returned
  
 
== Example ==
 
== Example ==
  
 +
This example command returns the count of checkpoints ingame (global and local checkpoints).
  
 
<code lang="squirrel">
 
<code lang="squirrel">
 
This example command returns the count of checkpoints ingame (global and local checkpoints).
 
 
function onPlayerCommand( player, command, text )
 
function onPlayerCommand( player, command, text )
 
{
 
{
        if ( command == "checkpoints" )
+
    if ( command == "checkpoints" )
        {
+
    {
                  local checkpoints = GetCheckpointCount();
+
          local checkpoints = GetCheckpointCount();
                  local PlrCheckpoints = GetCheckpointCount( player );
+
          local PlrCheckpoints = GetCheckpointCount( player );
                 
+
         
                  MessagePlayer( "There are currently " + checkpoints + " global checkpoints in-game.", player );
+
          MessagePlayer( "There are currently " + checkpoints + " global checkpoints in-game.", player );
                  MessagePlayer( "There are also " + PlrCheckpoints + " checkpoints which belong to you!", player );
+
          MessagePlayer( "There are also " + PlrCheckpoints + " checkpoints which belong to you!", player );
        }
+
    }
 +
   
 +
    return 1;
 
}
 
}
 
</code>
 
</code>

Latest revision as of 20:25, 24 September 2010

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

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

[edit] Syntax

  1. int GetCheckpointCount( [ Player plr ] )

[edit] Arguments

  • plr - If you want to get the number of local checkpoints for a specific client, use this argument to indicate the player. If you don't use this argument the global checkpoint 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 == "checkpoints" )
  5. {
  6. local checkpoints = GetCheckpointCount();
  7. local PlrCheckpoints = GetCheckpointCount( player );
  8. MessagePlayer( "There are currently " + checkpoints + " global checkpoints in-game.", player );
  9. MessagePlayer( "There are also " + PlrCheckpoints + " checkpoints which belong to you!", player );
  10. }
  11. return 1;
  12. }
  13.  

[edit] Notes

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

[edit] Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox