SetTrainSpeed: Difference between revisions
Jump to navigation
Jump to search
m (Needs example) |
(setting example (from setTrainDerailable, + my part)) |
||
Line 15: | Line 15: | ||
==Example== | ==Example== | ||
<section name="Example" class="server" show="true"> | |||
This example will make a train east of LS station which can not be derailed, and start moving it. | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- | function makeTrain(source) | ||
local myTrain = createVehicle(537,1995,-1949,13) -- This will make a freight train just east of the LS train station | |||
setTrainDerailable(myTrain, false) -- myTrain can not be derailed now | |||
outputChatBox("A freight train has been created for you.", source, 255, 255, 0) -- Just a simple message for the player | |||
warpPedIntoVehicle(source, myTrain) -- This will warp you to inside the train | |||
setTrainSpeed(myTrain, 1) -- Set the train speed to 1 - 100mp/h, 160km/h | |||
end | |||
addCommandHandler("trainmeup", makeTrain) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | |||
==See Also== | ==See Also== | ||
{{Vehicle functions}} | {{Vehicle functions}} | ||
[[Category:Needs Example]] | [[Category:Needs Example]] |
Revision as of 07:05, 23 April 2011
Sets the on-track speed of a train.
Syntax
bool setTrainSpeed ( vehicle train, float speed )
Required Arguments
- train: the train whose speed to change.
- speed: the new on-track speed of the train. A positive value will make it go clockwise, a negative value counter clockwise.
Returns
Returns true if successful, false otherwise.
Example
Click to collapse [-]
ExampleThis example will make a train east of LS station which can not be derailed, and start moving it.
function makeTrain(source) local myTrain = createVehicle(537,1995,-1949,13) -- This will make a freight train just east of the LS train station setTrainDerailable(myTrain, false) -- myTrain can not be derailed now outputChatBox("A freight train has been created for you.", source, 255, 255, 0) -- Just a simple message for the player warpPedIntoVehicle(source, myTrain) -- This will warp you to inside the train setTrainSpeed(myTrain, 1) -- Set the train speed to 1 - 100mp/h, 160km/h end addCommandHandler("trainmeup", makeTrain)
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