Squirrel/Server/Functions/Objects/ID
From Liberty Unleashed Wiki
(Difference between revisions)
(Created page with ' {{Squirrel/Title|Object.ID}} __NOTOC__ This ''Object'' class member returns the ID of the given object. == Syntax == <code>Integer object.ID</code> == Example == {{Squirrel/N…') |
|||
Line 1: | Line 1: | ||
− | |||
{{Squirrel/Title|Object.ID}} | {{Squirrel/Title|Object.ID}} | ||
__NOTOC__ | __NOTOC__ | ||
Line 9: | Line 8: | ||
== Example == | == Example == | ||
− | + | This will create a new object and return it's ID when a player types '/object' | |
− | + | ||
<code lang="squirrel"> | <code lang="squirrel"> | ||
− | - | + | function onPlayerCommand( pPlayer, szCommand, szText ) |
+ | { | ||
+ | if ( szCommand == "object" ) | ||
+ | { | ||
+ | local pPos = pPlayer.Pos, pObject; | ||
+ | pObject = CreateObject( 1378, pPos.x - 5, pPos.y, pPos.z ); | ||
+ | if ( pObject ) MessagePlayer( "Object created with ID " + pObject.ID, pPlayer ); | ||
+ | } | ||
+ | |||
+ | return 1; | ||
+ | } | ||
</code> | </code> | ||
=== Notes === | === Notes === | ||
− | + | The functions [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]] and [[Squirrel/Server/Functions/Players/Pos|Player.Pos]] and [[Squirrel/Server/Functions/Objects/CreateObject|CreateObject]] and event [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] were used in this example. More info about them in the corresponding pages. | |
Latest revision as of 00:07, 20 October 2010
This Object class member returns the ID of the given object.
[edit] Syntax
Integer object.ID
[edit] Example
This will create a new object and return it's ID when a player types '/object'
function onPlayerCommand( pPlayer, szCommand, szText ) { if ( szCommand == "object" ) { local pPos = pPlayer.Pos, pObject; pObject = CreateObject( 1378, pPos.x - 5, pPos.y, pPos.z ); if ( pObject ) MessagePlayer( "Object created with ID " + pObject.ID, pPlayer ); } return 1; }
[edit] Notes
The functions MessagePlayer and Player.Pos and CreateObject and event onPlayerCommand were used in this example. More info about them in the corresponding pages.