SetPedControlState: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (Added a note for some users, this function wont work using enter_exit or enter_passanger on peds)
m (Now it works with localPlayer, deleted the warning.)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client function}}
{{Client function}}
This function makes a [[ped]] press or release a certain control. It doesn't work with the local player, so use [[setControlState]] instead.
This function makes a [[ped]] or [[player]] press or release a certain control.


{{Note|You can't use enter_exit or enter_passanger with a ped}}
{{Note|You can't use enter_exit or enter_passanger with a ped}}

Revision as of 21:51, 23 April 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_passanger with a ped


  • Works with local player aswell.

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)

See Also