GetVehicleName: Difference between revisions
Jump to navigation
Jump to search
m (updated) |
No edit summary |
||
Line 1: | Line 1: | ||
__NOTOC__ | {{Server client function}} | ||
__NOTOC__ | |||
This function returns a string containing the name of the vehicle | This function returns a string containing the name of the vehicle | ||
Line 11: | Line 12: | ||
===Returns=== | ===Returns=== | ||
Returns a string containing the requested vehicle's name, or false if the vehicle passed to the function is invalid. | Returns a string containing the requested vehicle's name, or ''false'' if the vehicle passed to the function is invalid. | ||
==Example== | ==Example== | ||
This example checks whether a player enters an AT-400 or a Shamal. If they do, it announces it to the chat specifying what vehicle was stolen. | This example checks whether a player enters an AT-400 or a Shamal. If they do, it announces it to the chat specifying what vehicle was stolen. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function planeEnter ( theVehicle, seat, jacked ) --when someone enters a vehicle | function planeEnter ( theVehicle, seat, jacked ) -- when someone enters a vehicle | ||
local id = getVehicleID ( theVehicle ) -- get the ID of the vehicle | |||
if id == 519 or id == 577 then -- if theVehicle is one of these two planes | |||
local vehiclename = getVehicleName ( theVehicle ) -- define the vehicle name | |||
outputChatBox ( "Someone stole a " .. vehiclename .. "!" ) -- announce that someone stole the plane | |||
end | |||
end | end | ||
-- add the event to the event handler | -- add the event to the event handler |
Revision as of 17:35, 17 August 2007
This function returns a string containing the name of the vehicle
Syntax
string getVehicleName ( vehicle theVehicle )
Required Arguments
- theVehicle: The vehicle you want to get the name of.
Returns
Returns a string containing the requested vehicle's name, or false if the vehicle passed to the function is invalid.
Example
This example checks whether a player enters an AT-400 or a Shamal. If they do, it announces it to the chat specifying what vehicle was stolen.
function planeEnter ( theVehicle, seat, jacked ) -- when someone enters a vehicle local id = getVehicleID ( theVehicle ) -- get the ID of the vehicle if id == 519 or id == 577 then -- if theVehicle is one of these two planes local vehiclename = getVehicleName ( theVehicle ) -- define the vehicle name outputChatBox ( "Someone stole a " .. vehiclename .. "!" ) -- announce that someone stole the plane end end -- add the event to the event handler addEventHandler ( "onPlayerEnterVehicle", getRootElement(), planeEnter )
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