Help me about animation
#1

How to check whether the player is performing any action ?
English my Bad. Sorry
Reply
#2

GetPlayerAnimationIndex for anims and GetPlayerSpecialAction for special actions.
Reply
#3

Quote:
Originally Posted by RogueDrifter
Посмотреть сообщение
GetPlayerAnimationIndex for anims and GetPlayerSpecialAction for special actions.
I tried it but it failed.
I just stand still
Although I do not use any action, it still fails.
Код:
cmd:mload(playerid, params[])
{
        if(GetPlayerAnimationIndex(playerid))
	{
	    SendClientMessageEx(playerid, -1, "You are using another action.");
	}
        return 1;
}
Reply
#4

no, read this:
https://sampwiki.blast.hk/wiki/GetPlayerAnimationIndex
and this:
https://sampwiki.blast.hk/wiki/GetPlayerSpecialAction
Reply
#5

thanks man
Reply
#6

it still bugs
Reply
#7

Please show me the code you're using, this can't be used without checking for the exact anim.
Reply
#8

Quote:
Originally Posted by RogueDrifter
Посмотреть сообщение
Please show me the code you're using, this can't be used without checking for the exact anim.
Код:
cmd:fixcar(playerid, params[])
{
          if(PI[playerid][pJob] == MECHANIC_MAN)
          {
                    if(IsPlayerInAnyVehicle(playerid))
		    {
		               SendClientMessageEx(playerid, RED, "You can not repair your car while in the car.");
		               return 1;
		    }
                    if(GetPlayerAnimationIndex(playerid))
	            {
	                       SendClientMessageEx(playerid, RED, "Please check that you are taking any action.");
                               return 1;
	            }
	            if(GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_NONE)
                    {
                               SendClientMessageEx(playerid, RED, "Please check that you are taking any action.");
                               return 1;
                    }
                    else
                    {
                               ApplyAnimation(playerid, "BD_FIRE", "wash_up", 4.0, 1, 0, 0, 0, 0, 1);
                               SendClientMessageEx(playerid, GREEN, "You are starting to repair car.");
                               return 1;
                    }
          }
          return 1;
}
Reply
#9

Would this be of any use?

Quote:
Originally Posted by bartekdvd
Посмотреть сообщение
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.
See the commands he's added so you can get an idea of how to use it.

pawn Код:
if(HasAnimationApplied(playerid, "BD_FIRE", "wash_up"))
{
    //They do.
}
else
{
    //They don't.
}
Reply
#10

Quote:
Originally Posted by hoanduy
Посмотреть сообщение
I tried it but it failed.
I just stand still
Although I do not use any action, it still fails.
Код:
cmd:mload(playerid, params[])
{
        if(GetPlayerAnimationIndex(playerid))
	{
	    SendClientMessageEx(playerid, -1, "You are using another action.");
	}
        return 1;
}
Because standing is an animation, running is an animation, shooting is an animation too, etc..
You could hook ApplyAnimation and ClearAnimations and set a boolean when the script set an animation and reset it when it clear any animation.
Refer you to this boolean to know if a player is running an animation or not.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)