Squirrel/Server/Functions/Spheres/FindSphere

From Liberty Unleashed Wiki
Revision as of 04:01, 8 March 2010 by Force (Talk | contribs)

Jump to: navigation, search

This function finds a sphere from an ID and returns the pointer. If no sphere is found, null will be returned.

Syntax

  1. 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

  1.  
  2. function onPlayerCommand( player, command, text )
  3. {
  4. if ( command == "findsphere" )
  5. {
  6. local sphere = FindSphere( text.tointeger() )
  7. if ( sphere ) MessagePlayer( "Sphere ID " + text + " has been found!", player );
  8. else MessagePlayer( "Unable to find a sphere with ID " + text, player );
  9. }
  10. }
  11.  

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

  1.  
  2. function onPlayerCommand( player, command, text )
  3. {
  4. if ( command == "findsphere" )
  5. {
  6. local sphere = FindSphere( text.tointeger(), player )
  7. if ( sphere ) MessagePlayer( "Sphere ID " + text + " has been found belonging to you!", player );
  8. else MessagePlayer( "Unable to find a sphere with ID " + text + " belonging to you!", player );
  9. }
  10. }
  11.  

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.

Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox