GetVehicleNameFromModel: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m (fix returned value) |
||
(2 intermediate revisions by one other user not shown) | |||
Line 7: | Line 7: | ||
string getVehicleNameFromModel ( int model ) | string getVehicleNameFromModel ( int model ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[ | {{OOP|This function is a static function underneath the Vehicle class.|[[Vehicle]].getNameFromModel}} | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''model:''' This is the vehicle model ID. See [[vehicle IDs]] to see what values will return names. | *'''model:''' This is the vehicle model ID. See [[vehicle IDs]] to see what values will return names. | ||
===Returns=== | ===Returns=== | ||
Returns the name of the vehicle if the model ID was valid, | Returns the name of the vehicle if the model ID was valid, ''false'' otherwise. | ||
==Example== | ==Example== | ||
Line 39: | Line 38: | ||
addCommandHandler ( "spawnvehicle", createVehicleCommand ) | addCommandHandler ( "spawnvehicle", createVehicleCommand ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Vehicle functions}} | {{Vehicle functions}} |
Latest revision as of 02:36, 19 April 2021
Gets the name of a vehicle by its model ID.
Syntax
string getVehicleNameFromModel ( int model )
OOP Syntax Help! I don't understand this!
- Note: This function is a static function underneath the Vehicle class.
- Method: Vehicle.getNameFromModel(...)
Required Arguments
- model: This is the vehicle model ID. See vehicle IDs to see what values will return names.
Returns
Returns the name of the vehicle if the model ID was valid, false otherwise.
Example
This will retrieve the name of a car so its name can be displayed when the player chooses to spawn a car by model ID.
function createVehicleCommand ( thePlayer, commandName, carModel ) -- This function is triggered by the text "spawnvehicle" in the console. -- The player must specify the parameter 'carModel' to specify -- what car they wish to spawn. local x, y, z = getElementPosition ( thePlayer ) -- Get the position of the player to spawn the car near this location local carName = getVehicleNameFromModel ( tonumber ( carModel ) ) -- Get the name of the car the player asked for and store it in the -- variable 'carName' if not carname then outputChatBox ( "That is not a valid car model ID", thePlayer ) else createVehicle ( tonumber ( carModel ), x + 5, y, z ) -- Spawn the car at x + 5 from the player so it doesn't crush him outputChatBox ( "A " .. carName .. " was created!" ) end -- If the entered car model ID is invalid, false will be returned. -- Otherwise a string is returned, we create the car and announce the car name in the chatbox. end addCommandHandler ( "spawnvehicle", createVehicleCommand )
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