Squirrel/Server/Functions/Checkpoints/FindCheckpoint

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(Example 1. Non-player specific)
Line 22: Line 22:
 
                   if ( Checkpoint ) MessagePlayer( "Checkpoint ID " + text + " has been found!", player );
 
                   if ( Checkpoint ) MessagePlayer( "Checkpoint ID " + text + " has been found!", player );
 
                   else MessagePlayer( "Unable to find a checkpoint with ID " + text, player );
 
                   else MessagePlayer( "Unable to find a checkpoint with ID " + text, player );
 +
        }
 +
}
 +
</code>
 +
 +
=== Notes ===
 +
 +
This command is used to find the specified checkpoint ID.
 +
 +
== Example 2. Player specific ==
 +
 +
<code lang="squirrel">
 +
function onPlayerCommand( player, command, text )
 +
{
 +
        if ( command == "findcheckpoint" )
 +
        {
 +
                  local Checkpoint = FindCheckpoint( text.tointeger(), player )
 +
                 
 +
                  if ( Checkpoint ) MessagePlayer( "Checkpoint ID " + text + " has been found belonging to you!", player );
 +
                  else MessagePlayer( "Unable to find a checkpoint with ID " + text + " belonging to you!", player );
 
         }
 
         }
 
}
 
}

Revision as of 16:04, 7 January 2010

This function finds a checkpoint from an ID and returns the pointer. If no checkpoint is found, null will be returned.

Syntax

  1. Checkpoint FindCheckpoint( int id [, Player plr ] )

Arguments

  • id - The ID of the checkpoint to be found
  • plr - If the checkpoint you want to find is for a specific client only, use this to specify a pointer to the player who owns the checkpoint. If you don't use this argument the checkpoint will be returned from the global checkpoint pool

Example 1. Non-player specific

  1.  
  2. function onPlayerCommand( player, command, text )
  3. {
  4. if ( command == "findcheckpoint" )
  5. {
  6. local Checkpoint = FindCheckpoint( text.tointeger() )
  7. if ( Checkpoint ) MessagePlayer( "Checkpoint ID " + text + " has been found!", player );
  8. else MessagePlayer( "Unable to find a checkpoint with ID " + text, player );
  9. }
  10. }
  11.  

Notes

This command is used to find the specified checkpoint ID.

Example 2. Player specific

  1.  
  2. function onPlayerCommand( player, command, text )
  3. {
  4. if ( command == "findcheckpoint" )
  5. {
  6. local Checkpoint = FindCheckpoint( text.tointeger(), player )
  7. if ( Checkpoint ) MessagePlayer( "Checkpoint ID " + text + " has been found belonging to you!", player );
  8. else MessagePlayer( "Unable to find a checkpoint with ID " + text + " belonging to you!", player );
  9. }
  10. }
  11.  

Notes

This command is used to find the specified checkpoint ID.

Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox