PDA

View Full Version : Detect if player is running


gmstrikker
24/03/2017, 05:29 AM
Anybody know a best way to detect if player is running?

I trying this:

if(HOLDING(KEY_SPRINT) || PRESSING(newkeys, KEY_SPRINT ))
{
if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
{
PlayerRunning(playerid);
}
}
if(RELEASED(KEY_SPRINT))
{
CounterStopRunning[playerid] = SetTimerEx("PlayerNotRunning", 100, 0, "i", playerid);
}


But sometimes it bug, when player fall, player anim...
Its show player running when player is not and show player not running when player is running

SyS
24/03/2017, 07:00 AM
checking the animation and velocity is better I think.

NeXoR
24/03/2017, 07:13 AM
checking the animation and velocity is better I think.

Like he said ^
Check if the animation equals to the running animation

gmstrikker
30/03/2017, 08:28 AM
checking the animation and velocity is better I think.

You mean checking anim ID?
GetPlayerAnimationIndex(playerid) == X
Because it's sometimes bug here with no UsePlayerPedAnims();