FindCheckpoint

From Liberty Unleashed Wiki
Jump to: navigation, search
Home   |   Squirrel Scripting   |   Server Functions   |   Server Events   |   Client Functions   |   Client Events

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 owned by a specific client, 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

This command is used to check if the specified checkpoint ID exists.

  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. return 1;
  11. }
  12.  

Notes

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

Example 2. Player specific

This command is used to find the specified checkpoint ID for the player typing the command.

  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. return 1;
  11. }
  12.  

Notes

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

Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox