SA-MP Forums Archive
Detect if player is running - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Detect if player is running (/showthread.php?tid=631155)



Detect if player is running - gmstrikker - 24.03.2017

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


Re: Detect if player is running - SyS - 24.03.2017

checking the animation and velocity is better I think.


Re: Detect if player is running - NeXoR - 24.03.2017

Quote:
Originally Posted by Sreyas
Посмотреть сообщение
checking the animation and velocity is better I think.
Like he said ^
Check if the animation equals to the running animation


Re: Detect if player is running - gmstrikker - 30.03.2017

Quote:
Originally Posted by Sreyas
Посмотреть сообщение
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();