GetTrainPosition
Jump to navigation
Jump to search
Gets the position the train is currently on the track
Syntax
float getTrainPosition ( vehicle train )
OOP Syntax Help! I don't understand this!
- Method: vehicle:getTrainPosition(...)
- Variable: .trainPosition
- Counterpart: setTrainPosition
Required Arguments
- train: the train to get the position of
Returns
Returns a float that represents how along the track it is, false if there is problem with train element.
Example
Click to collapse [-]
Server scriptThis example adds a command called "/getpos", allowing you to get the position of the train.
function position(player) if player and isElement(player) then if isPedInVehicle(player) then -- make sure we're actually in a vehicle local vehicle = getPedOccupiedVehicle(player) if vehicle then local vehType = getVehicleType (vehicle) if vehType == "Train" then -- make sure we're in a train local position = getTrainPosition (vehicle) outputChatBox("The Train position is: "..position) else outputChatBox("You are not in a train!") end end else outputChatBox("You are not in a vehicle!") end end end addCommandHandler("getpos",position)
See Also
- addVehicleSirens
- addVehicleUpgrade
- attachTrailerToVehicle
- blowVehicle
- createVehicle
- detachTrailerFromVehicle
- fixVehicle
- getModelHandling
- getOriginalHandling
- getTrainDirection
- getTrainPosition
- getTrainSpeed
- getVehicleColor
- getVehicleCompatibleUpgrades
- getVehicleController
- getVehicleDoorOpenRatio
- getVehicleDoorState
- getVehicleEngineState
- getVehicleHandling
- getVehicleHeadLightColor
- getVehicleLandingGearDown
- getVehicleLightState
- getVehicleMaxPassengers
- getVehicleModelFromName
- getVehicleName
- getVehicleNameFromModel
- getVehicleOccupant
- getVehicleOccupants
- getVehicleOverrideLights
- getVehiclePaintjob
- getVehiclePanelState
- getVehiclePlateText
- getVehicleRespawnPosition
- getVehicleRespawnRotation
- getVehicleSirenParams
- getVehicleSirens
- getVehicleSirensOn
- getVehiclesOfType
- getVehicleTowedByVehicle
- getVehicleTowingVehicle