SetPedControlState: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
(3 intermediate revisions by 2 users not shown)
Line 8: Line 8:
bool setPedControlState ( ped thePed, string control, bool state )
bool setPedControlState ( ped thePed, string control, bool state )
</syntaxhighlight>
</syntaxhighlight>
{{OOP||[[Ped]]:setControlState}}


===Required Arguments===
===Required Arguments===
Line 21: Line 22:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function newPed()
function newPed()
  local x, y, z = getElementPosition(localPlayer)
    local x, y, z = getElementPosition(localPlayer)
  local myPed = createPed(0, x + 1, y, z)
    local ped = createPed(0, x + 1, y, z)
  if myPed then  
    if ped then  
    setPedControlState(myPed,"forwards", true)
        setPedControlState(ped, "forwards", true)
  end  
    end  
end
end
addCommandHandler("ped",newPed)
addCommandHandler("ped", newPed)
</syntaxhighlight>
</syntaxhighlight>
</section>
</section>

Revision as of 22:30, 5 November 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 )

OOP Syntax Help! I don't understand this!

Method: Ped:setControlState(...)


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 ped = createPed(0, x + 1, y, z)
    if ped then 
        setPedControlState(ped, "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