SetPedControlState: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client function}}
{{Client function}}
{{Needs Example}}
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]] press or release a certain control. It doesn't work with the local player, so use [[setControlState]] instead.


Line 20: Line 19:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function newPed()
function newPed()
local x, y, z = getElementPosition(localPlayer)
  local x, y, z = getElementPosition(localPlayer)
myPed = createPed(0, x + 1, y, z)
  local myPed = createPed(0, x + 1, y, z)
setPedControlState(myPed, "forwards", true)
  if myPed then
    setPedControlState(myPed,"forwards", true)
  end
end
end
addEventHandler("onClientResourceStart", resourceRoot, newPed)
addCommandHandler("ped",newPed)
</syntaxhighlight>
</syntaxhighlight>
</section>
</section>

Revision as of 14:03, 30 June 2016

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

See Also