SetPedControlState: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 16: Line 16:
===Returns===
===Returns===
Returns ''true'' if successful, ''false'' if otherwise.
Returns ''true'' if successful, ''false'' if otherwise.
==Example==
<section name="Client" class="client" show="true">
<syntaxhighlight lang="lua">
function newPed()
local x, y, z = getElementPosition(localPlayer)
myPed = createPed(0, x + 1, y, z)
setPedControlState(myPed, "forwards", true)
end
addEventHandler("onClientResourceStart", resourceRoot, newPed)
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{Client ped functions}}
{{Client ped functions}}

Revision as of 11:45, 26 March 2016

Accessories-text-editor.png Script Example Missing Function SetPedControlState needs a script example, help out by writing one.

Before submitting check out Editing Guidelines Script Examples.

This function makes a ped press or release a certain control. It doesn't work with the local player, so use setControlState instead.

Syntax

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

Required Arguments

  • thePed: the ped you want to press or release a control.
  • control: the name of the control of which to change the state. See control names for a list of valid names.
  • state: the new control state. true means pressed, false is released.

Returns

Returns true if successful, false if otherwise.

Example

Click to collapse [-]
Client
function newPed()
local x, y, z = getElementPosition(localPlayer)
myPed = createPed(0, x + 1, y, z)
setPedControlState(myPed, "forwards", true)
end
addEventHandler("onClientResourceStart", resourceRoot, newPed)

See Also