getPedAnalogControlState
Client
Tells how far one of a ped's controls is pressed, from 0 to 1. It is meant for analog controls such as walking, steering and accelerating.
float|false getPedAnalogControlState(ped thePed, string control [, bool rawInput = false])
Parameters
| Name | Type | Description |
|---|---|---|
| thePed | ped | The ped or player. |
| control | string | The control's name, case insensitive. |
| rawInput | bool | Local player only: true reads the player's own input, before the states set by scripts and the controls turned off.default false |
Returns
A number from 0 to 1. A control that is not analog gives 0 or 1. false if the control name does not exist or the ped cannot be read; on a player, a name that does not exist gives 0.
On the local player it reads what the game gets this frame, including what setControlState turned on. On a remote player it reads the controls that came over the network. On a ped it reads what a script set on it.
Example
addEventHandler("onClientRender", root, function()
if isPedInVehicle(localPlayer) then
local throttle = getPedAnalogControlState(localPlayer, "accelerate")
dxDrawText(string.format("Acelerador: %d%%", throttle * 100), 20, 300)
end
end)