Detect if player is running
#1

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.
Reply
#2

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)