SetVehicleGravity: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
No edit summary |
||
Line 15: | Line 15: | ||
Returns ''true'' if successful, ''false'' otherwise. | Returns ''true'' if successful, ''false'' otherwise. | ||
===Example=== | |||
This example will set 0 gravity to the vehicle if a local player enters it | |||
<syntaxhighlight lang="lua"> | |||
addEventHandler("onClientVehicleEnter",getRootElement(),function(thePlayer) | |||
if (thePlayer == localPlayer) then -- if thePlayer is localPlayer | |||
local gravity = setVehicleGravity(source,0,0,0) -- Set the gravity | |||
if (gravity) then -- If the gravity was set succesfully | |||
local gravity_pos = Vector3(getVehicleGravity(source)) -- get the gravity vector | |||
outputChatBox("Gravity was set to "..gravity_pos.x.." "..gravity_pos.y.." "..gravity_pos.z,0,255,0) -- output to chat | |||
end | |||
end | |||
end) | |||
</syntaxhighlight> | |||
==See Also== | ==See Also== | ||
{{Client vehicle functions}} | {{Client vehicle functions}} |
Revision as of 11:28, 12 July 2017
Script Example Missing Function SetVehicleGravity needs a script example, help out by writing one. | |
Before submitting check out Editing Guidelines Script Examples. |
Sets the gravity vector of a vehicle. The vehicle will fall in this direction, and the camera of any occupants will also be rotated to match it. Can be used for e.g. driving on walls or upside down on ceilings.
Syntax
bool setVehicleGravity ( vehicle theVehicle, float x, float y, float z )
Required Arguments
- theVehicle: the vehicle of which to change the gravity.
- x, y, z: the components of the new gravity vector. If this vector has length 1, the strength of the gravity will be same as the global gravity for other entities. If it is 2, it will be twice as strong, etc.
Returns
Returns true if successful, false otherwise.
Example
This example will set 0 gravity to the vehicle if a local player enters it
addEventHandler("onClientVehicleEnter",getRootElement(),function(thePlayer) if (thePlayer == localPlayer) then -- if thePlayer is localPlayer local gravity = setVehicleGravity(source,0,0,0) -- Set the gravity if (gravity) then -- If the gravity was set succesfully local gravity_pos = Vector3(getVehicleGravity(source)) -- get the gravity vector outputChatBox("Gravity was set to "..gravity_pos.x.." "..gravity_pos.y.." "..gravity_pos.z,0,255,0) -- output to chat end end end)
See Also
- areVehicleLightsOn
- getHeliBladeCollisionsEnabled
- getHelicopterRotorSpeed
- getVehicleAdjustableProperty
- getVehicleComponentPosition
- getVehicleComponentRotation
- getVehicleComponents
- getVehicleComponentScale
- getVehicleComponentVisible
- getVehicleCurrentGear
- getVehicleDummyPosition
- getVehicleGravity
- getVehicleLandingGearDown
- getVehicleModelDummyDefaultPosition
- getVehicleModelDummyPosition
- getVehicleModelExhaustFumesPosition
- getVehicleModelWheelSize
- getVehicleNitroCount
- getVehicleNitroLevel
- getVehicleWheelFrictionState
- getVehicleWheelScale
- isTrainChainEngine
- isVehicleNitroActivated
- isVehicleNitroRecharging
- isVehicleOnGround
- isVehicleWheelOnGround
- isVehicleWindowOpen
- resetVehicleComponentPosition
- resetVehicleComponentRotation
- resetVehicleComponentScale
- resetVehicleDummyPositions
- setHeliBladeCollisionsEnabled
- setHelicopterRotorSpeed
- setVehicleAdjustableProperty
- setVehicleComponentPosition
- setVehicleComponentRotation
- setVehicleComponentScale
- setVehicleComponentVisible
- setVehicleDummyPosition
- setVehicleGravity
- setVehicleLandingGearDown
- setVehicleModelDummyPosition
- setVehicleModelExhaustFumesPosition
- setVehicleModelWheelSize
- setVehicleNitroActivated
- setVehicleNitroCount
- setVehicleNitroLevel
- setVehicleWheelScale
- setVehicleWheelStates
- setVehicleWindowOpen
- Shared
- 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