Scripting/Squirrel/Functions/CreateObject: Difference between revisions

From Vice City Multiplayer
Jump to navigation Jump to search
Caution icon
This wiki is using an old backup from 2020
Some information may be old/missing
No edit summary
No edit summary
 
(11 intermediate revisions by 3 users not shown)
Line 1: Line 1:
   
This function will create an object.
<pre>CreateObject( model, world, Vector( x, y, z ), alpha );</pre>
 
== Syntax ==
<source lang=squirrel>
 
function onPlayerCommand( player, cmd, text )
'''1'''
if ( cmd == "createobj" )
<pre>CreateObject( model, world, pos, alpha )</pre>
{  
'''2'''
if ( player.IsSpawned )
<pre>CreateObject( model, world, x, y, z, alpha )</pre>
{
 
if ( text )
== Arguments ==
{
 
local model = GetTok( text, " ", 1 );
'''1'''
if(IsNum(model))
* ''int'' '''model''' - The object model id
{
* ''int'' '''world''' - The world id
local x = player.Pos.x, y = player.Pos.y, z = player.Pos.z;
* ''Vector'' '''pos''' - The object pos
local Pos = Vector( x.tofloat(), y.tofloat(), z.tofloat() );
* ''int'' '''alpha''' - The object alpha
CreateObject( model.tointeger(), 0, Vector( x.tofloat(), y.tofloat(), z.tofloat() ), 255 );
'''2'''
}
* ''int'' '''model''' - The object model id.
    else PrivMessage( player, "Type must be an integer");
* ''int'' '''world''' - The world id.
}
* ''float'' '''x''' - The x pos of the object.
else PrivMessage( player, "/createobj <model id>");
* ''float'' '''y''' - The y pos of the object.
}
* ''float'' '''z''' - The z pos of the object.
else PrivMessage( player, "Spawn and then use this command again");
* ''int'' '''alpha''' - The object alpha.
}
 
  </source>
== Example ==
The following example create an object
<source lang=squirrel>
function onPlayerCommand( player, cmd, text );
{
if ( cmd == "obj" )
{
  CreateObject( 560, player.World, player.Pos, 255);
}
}
</source>
 
=== Notes ===
Call [[onPlayerCommand]] were used in this example. More info about them in the corresponding pages.
 
== Related Functions ==
 
{{Scripting/Squirrel/Functions/Object_Functions}}
[[Category:Scripting/Squirrel/Functions/Object_Functions]]

Latest revision as of 18:30, 30 January 2017

This function will create an object.

Syntax

1

CreateObject( model, world, pos, alpha )

2

CreateObject( model, world, x, y, z, alpha )

Arguments

1

  • int model - The object model id
  • int world - The world id
  • Vector pos - The object pos
  • int alpha - The object alpha

2

  • int model - The object model id.
  • int world - The world id.
  • float x - The x pos of the object.
  • float y - The y pos of the object.
  • float z - The z pos of the object.
  • int alpha - The object alpha.

Example

The following example create an object

function onPlayerCommand( player, cmd, text );
{
 if ( cmd == "obj" )
 {
  CreateObject( 560, player.World, player.Pos, 255);
 }
}

Notes

Call onPlayerCommand were used in this example. More info about them in the corresponding pages.

Related Functions