Squirrel/Server/Functions/Spheres/FindSphere
From Liberty Unleashed Wiki
This function finds a sphere from an ID and returns the pointer. If no sphere is found, null will be returned.
Syntax
Sphere FindSphere( int id [, Player plr ] )
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
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.
Notes
The call onPlayerCommand was used in in this example. More info about this in the corresponding page.
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.
Notes
The call onPlayerCommand was used in in this example. More info about this in the corresponding page.