Squirrel/Server/Functions/Objects/ID

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(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 ==
  
{{Squirrel/NeedsExample}}
+
This will create a new object and return it's ID when a player types '/object'
Explanation for the example
+
  
 
<code lang="squirrel">
 
<code lang="squirrel">
-- Todo
+
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 ===
  
-- List of used functions and other notes here.  
+
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

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


This Object class member returns the ID of the given object.

[edit] Syntax

  1. Integer object.ID

[edit] Example

This will create a new object and return it's ID when a player types '/object'

  1.  
  2. function onPlayerCommand( pPlayer, szCommand, szText )
  3. {
  4. if ( szCommand == "object" )
  5. {
  6. local pPos = pPlayer.Pos, pObject;
  7. pObject = CreateObject( 1378, pPos.x - 5, pPos.y, pPos.z );
  8. if ( pObject ) MessagePlayer( "Object created with ID " + pObject.ID, pPlayer );
  9. }
  10. return 1;
  11. }
  12.  

[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.


[edit] Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox