ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Server functions
  3. setPedControlState

Function

setPedControlState

ServerPedsIdentical to MTA:SA

Presses or releases a virtual control of a ped, e.g. forwards (walk forward) or sprint. For NPCs every player's game carries out forwards, backwards and sprint, so the ped walks or runs the way it faces; other control names are stored for scripts and returned by getPedControlState. Names are the same as in bindKey/toggleControl (e.g. fire, jump, crouch, walk).

Syntax

bool setPedControlState(ped ped, string control, bool state)

Arguments

pedped
A player or an NPC.
controlstring
Control name, e.g. "forwards", "backwards", "sprint", "walk", "jump", "fire". It must be a valid name (isValidControlName).
statebool
true = pressed, false = released.

Returns

true on success, false for a bad name.

Example

local walker = createPed(7, 2490, -1670, 13.3, 180)
setPedControlState(walker, "forwards", true)
setTimer(setPedControlState, 5000, 1, walker, "forwards", false)

See also