SA-MP Forums Archive
ApplyAnim after player landing - 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: ApplyAnim after player landing (/showthread.php?tid=623367)



ApplyAnim after player landing - shaun_baker - 30.11.2016

i have a problem with my code..

i would like the player do a animation after jumping and landing..

My Code work for the first time, but if i jump again or again, it bugs a little

Code:
Код:
new bhopAnim[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
	bhopAnim[playerid] = 0;
	return 1;
}
public OnPlayerUpdate(playerid)
{
     if(bhopAnim[playerid] == 1)
     {
          if(GetPlayerAnimationIndex(playerid))
          {
               new animlib[32], animname[32];
               GetAnimationName(GetPlayerAnimationIndex(playerid),animlib,32,animname,32);
               if(!strcmp(animname, "JUMP_LAND", true))
               {
     				ApplyAnimation(playerid, "PED","FALL_LAND", 4.1, 0,1,1,0,0);
                    SendClientMessage(playerid, 0xFFFFFFFF, "MakeAnimation");
                    SendClientMessage(playerid, 0xFFFFFFFF, "");
                    bhopAnim[playerid] = 0;
               }
          }
     }
     return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
     if((newkeys & KEY_JUMP) && !IsPlayerInAnyVehicle(playerid))
     {
          SendClientMessage(playerid, 0xFFFFFFFF, "if JUMP && !Car");
          SendClientMessage(playerid, 0xFFFFFFFF, "");
          if((oldkeys & KEY_UP) || (oldkeys & KEY_DOWN) || (oldkeys & KEY_LEFT) || (oldkeys & KEY_RIGHT) || (oldkeys & KEY_SPRINT))
          {
               SendClientMessage(playerid, 0xFFFFFFFF, "if (W || A || S || D || SHIFT)");
               SendClientMessage(playerid, 0xFFFFFFFF, "");
               bhopAnim[playerid] = 1;
          }
     }
     return 1;
}
thanks for your help


Re: ApplyAnim after player landing - TheRohlikar - 30.11.2016

How does it bug ?


Re: ApplyAnim after player landing - shaun_baker - 30.11.2016

My Code work for the first time, but if i jump again or again, it bugs a little

the first jump, animation = after landing = OK
second jump, animation = before landing = buggy :/


Re: ApplyAnim after player landing - TheRohlikar - 30.11.2016

Okay. But what exactly means buggy ?


Re: ApplyAnim after player landing - shaun_baker - 30.11.2016

it means, he make the animation before he landing ^^ and thats really gay :3


Re: ApplyAnim after player landing - TheRohlikar - 30.11.2016

Well, I would never do it in "OnPlayerUpdate"... That's a sh*t, because it's "started" whenever you do something, am I right ?

"This callback is called, on average, 30 times per second, per player; only use it when you know what it's meant for (or more importantly what it's NOT meant for). " (wiki)