Squirrel/Server/Functions/Checkpoints/FindCheckpoint
From Liberty Unleashed Wiki
(Difference between revisions)
(New page: __NOTOC__ This function finds a checkpoint from an ID and returns the pointer. If no checkpoint is found, ''null'' will be returned. == Syntax == <code>Checkpoint FindCheckpoint( int id ...) |
(→Example) |
||
Line 11: | Line 11: | ||
* '''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 | * '''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 == | + | == Example 1. Non-player specific == |
{{Squirrel/NeedsExample}} | {{Squirrel/NeedsExample}} | ||
<code lang="squirrel"> | <code lang="squirrel"> | ||
− | + | function onPlayerCommand( player, command, text ) | |
+ | { | ||
+ | if ( command == "findcheckpoint" ) | ||
+ | { | ||
+ | local Checkpoint = FindCheckpoint( text.tointeger() ) | ||
+ | |||
+ | if ( Checkpoint ) MessagePlayer( "Checkpoint ID " + text + " has been found!", player ); | ||
+ | else MessagePlayer( "Unable to find a checkpoint with ID " + text, player ); | ||
+ | } | ||
+ | } | ||
</code> | </code> | ||
=== Notes === | === Notes === | ||
− | + | This command is used to find the specified checkpoint ID. | |
== Related Functions == | == Related Functions == | ||
{{Squirrel/Server/Functions/Checkpoints}} | {{Squirrel/Server/Functions/Checkpoints}} |
Revision as of 16:02, 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
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
This function needs an example. You can help us complete the wiki by writing one, or maybe even more :o
function onPlayerCommand( player, command, text ) { if ( command == "findcheckpoint" ) { local Checkpoint = FindCheckpoint( text.tointeger() ) if ( Checkpoint ) MessagePlayer( "Checkpoint ID " + text + " has been found!", player ); else MessagePlayer( "Unable to find a checkpoint with ID " + text, player ); } }
Notes
This command is used to find the specified checkpoint ID.