Squirrel/Server/Functions/Vehicles/CreateVehicle

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
m (Bad link)
(Example)
 
Line 19: Line 19:
 
== Example ==
 
== Example ==
  
{{Squirrel/NeedsExample}}
 
 
<code lang="squirrel">
 
<code lang="squirrel">
-- todo
+
function onPlayerCommand( pPlayer, szCommand, szText )
 +
{
 +
if ( szCommand == "veh" )
 +
{
 +
CreateVehicle( VEH_INFERNUS, pPlayer.Pos, pPlayer.Angle, -1, -1 );
 +
}
 +
 
 +
return 1;
 +
}
 
</code>
 
</code>
  
 
=== Notes ===
 
=== Notes ===
  
Example notes and used functions here.
+
The event [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] was used in this example. More info about this in the corresponding page.
  
 
== Related Functions ==
 
== Related Functions ==
  
 
{{Squirrel/Server/Functions/Vehicles}}
 
{{Squirrel/Server/Functions/Vehicles}}

Latest revision as of 15:58, 29 September 2010

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

This function creates a new vehicle and returns a pointer to it. If the vehicle couldn't be created the function will return null.

[edit] Syntax

CreateVehicle can take different lists of parameters:

  1. Vehicle CreateVehicle( int model, Vector pos, float angle, [ int col1, int col2 ] )
  1. Vehicle CreateVehicle( int model, float x, float y, float z, float angle, [ int col1, int col2 ] )

[edit] Arguments

  • model - The model of the vehicle. See a list of vehicle model constants here
  • pos - The position of the new vehicle as a vector
  • angle - The rotation of the created vehicle in degrees
  • col1 - Colour 1 of the vehicle. Using -1 will select a random colour specific for that vehicle model. This is an optional argument
  • col2 - Colour 2 of the vehicle. Using -1 will select a random colour specific for that vehicle model. This is an optional argument
  • x, y, z - The position of the new vehicle as floats

[edit] Example

  1.  
  2. function onPlayerCommand( pPlayer, szCommand, szText )
  3. {
  4. if ( szCommand == "veh" )
  5. {
  6. CreateVehicle( VEH_INFERNUS, pPlayer.Pos, pPlayer.Angle, -1, -1 );
  7. }
  8.  
  9. return 1;
  10. }
  11.  

[edit] Notes

The event onPlayerCommand was used in this example. More info about this in the corresponding page.

[edit] Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox