Help me about animation -
hoanduy - 25.02.2018
How to check whether the player is performing any action ?
English my Bad. Sorry
Re: Help me about animation -
RogueDrifter - 25.02.2018
GetPlayerAnimationIndex for anims and GetPlayerSpecialAction for special actions.
Re: Help me about animation -
hoanduy - 25.02.2018
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;
}
Re: Help me about animation -
RogueDrifter - 25.02.2018
no, read this:
https://sampwiki.blast.hk/wiki/GetPlayerAnimationIndex
and this:
https://sampwiki.blast.hk/wiki/GetPlayerSpecialAction
Re: Help me about animation -
hoanduy - 25.02.2018
Quote:
Originally Posted by RogueDrifter
|
thanks man
Re: Help me about animation -
hoanduy - 25.02.2018
Quote:
Originally Posted by RogueDrifter
|
it still bugs
Re: Help me about animation -
RogueDrifter - 25.02.2018
Please show me the code you're using, this can't be used without checking for the exact anim.
Re: Help me about animation -
hoanduy - 26.02.2018
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;
}
Re: Help me about animation -
DobbysGamertag - 26.02.2018
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.
}
Re: Help me about animation -
Dayrion - 26.02.2018
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.