Squirrel/Server/Functions/Checkpoints/FindCheckpoint
From Liberty Unleashed Wiki
(Difference between revisions)
m (returns for events) |
|||
Line 25: | Line 25: | ||
else MessagePlayer( "Unable to find a checkpoint with ID " + text, player ); | else MessagePlayer( "Unable to find a checkpoint with ID " + text, player ); | ||
} | } | ||
+ | |||
+ | return 1; | ||
} | } | ||
</code> | </code> | ||
Line 46: | Line 48: | ||
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 ); | ||
} | } | ||
+ | |||
+ | return 1; | ||
} | } | ||
</code> | </code> |
Latest revision as of 20:26, 24 September 2010
This function finds a checkpoint from an ID and returns the pointer. If no checkpoint is found, null will be returned.
[edit] Syntax
Checkpoint FindCheckpoint( int id [, Player plr ] )
[edit] 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
[edit] Example 1. Non-player specific
This command is used to check if the specified checkpoint ID exists.
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 ); } return 1; }
[edit] Notes
The function MessagePlayer and event onPlayerCommand were used in this example. More info about them in the corresponding pages.
[edit] Example 2. Player specific
This command is used to find the specified checkpoint ID for the player typing the command.
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 ); } return 1; }
[edit] Notes
The function MessagePlayer and event onPlayerCommand were used in in this example. More info about them in the corresponding pages.