GetVehicleNameFromID: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 18: | Line 18: | ||
This example does... | This example does... | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
--This | addCommandHandler ( "spawncar", "createcarcommand" ) | ||
function createcarcommand ( player, commandName, carid ) | |||
-- | --This function is triggered by the text "spawncar" in the console. | ||
--The player must also specify the added varible carid to specify | |||
--what car they wish to spawn. | |||
local x, y, z = getElementPosition ( player ) | |||
--Get the position of the player to spawn the car near this location | |||
createVehicle ( carid, x + 5, y, z ) | |||
--Spawn the car at x + 5 from the player so it doesn't crush him | |||
carname = getVehicleNameFromID ( carid ) | |||
--Get the name of the car the player asked for and store it to the | |||
--varible 'carname' | |||
if carname == "" then | |||
outputChatBox ( "That is not a valid car ID" ) | |||
else | |||
outputChatBox ( "A "..carname.." was created!" ) | |||
end | |||
--A string is always returned in this situation, so if the car doesn't | |||
--exist the string has no values. If the string does have any value, we | |||
--announce it in the chatbox because it is a vehicle. | |||
end | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Vehicle functions}} | {{Vehicle functions}} |
Revision as of 08:18, 11 April 2007
Allows you to input a vehicleID and return a vehicle name from that 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 true if vehicle exists, false otherwise.
Example
This example does...
addCommandHandler ( "spawncar", "createcarcommand" ) function createcarcommand ( player, commandName, carid ) --This function is triggered by the text "spawncar" in the console. --The player must also specify the added varible carid to specify --what car they wish to spawn. local x, y, z = getElementPosition ( player ) --Get the position of the player to spawn the car near this location createVehicle ( carid, x + 5, y, z ) --Spawn the car at x + 5 from the player so it doesn't crush him carname = getVehicleNameFromID ( carid ) --Get the name of the car the player asked for and store it to the --varible 'carname' if carname == "" then outputChatBox ( "That is not a valid car ID" ) else outputChatBox ( "A "..carname.." was created!" ) end --A string is always returned in this situation, so if the car doesn't --exist the string has no values. If the string does have any value, we --announce it in the chatbox because it is a vehicle. end
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