Squirrel/Server/Functions/Vehicles/CreateVehicle
From Liberty Unleashed Wiki
(Difference between revisions)
m (Bad link) |
(→Example) |
||
Line 19: | Line 19: | ||
== Example == | == Example == | ||
− | |||
<code lang="squirrel"> | <code lang="squirrel"> | ||
− | -- | + | function onPlayerCommand( pPlayer, szCommand, szText ) |
+ | { | ||
+ | if ( szCommand == "veh" ) | ||
+ | { | ||
+ | CreateVehicle( VEH_INFERNUS, pPlayer.Pos, pPlayer.Angle, -1, -1 ); | ||
+ | } | ||
+ | |||
+ | return 1; | ||
+ | } | ||
</code> | </code> | ||
=== Notes === | === Notes === | ||
− | + | 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
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:
Vehicle CreateVehicle( int model, Vector pos, float angle, [ int col1, int col2 ] )
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
function onPlayerCommand( pPlayer, szCommand, szText ) { if ( szCommand == "veh" ) { CreateVehicle( VEH_INFERNUS, pPlayer.Pos, pPlayer.Angle, -1, -1 ); } return 1; }
[edit] Notes
The event onPlayerCommand was used in this example. More info about this in the corresponding page.
[edit] Related Functions
- CreateVehicle
- FindVehicle
- GetClosestVehicle
- GetVehicleCount
- GetVehicleHandlingData
- GetVehicleIDFromName
- GetVehicleName
- SetVehicleHandlingData
- Vehicle.Alpha
- Vehicle.Angle
- Vehicle.Colour1
- Vehicle.Colour2
- Vehicle.Driver
- Vehicle.EngineDamage
- Vehicle.Explode
- Vehicle.Fix
- Vehicle.GetAddon
- Vehicle.GetPassenger
- Vehicle.GetHandlingData
- Vehicle.GetWheelStatus
- Vehicle.Health
- Vehicle.ID
- Vehicle.IdleRespawnTime
- Vehicle.IdleTime
- Vehicle.LightState
- Vehicle.Locked
- Vehicle.Marker
- Vehicle.MarkerScale
- Vehicle.MarkerSprite
- Vehicle.Model
- Vehicle.OneTime
- Vehicle.PassengerCount
- Vehicle.Pos
- Vehicle.Remove
- Vehicle.Respawn
- Vehicle.RespawnTime
- Vehicle.RGBColour1
- Vehicle.RGBColour2
- Vehicle.SetHandlingData
- Vehicle.SetWheelStatus
- Vehicle.SpawnAngle
- Vehicle.SpawnPos
- Vehicle.SetAddon
- Vehicle.SetEngineState
- Vehicle.SetRadio
- Vehicle.Siren
- Vehicle.SirenLight
- Vehicle.TaxiLight
- Vehicle.Velocity
- Vehicle.VirtualWorld
- Vehicle.Wrecked