PDA

View Full Version : Detect if player is running


Dodo9655
11/08/2013, 05:17 PM
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.

ExTaZZ69
16/09/2016, 01:00 PM
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;
}