Squirrel/Server/Functions/Objects/FindObject

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(New page: __NOTOC__ This function finds an object from an ID and returns the pointer. If no object is found, ''null'' will be returned. == Syntax == <code>Object FindObject( int id )</code> == Ar...)
 
Line 12: Line 12:
 
== Example ==
 
== Example ==
  
{{Squirrel/NeedsExample}}
 
 
<code lang="squirrel">
 
<code lang="squirrel">
-- todo
+
function onPlayerCommand( player, cmd, text )
 +
{
 +
if ( cmd == "findobj" )
 +
{
 +
local obj;
 +
if ( text ) obj = FindObject( text.tointeger() );
 +
 
 +
if ( obj ) MessagePlayer( "Succesfully found object id: " + text + "!", player );
 +
else MessagePlayer( "Unable to find an object with id: " + text + "!", player );
 +
}
 +
}
 
</code>
 
</code>
 +
 +
This command will try to find the an object from the id given in the text.
  
 
=== Notes ===
 
=== Notes ===
  
-- Example notes here
+
The call [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] was used in in this example. More info about this in the corresponding page.
  
 
== Related Functions ==
 
== Related Functions ==
  
 
{{Squirrel/Server/Functions/Objects}}
 
{{Squirrel/Server/Functions/Objects}}

Revision as of 03:07, 8 March 2010

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

Syntax

  1. Object FindObject( int id )

Arguments

  • id - The ID of the object to be found

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 an object from the id given in the text.

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