GetPedAnalogControlState: Difference between revisions
Jump to navigation
Jump to search
m (fix typo) |
|||
Line 19: | Line 19: | ||
Returns a float between 0 ( full release ) and 1 ( full push ) indicating the amount the control is pushed. | Returns a float between 0 ( full release ) and 1 ( full push ) indicating the amount the control is pushed. | ||
== | <section name="Client-side example" class="client" show="true"> | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
x, y, z = getElementPosition(localPlayer) | |||
rotX, rotY, rotZ = getElementRotation(localPlayer) | |||
local playervehicle = getPedOccupiedVehicle(localPlayer) | |||
CJ = createPed(0, x, y, z) | |||
CJ2 = createPed(0, x, y, z) | |||
copcar = createVehicle(597, x, y+5, z+2) | |||
copcar2 = createVehicle(597, x+2, y+10, z+4) | |||
warpPedIntoVehicle(CJ2, copcar2, 0) | |||
warpPedIntoVehicle(CJ, copcar, 0) | |||
function onGetCJAnalogControlState() | |||
setPedAnalogControlState(CJ, "accelerate", 0.90) | |||
if getPedAnalogControlState(CJ, "accelerate", 0.90) then | |||
setPedAnalogControlState(CJ2, "brake_reverse", 0.90) | |||
end | |||
end | |||
addEventHandler("onClientRender", getRootElement(), onGetCJAnalogControlState) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | |||
<br /><br /> | |||
* This example was created by '''Hydra'''. | |||
==Requirements== | ==Requirements== |
Revision as of 16:09, 2 March 2020
Script Example Missing Function GetPedAnalogControlState needs a script example, help out by writing one. | |
Before submitting check out Editing Guidelines Script Examples. |
This function retrieves the analog control state of a ped, as set by setPedAnalogControlState.
Syntax
float getPedAnalogControlState ( ped thePed, string controlName [, bool rawValue ] )
Required Arguments
- thePed: The ped you wish to retrieve the control state of.
- controlName: The control. See control names for a list of possible controls.
Optional Arguments
- rawValue: A bool indicating whether to poll for raw controller state, which ignores keyboard input and any overrides from setPedAnalogControlState and others. When set to true, and a controller is not used, the function will always return 0.
Returns
Returns a float between 0 ( full release ) and 1 ( full push ) indicating the amount the control is pushed.
Click to collapse [-]
Client-side examplex, y, z = getElementPosition(localPlayer) rotX, rotY, rotZ = getElementRotation(localPlayer) local playervehicle = getPedOccupiedVehicle(localPlayer) CJ = createPed(0, x, y, z) CJ2 = createPed(0, x, y, z) copcar = createVehicle(597, x, y+5, z+2) copcar2 = createVehicle(597, x+2, y+10, z+4) warpPedIntoVehicle(CJ2, copcar2, 0) warpPedIntoVehicle(CJ, copcar, 0) function onGetCJAnalogControlState() setPedAnalogControlState(CJ, "accelerate", 0.90) if getPedAnalogControlState(CJ, "accelerate", 0.90) then setPedAnalogControlState(CJ2, "brake_reverse", 0.90) end end addEventHandler("onClientRender", getRootElement(), onGetCJAnalogControlState)
- This example was created by Hydra.
Requirements
Note: Using this feature requires the resource to have the above minimum version declared in the meta.xml <min_mta_version> section. e.g. <min_mta_version client="1.3.0-9.04185" />
See Also
- addPedClothes
- getPedClothes
- removePedClothes
- createPed
- getPedAmmoInClip
- getPedArmor
- getPedFightingStyle
- getPedOccupiedVehicle
- getPedOccupiedVehicleSeat
- getPedStat
- getPedTarget
- getPedTotalAmmo
- getPedWalkingStyle
- getPedWeapon
- getPedWeaponSlot
- getPedContactElement
- getValidPedModels
- isPedChoking
- isPedDead
- isPedDoingGangDriveby
- isPedDucked
- isPedHeadless
- isPedInVehicle
- isPedOnFire
- isPedOnGround
- isPedWearingJetpack
- killPed
- removePedFromVehicle
- setPedAnimation
- setPedAnimationProgress
- setPedAnimationSpeed
- setPedArmor
- setPedDoingGangDriveby
- setPedFightingStyle
- setPedHeadless
- setPedOnFire
- setPedStat
- setPedWalkingStyle
- setPedWeaponSlot
- warpPedIntoVehicle