CreateVehicle
From Liberty Unleashed Wiki
This function creates a new vehicle and returns a pointer to it. If the vehicle couldn't be created the function will return null.
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 ] )
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
Example
function onPlayerCommand( pPlayer, szCommand, szText ) { if ( szCommand == "veh" ) { CreateVehicle( VEH_INFERNUS, pPlayer.Pos, pPlayer.Angle, -1, -1 ); } return 1; }
Notes
The event onPlayerCommand was used in this example. More info about this in the corresponding page.
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