GetVehicleNameFromID: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 1: | Line 1: | ||
__NOTOC__ | {{Server client function}} | ||
__NOTOC__ | |||
Gets the name of a vehicle by its model id. | |||
==Syntax== | ==Syntax== | ||
Line 11: | Line 12: | ||
===Returns=== | ===Returns=== | ||
Returns | Returns the name of the vehicle if the id was valid, ''false'' otherwise. | ||
==Example== | ==Example== | ||
This will retrieve the name of a car so | This will retrieve the name of a car so its name can be displayed when the player chooses to spawn a car by ID. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function createvehiclecommand ( sourcePlayer, commandName, carid ) | |||
function createvehiclecommand ( | -- This function is triggered by the text "spawnvehicle" in the console. | ||
--This function is triggered by the text "spawnvehicle" in the console. | -- The player must specify the parameter 'carid' to specify | ||
--The player must | -- what car they wish to spawn. | ||
--what car they wish to spawn. | local x, y, z = getElementPosition ( thePlayer ) | ||
local x, y, z = getElementPosition ( | -- Get the position of the player to spawn the car near this location | ||
--Get the position of the player to spawn the car near this location | local carname = getVehicleNameFromID ( tonumber(carid) ) | ||
carname = getVehicleNameFromID ( carid ) | -- Get the name of the car the player asked for and store it in the | ||
--Get the name of the car the player asked for and store it | -- variable 'carname' | ||
-- | |||
if carname == false then | if carname == false then | ||
outputChatBox ( "That is not a valid car ID", sourcePlayer ) | |||
else | else | ||
createVehicle ( carid, 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 | end | ||
--If the entered car ID | -- If the entered car 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 | end | ||
addCommandHandler ( "spawnvehicle", createvehiclecommand ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Vehicle functions}} | {{Vehicle functions}} |
Revision as of 17:58, 17 August 2007
Gets the name of a vehicle by its model id.
Syntax
string getVehicleNameFromID ( int id )
Required Arguments
- id: This is a vehicle id. See vehicle to see what values will return names (true).
Returns
Returns the name of the vehicle if the 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 ID.
function createvehiclecommand ( sourcePlayer, commandName, carid ) -- This function is triggered by the text "spawnvehicle" in the console. -- The player must specify the parameter 'carid' 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 = getVehicleNameFromID ( tonumber(carid) ) -- Get the name of the car the player asked for and store it in the -- variable 'carname' if carname == false then outputChatBox ( "That is not a valid car ID", sourcePlayer ) else createVehicle ( carid, 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 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