- Documentation
- Server functions
- setPedAnalogControlState
Function
setPedAnalogControlState
Sets a ped's analog control within 0-1, i.e. how hard it is "pressed" (e.g. 0.5 = half throttle). The value is stored for scripts; in addition any value above 0 presses the regular control of that name and 0 releases it, so for NPCs forwards, backwards and sprint work in the game as with setPedControlState (without graded strength).
Syntax
bool setPedAnalogControlState(ped ped, string control, float state)Arguments
pedped- A player or an NPC.
controlstring- Control name, e.g.
"accelerate","forwards","vehicle_left". statefloat- Strength 0-1; values outside are clamped. 0 = released.
Returns
true on success.
Example
setPedAnalogControlState(walker, "forwards", 1)
See also
getPedAnalogControlStateReturns the strength of a ped's analog control (0-1) set withsetPedAnalogControlState. 0 means the control is not pressed.setPedControlStatePresses or releases a virtual control of a ped, e.g.forwards(walk forward) orsprint. For NPCs every player's game carries outforwards,backwardsandsprint, so the ped walks or runs the way it faces; other control names are stored for scripts and returned bygetPedControlState. Names are the same as inbindKey/toggleControl(e.g.fire,jump,crouch,walk).