Squirrel/Server/Functions/Objects/FindObject
From Liberty Unleashed Wiki
(Difference between revisions)
Line 1: | Line 1: | ||
− | + | {{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
This function finds an object from an ID and returns the pointer. If no object is found, null will be returned.
[edit] Syntax
Object FindObject( int id )
[edit] Arguments
- id - The ID of the object to be found
[edit] Example
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 ); } }
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.