SA-MP Forums Archive
IsPlayerRunning - 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: IsPlayerRunning (/showthread.php?tid=338580)



IsPlayerRunning - zgintasz - 30.04.2012

Hi guys,

Maybe someone have a function, to check, is player running? I know, I need to use GetPlayerAnimationIndex, but maybe someone already made this and can post it here ?

Thanks.


Re: IsPlayerRunning - 2KY - 30.04.2012

Use

pawn Код:
public OnPlayerUpdate(playerid)
{
    if(GetPlayerAnimationIndex(playerid))
    {
        new animlib[32];
        new animname[32];
        new msg[128];
        GetAnimationName(GetPlayerAnimationIndex(playerid),animlib,32,animname,32);
        format(msg, 128, "Running anim: %s %s", animlib, animname);
        SendClientMessage(playerid, 0xFFFFFFFF, msg);
    }
    return 1;
}
and run, get the animation name and do this:

pawn Код:
#define RUNANIM_LIB "RUNNING"
#define RUNANIM_NAME "RUN" // Change these obviously, because they're not correct.

stock IsPlayerRunning ( playerid )
{
new animlib[32], animname[32];
GetAnimationName(GetPlayerAnimationIndex(playerid),animlib,32,animname,32);

if( strcmp( animlib, RUNANIM_LIB, false ) && strcmp( animname, RUNANIM_NAME, false ) )
{
return true;
}
else return false;
}
Sorry about the indentation, school computers.. blah. That's my guess on how to do it; otherwise, check out IsPlayerSwimming and modify that to your needs.


Re: IsPlayerRunning - Vince - 30.04.2012

pawn Код:
stock IsPlayerRunning(playerid)
{
    new
        keys,
        ud,
        lr;

    GetPlayerKeys(playerid, keys, ud, lr);
   
    if(keys & KEY_WALK)
        return false;

    if(ud == 0 && lr == 0)
        return false;

    return true;
}
Something like that should suffice. Not tested.


Re: IsPlayerRunning - zgintasz - 30.04.2012

Yeah, I know it, but some skins have different running animations(I think). I'm lazy and I need all these animations indexes .

EDIT: Vince, I need to check it by animation...


Re: IsPlayerRunning - Finn - 30.04.2012

Laziness is not an excuse.

https://sampwiki.blast.hk/wiki/Animations


Re: IsPlayerRunning - SuperViper - 30.04.2012

pawn Код:
IsPlayerRunning(playerid)
{
    new ai = GetPlayerAnimationIndex(playerid);
    if(ai == 1231 || ai == 1266) return 1;
    return 0;
}