Squirrel/Server/Functions/Spheres/FindSphere

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(Example)
 
Line 1: Line 1:
__NOTOC__
+
{{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

Home   |   Squirrel Scripting   |   Server Functions   |   Server Events   |   Client Functions   |   Client Events

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

[edit] Syntax

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

  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.

[edit] Notes

The call onPlayerCommand was used in in this example. More info about this in the corresponding page.

[edit] 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.

[edit] Notes

The call onPlayerCommand was used in in this example. More info about this in the corresponding page.

[edit] Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox