From Multi Theft Auto: Wiki
Revision as of 00:54, 8 July 2018 by Myonlake (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Sets an analog state of a specified ped's control, as if they pressed or released it.

This function only works on peds, to change the analog control state for a player, please use setAnalogControlState.


bool setPedAnalogControlState ( ped thePed, string control, float state ) 

Required Arguments

  • thePed: The ped you wish to set the control state of.
  • control: The control that you want to set the state of. See control names for a list of possible controls.
  • state: A float between 0 and 1 indicating the amount the control is pressed.


Returns true if the control state was successfully set, false otherwise.


This example uses setPedAnalogControlState to very slowly accelerate a ped-controlled NRG-500.

function createAnalogControlTest( )
    local playerPosition = Vector3( getElementPosition( localPlayer ) )
    local theVehicle = createVehicle( 522, playerPosition )
    local thePed = createPed( 0, playerPosition )

    warpPedIntoVehicle( thePed, theVehicle )

    setPedAnalogControlState( thePed, "accelerate", 0.05 )
    setPedAnalogControlState( thePed, "vehicle_left", 1 )
addCommandHandler( "analogcontroltest", createAnalogControlTest )


Minimum server version n/a
Minimum client version 1.3.0-9.04185

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