GetVehicleIDFromName
Jump to navigation
Jump to search
This function retrieves the ID of a vehicle as an integer value from its name.
Syntax
int getVehicleIDFromName ( string name )
Required Arguments
- name: A string containing the name of the vehicle.
Returns
Returns an int if the name exists, false otherwise.
Example
This will allow the player to create a vehicle by name and it's ID will be displayed in the chatbox when the vehicle is spawned.
addCommandHandler ( "spawnvehicle", "createvehiclecommand" ) function createvehiclecommand ( player, commandName, carname ) --This function is triggered by the text "spawncar" in the console. --The player must also specify the added varible carname to specify --what car they wish to spawn. carid = getVehicleIDFromName ( carname ) --Get the ID of the car the player asked for and store it to the --varible 'carid' 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 using it's ID. Spawn it at x + 5 from the player so it doesn't crush him if carid == "" then outputChatBox ( "That is not a valid car name" ) else outputChatBox ( "A vehicle with an ID of "..carid.." 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 ID. 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