SetPedControlState: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (Now it works with localPlayer, deleted the warning.)
mNo edit summary
Line 2: Line 2:
{{Client function}}
{{Client function}}
This function makes a [[ped]] or [[player]] press or release a certain control.
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.}}
{{Note|You can't use enter_exit or enter_passanger with a ped}}
 
 
{{New feature/item|3.0160|1.5|11427|
*Works with local player aswell.
}}


==Syntax==
==Syntax==
Line 22: Line 16:
===Returns===
===Returns===
Returns ''true'' if successful, ''false'' if otherwise.
Returns ''true'' if successful, ''false'' if otherwise.
==Example==
==Example==
<section name="Client" class="client" show="true">
<section name="Client" class="client" show="true">
Line 35: Line 30:
</syntaxhighlight>
</syntaxhighlight>
</section>
</section>
==Changelog==
{{ChangelogHeader}}
{{ChangelogItem|1.5.5-3.11427|Works with the [[getLocalPlayer|local player]] as well. Deprecated [[setControlState]] and [[getControlState]].}}


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

Revision as of 21:07, 8 July 2018

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

[[{{{image}}}|link=|]] Note: You can't use enter_exit or enter_passenger on a ped.

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)
  local myPed = createPed(0, x + 1, y, z)
  if myPed then 
    setPedControlState(myPed,"forwards", true)
  end 
end
addCommandHandler("ped",newPed)

Changelog

Version Description
1.5.5-3.11427 Works with the local player as well. Deprecated setControlState and getControlState.

See Also