Squirrel/Server/Functions/Spheres/FindSphere
From Liberty Unleashed Wiki
(Difference between revisions)
(→Example) |
|||
Line 1: | Line 1: | ||
− | + | {{Squirrel/Title|FindSphere}} | |
This function finds a sphere from an ID and returns the pointer. If no sphere is found, ''null'' will be returned. | This function finds a sphere from an ID and returns the pointer. If no sphere is found, ''null'' will be returned. | ||
Latest revision as of 10:35, 11 October 2010
This function finds a sphere from an ID and returns the pointer. If no sphere is found, null will be returned.
[edit] Syntax
Sphere FindSphere( int id [, Player plr ] )
[edit] Arguments
- id - The ID of the sphere to be found
- plr - If the sphere you want to find is for a specific client only, use this to specify a pointer to the player who owns the sphere. If you don't use this argument the sphere will be returned from the global sphere pool
[edit] Example 1. Non-player specific
function onPlayerCommand( player, command, text ) { if ( command == "findsphere" ) { local sphere = FindSphere( text.tointeger() ) if ( sphere ) MessagePlayer( "Sphere ID " + text + " has been found!", player ); else MessagePlayer( "Unable to find a sphere with ID " + text, player ); } }
This command is used to find the specified checkpoint ID.
[edit] Notes
The call onPlayerCommand was used in in this example. More info about this in the corresponding page.
[edit] Example 2. Player specific
function onPlayerCommand( player, command, text ) { if ( command == "findsphere" ) { local sphere = FindSphere( text.tointeger(), player ) if ( sphere ) MessagePlayer( "Sphere ID " + text + " has been found belonging to you!", player ); else MessagePlayer( "Unable to find a sphere with ID " + text + " belonging to you!", player ); } }
This command is used to find the specified checkpoint ID which relates to the command user.
[edit] Notes
The call onPlayerCommand was used in in this example. More info about this in the corresponding page.