setPedControlState | Multi Theft Auto: Wiki Skip to content

setPedControlState

Client-side
Server-side
Shared

This page is incomplete! Help wanted!

Please finish this page using the corresponding Old Wiki article.
Go to Contribution guidelines for more information.


This function makes a ped or player press or release a certain control.

Note

You can't use enter_exit or enter_passenger on a ped. Please use setPedEnterVehicle and setPedExitVehicle .

Note

To make a ped crouch, set the control to true and reset to false after one frame. Use setTimer with 0ms. Do the same to make the ped stand again.

Note

If you set the control state on the localPlayer element, then the control state is synchronized to every other client as if the input was made through the game input. But if you set any control states to server-side peds then the control state is not automatically synchronized. This behaviour is unaffected by being the syncer of the server-side ped or not. Let's assume that the syncer client calls setPedControlState on the ped. The other game clients - the ones where setPedControlState was not manually called by scripts - will see the ped teleport around. It will clearly look as if synchronization were broken.

Syntax

setPedControlState ( )

Code Examples

client
function newPed()
local x, y, z = getElementPosition(localPlayer)
local ped = createPed(0, x + 1, y, z)
if ped then
setPedControlState(ped, "forwards", true)
end
end
addCommandHandler("ped", newPed)

See Also