GetVehicleType: Difference between revisions
Jump to navigation
Jump to search
(Replace to predefined variables.) |
|||
(8 intermediate revisions by 8 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server client function}} | {{Server client function}} | ||
{{New feature|3| | {{New feature|3|1.0| | ||
This function retrieves the type of a vehicle (such as if it is a car or a boat). | This function retrieves the type of a vehicle (such as if it is a car or a boat). | ||
}} | }} | ||
Line 8: | Line 8: | ||
string getVehicleType ( vehicle theVehicle ) | string getVehicleType ( vehicle theVehicle ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[vehicle]]:getVehicleType|vehicleType}} | |||
'''OR''' | '''OR''' | ||
Line 17: | Line 17: | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''vehicle:''' The vehicle element to get the type of. | *'''vehicle:''' The vehicle element to get the type of. | ||
*''' | |||
'''OR''' | |||
*'''modelID:''' A vehicle model ID | |||
===Returns=== | ===Returns=== | ||
Line 23: | Line 26: | ||
Possible strings returned: | Possible strings returned: | ||
{{VehicleTypes}} | |||
==Example== | ==Example== | ||
In this example when a player enters an airplane, it displays a message welcoming the player onboard. | '''Example 1:''' 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) | function enterPlane(theVehicle, seat, jacked) | ||
Line 43: | Line 37: | ||
end | end | ||
addEventHandler("onPlayerVehicleEnter", | addEventHandler("onPlayerVehicleEnter", root, enterPlane) | ||
</syntaxhighlight> | |||
'''Example 2:''' In this example player gets message what type of vehicle he just entered. | |||
<syntaxhighlight lang="lua"> | |||
function enteredVehicleType(theVehicle, seat, jacked) | |||
outputChatBox("You entered ".. getVehicleType(theVehicle) ..".", source) | |||
end | |||
addEventHandler("onPlayerVehicleEnter", root, enteredVehicleType) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Vehicle functions}} | {{Vehicle functions}} | ||
Latest revision as of 11:17, 12 June 2024
This function retrieves the type of a vehicle (such as if it is a car or a boat).
Syntax
string getVehicleType ( vehicle theVehicle )
OOP Syntax Help! I don't understand this!
- Method: vehicle:getVehicleType(...)
- Variable: .vehicleType
OR
string getVehicleType ( int modelId )
Required Arguments
- vehicle: The vehicle element to get the type of.
OR
- 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
Example 1: 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", root, enterPlane)
Example 2: In this example player gets message what type of vehicle he just entered.
function enteredVehicleType(theVehicle, seat, jacked) outputChatBox("You entered ".. getVehicleType(theVehicle) ..".", source) end addEventHandler("onPlayerVehicleEnter", root, enteredVehicleType)
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