Squirrel/Server/Functions/Objects/Remove
From Liberty Unleashed Wiki
(Difference between revisions)
(Created page with '{{Squirrel/Title|Object.Remove}} __NOTOC__ This ''Object'' class member removes the given object. == Syntax == <code>bool object.Remove()</code> == Example == {{Squirrel/Needs…') |
(→Example) |
||
Line 8: | Line 8: | ||
== Example == | == Example == | ||
− | + | This will remove object ID 0 when the player types '/remove' | |
− | + | ||
<code lang="squirrel"> | <code lang="squirrel"> | ||
− | + | function onPlayerCommand( pPlayer, szCommand, szText ) | |
+ | { | ||
+ | if ( szCommand == "remove" ) | ||
+ | { | ||
+ | local pObject = FindObject( 0 ); | ||
+ | |||
+ | if ( pObject ) pObject.Remove(); | ||
+ | } | ||
+ | |||
+ | return 1; | ||
+ | } | ||
</code> | </code> | ||
=== Notes === | === Notes === | ||
− | + | The function [[Squirrel/Server/Functions/Objects/FindObject|FindObject]] and event [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] were used in this example. More info about them in the corresponding pages. | |
− | + | ||
== Related Functions == | == Related Functions == | ||
{{Squirrel/Server/Functions/Objects}} | {{Squirrel/Server/Functions/Objects}} |
Latest revision as of 00:19, 20 October 2010
This Object class member removes the given object.
[edit] Syntax
bool object.Remove()
[edit] Example
This will remove object ID 0 when the player types '/remove'
function onPlayerCommand( pPlayer, szCommand, szText ) { if ( szCommand == "remove" ) { local pObject = FindObject( 0 ); if ( pObject ) pObject.Remove(); } return 1; }
[edit] Notes
The function FindObject and event onPlayerCommand were used in this example. More info about them in the corresponding pages.