Squirrel/Server/Functions/Objects/FindObject

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
 
Line 1: Line 1:
__NOTOC__
+
{{Squirrel/Title|FindObject}}
 
This function finds an object from an ID and returns the pointer. If no object is found, ''null'' will be returned.
 
This function finds an object from an ID and returns the pointer. If no object is found, ''null'' will be returned.
  

Latest revision as of 10:51, 11 October 2010

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

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

[edit] Syntax

  1. Object FindObject( int id )

[edit] Arguments

  • id - The ID of the object to be found

[edit] Example

  1.  
  2. function onPlayerCommand( player, cmd, text )
  3. {
  4. if ( cmd == "findobj" )
  5. {
  6. local obj;
  7. if ( text ) obj = FindObject( text.tointeger() );
  8.  
  9. if ( obj ) MessagePlayer( "Succesfully found object id: " + text + "!", player );
  10. else MessagePlayer( "Unable to find an object with id: " + text + "!", player );
  11. }
  12. }
  13.  

This command will try to find the specified object id.

[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