- Documentation
- Server functions
- getPedMoveState
Function
getPedMoveState
Estimates how a ped is moving right now: stand, walk, powerwalk, jog or sprint. The result follows from the ped's speed, or from the walk/sprint control when a script pressed it. Useful e.g. for fatigue or footstep noise systems.
Syntax
string getPedMoveState(ped ped)Arguments
pedped- A player or an NPC.
Returns
stand, walk, powerwalk, jog or sprint.
Example
setTimer(function()
for _, p in ipairs(getElementsByType("player")) do
if getPedMoveState(p) == "sprint" then outputChatBox("Biegniesz!", p) end
end
end, 2000, 0)
See also
getElementVelocityReturns the element's velocity. Units: 1 is 50 m/s, so km/h is the vector length times 180.setPedControlStatePresses or releases a virtual control of a ped, e.g.forwards(walk forward) orsprint. For NPCs every player's game carries outforwards,backwardsandsprint, so the ped walks or runs the way it faces; other control names are stored for scripts and returned bygetPedControlState. Names are the same as inbindKey/toggleControl(e.g.fire,jump,crouch,walk).