GetVehicleType: Difference between revisions
Jump to navigation
Jump to search
Line 34: | Line 34: | ||
* '''Quad''': Quadbikes | * '''Quad''': Quadbikes | ||
==Example== | ==Example== | ||
In this example when a player enters an airplane, it displays a message welcoming the player onboard. | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function enterPlane(theVehicle, seat, jacked) | |||
if (getVehicleType(theVehicle) == "Plane") then | |||
outputChatBox("Welcome onboard!", source) | |||
end | |||
end | |||
addEventHandler("onPlayerVehicleEnter", getRootElement(), enterPlane) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 00:08, 5 May 2008
This function retrieves the type of a vehicle (such as if it is a car or a boat).
Syntax
string getVehicleType ( vehicle theVehicle )
OR
string getVehicleType ( int modelId )
Required Arguments
- vehicle: The vehicle element to get the type of.
- modelId: A vehicle model id
Returns
Returns a string with vehicle type or false if an invalid modelID has been supplied, or an empty string if the vehicle is blocked internally (some trailers).
Possible strings returned:
- Automobile: Cars, vans and trucks
- Plane
- Bike: Motorbikes
- Helicopter
- Boat
- Train
- Trailer: A trailer for a truck
- BMX
- Monster Truck
- Quad: Quadbikes
Example
In this example when a player enters an airplane, it displays a message welcoming the player onboard.
function enterPlane(theVehicle, seat, jacked) if (getVehicleType(theVehicle) == "Plane") then outputChatBox("Welcome onboard!", source) end end addEventHandler("onPlayerVehicleEnter", getRootElement(), enterPlane)
See Also
- addVehicleUpgrade
- attachTrailerToVehicle
- blowVehicle
- createVehicle
- detachTrailerFromVehicle
- fixVehicle
- getOriginalHandling
- getTrainDirection
- getTrainPosition
- getTrainSpeed
- getTrainTrack
- getVehicleColor
- getVehicleCompatibleUpgrades
- getVehicleController
- getVehicleDoorOpenRatio
- getVehicleDoorState
- getVehicleEngineState
- getVehicleHandling
- getVehicleHeadLightColor
- getVehicleLandingGearDown
- getVehicleLightState
- getVehicleMaxPassengers
- getVehicleModelFromName
- getVehicleName
- getVehicleNameFromModel
- getVehicleOccupant
- getVehicleOccupants
- getVehicleOverrideLights
- getVehiclePaintjob
- getVehiclePanelState
- getVehiclePlateText
- getVehicleSirenParams
- getVehicleSirens
- getVehicleSirensOn
- getVehicleTowedByVehicle
- getVehicleTowingVehicle
- getVehicleTurretPosition
- getVehicleType
- getVehicleUpgradeOnSlot
- getVehicleUpgradeSlotName
- getVehicleUpgrades
- getVehicleVariant
- getVehicleWheelStates
- isTrainDerailable
- isTrainDerailed
- isVehicleBlown
- isVehicleDamageProof
- isVehicleFuelTankExplodable
- isVehicleLocked
- isVehicleOnGround
- isVehicleTaxiLightOn
- removeVehicleUpgrade
- setTrainDerailable
- setTrainDerailed
- setTrainDirection
- setTrainPosition
- setTrainSpeed
- setTrainTrack
- setVehicleColor
- setVehicleDamageProof
- setVehicleDoorOpenRatio
- setVehicleDoorState
- setVehicleDoorsUndamageable
- setVehicleEngineState
- setVehicleFuelTankExplodable
- setVehicleHandling
- setVehicleHeadLightColor
- setVehicleLandingGearDown
- setVehicleLightState
- setVehicleLocked
- setVehicleOverrideLights
- setVehiclePaintjob
- setVehiclePanelState
- setVehiclePlateText
- setVehicleSirens
- setVehicleSirensOn
- setVehicleTaxiLightOn
- setVehicleTurretPosition
- setVehicleVariant
- setVehicleWheelStates