Function to check a certain animation
#1

Okay so I made a command to place your hands up

Код:
ApplyAnimation(playerid, "PED", "HANDSUP", 4.1, 0, 0, 0, 1, 0, 1);
Havn't tried it yet, though

Then wanted to make a command(/cuff) that applies only when the player has his hands up.

So, what's the function to check if the player has his hands up? Or has the animation on or something?

Thanks in advance.
Reply
#2

Take a look at this:
https://sampwiki.blast.hk/wiki/GetPlayerAnimationIndex
Reply
#3

Quote:
Originally Posted by bartekdvd
Посмотреть сообщение
I did, and I'm not really sure how to apply this in my cuff command. Can you give me an example to check if the player has his hands up? Thanks.
Reply
#4

I think the easiest way would be to set a player variable for a player when he uses /handsup, and then check if the variable is true when you use /cuff.

If you're really into using the GetPlayerAnimationIndex
Approach like this:

Код:
new lib[32];
new index[32];
if(GetPlayerAnimationIndex(playerid)) GetAnimationName(GetPlayerAnimationIndex(playerid),lib,32,index,32);
if(strcmp(lib,"PED") == 0 && strcmp(index,"HANDSUP") == 0)
{
 //player will be cuffed
}
I did not test this
Reply
#5

Here is an example:
pawn Код:
#include <a_samp>

bool:HasAnimationApplied(playerid, animlib[], animname[])
{
    new l_animlib[32];
    new l_animname[32];
    GetAnimationName(GetPlayerAnimationIndex(playerid),l_animlib,32,l_animname,32);
    if (strcmp(animlib, l_animlib, true) == 0 && strcmp(animname, l_animname, true) == 0)
        return true;
    return false;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        // Do something here
        return 1;
    }
    else if (strcmp("/up", cmdtext, true, 3) == 0)
    {
        ApplyAnimation(playerid, "PED", "HANDSUP", 4.1, 0, 0, 0, 1, 0, 1);
        return 1;
    }
    else if (strcmp("/down", cmdtext, true, 5) == 0)
    {
         ClearAnimations(playerid);
         return 1;
    }
    else if (strcmp("/isup", cmdtext, true, 5) == 0 )
    {
        if (HasAnimationApplied(playerid, "PED", "HANDSUP"))
            SendClientMessage(playerid, 0xFFFFFFFF, "HANDSUP");
        else
            SendClientMessage(playerid, 0xFFFFFFFF, "HANDSDOWN");
           
        return 1;
    }
    return 0;
}
I have tested it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)