GetPedAnalogControlState: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
Fernando187 (talk | contribs) (Remove obsolete Requirements section) |
||
(3 intermediate revisions by one other user not shown) | |||
Line 19: | Line 19: | ||
==Example== | ==Example== | ||
This exmaple creating a ped can drive with command '''/drive''' | |||
<syntaxhighlight lang="lua"> | |||
local ped = createPed(0, 0,0,3) | |||
local vehicle = createVehicle(554,0,0,3) | |||
warpPedIntoVehicle(ped, vehicle) | |||
= | addCommandHandler("drive",function() | ||
isDriving = getPedAnalogControlState ( ped, "accelerate" ) -- get the analaog state of (accelerate) | |||
if isDriving==1 then -- checks if equals 1 that means is driving | |||
outputChatBox("Ped is driving stoping..") | |||
setPedAnalogControlState( ped, "accelerate", 0 ) -- set the analaog (accelerate) to 0 | |||
else | |||
outputChatBox("Starting drive") | |||
setPedAnalogControlState( ped, "accelerate", 1 ) -- set the analaog (accelerate) to 1 | |||
end | |||
end) | |||
</syntaxhighlight> | |||
==See Also== | ==See Also== |
Latest revision as of 17:12, 7 November 2024
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 if it should return the raw player input value (will always return script value for non-player peds).
Returns
Returns a float between 0 (full release) and 1 (full push) indicating the amount the control is pushed.
Example
This exmaple creating a ped can drive with command /drive
local ped = createPed(0, 0,0,3) local vehicle = createVehicle(554,0,0,3) warpPedIntoVehicle(ped, vehicle) addCommandHandler("drive",function() isDriving = getPedAnalogControlState ( ped, "accelerate" ) -- get the analaog state of (accelerate) if isDriving==1 then -- checks if equals 1 that means is driving outputChatBox("Ped is driving stoping..") setPedAnalogControlState( ped, "accelerate", 0 ) -- set the analaog (accelerate) to 0 else outputChatBox("Starting drive") setPedAnalogControlState( ped, "accelerate", 1 ) -- set the analaog (accelerate) to 1 end end)
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