Squirrel/Server/Functions/Checkpoints/FindCheckpoint
From Liberty Unleashed Wiki
(Difference between revisions)
(→Example 1. Non-player specific) |
(→Example 2. Player specific) |
||
Line 39: | Line 39: | ||
if ( command == "findcheckpoint" ) | if ( command == "findcheckpoint" ) | ||
{ | { | ||
− | local | + | local checkpoint = FindCheckpoint( text.tointeger(), player ) |
− | if ( | + | 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 ); | else MessagePlayer( "Unable to find a checkpoint with ID " + text + " belonging to you!", player ); | ||
} | } | ||
} | } | ||
</code> | </code> | ||
− | |||
− | |||
This command is used to find the specified checkpoint ID for the player typing the command. | This command is used to find the specified checkpoint ID for the player typing the command. | ||
+ | |||
+ | === Notes === | ||
The function [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]] and event [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] were used in in this example. More info about them in the corresponding pages. | The function [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]] and event [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] were used in in this example. More info about them in the corresponding pages. |
Revision as of 04:02, 8 March 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
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.
The function MessagePlayer and event onPlayerCommand were used in in this example. More info about them in the corresponding pages.
Example 2. Player specific
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 ); } }
This command is used to find the specified checkpoint ID for the player typing the command.
Notes
The function MessagePlayer and event onPlayerCommand were used in in this example. More info about them in the corresponding pages.