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=457440)
Detect if player is running -
Dodo9655 - 11.08.2013
What is the best way to detect if a player is running? Do you check if he presses UP and SPACE at the same time?
I need it for my cuff system. Thanks in advance.
Re: Detect if player is running -
ExTaZZ69 - 16.09.2016
I have this on my gamemode:
Код:
stock IsPlayerRunning(playerid)
{
if(!IsPlayerConnected(playerid) || IsPlayerInAnyVehicle(playerid)) return 0;
new keys, updown, leftright;
GetPlayerKeys(playerid, keys, updown, leftright);
if(keys & KEY_SPRINT && GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_USEJETPACK) return 1;
if(GetPlayerAnimationIndex(playerid))
{
new animlib[32], animname[32];
GetAnimationName(GetPlayerAnimationIndex(playerid),animlib,32,animname,32);
if(!strcmp(animlib, "PED"))
{
new const names[8][] = { "run_fat", "run_fatold", "run_old", "swat_run", "woman_run", "WOMAN_runbusy", "woman_runpanic", "WOMAN_runsexy" };
for(new i; i < sizeof(names); i++)
{
if(!strcmp(animname, names[i])) return 1;
}
}
}
return 0;
}