M MY Multiplayer: Wiki
Side
Kind

setPedControlState

Client

Presses or releases one of a ped's controls as if it were a key, for example to make it walk, jump or shoot.

bool setPedControlState(string control, bool state [, ped thePed = localPlayer])

Parameters

NameTypeDescription
thePedpedThe ped or the local player. It can be left out, which means the local player.default localPlayer
controlstringThe control's name, case insensitive.
statebooltrue to hold it down, false to release it.

Returns

true if the state was applied. false if the control name does not exist or the ped cannot take controls.

On an analog control (walking, steering, accelerating, braking), true presses it all the way and releases the opposite control. A control turned off with toggleControl does not reach the game, even when a script presses it.

Example

local ped = createPed("male01", 2495.0, -1685.0, 13.5)
setPedControlState(ped, "forwards", true)
setTimer(function()
    setPedControlState(ped, "forwards", false)
end, 3000, 1)
Coming from MTABesides MTA's controls, MYMP has block (melee block) and reload.
NoteOn a remote player the function returns true but does nothing. On the local player, the player's own input on that control replaces the script's state.

See also