PDA

View Full Version : ApplyAnim after player landing


shaun_baker
30/11/2016, 08:35 PM
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

TheRohlikar
30/11/2016, 10:08 PM
How does it bug ?

shaun_baker
30/11/2016, 10:18 PM
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 :/

TheRohlikar
30/11/2016, 10:24 PM
Okay. But what exactly means buggy ? :D

shaun_baker
30/11/2016, 10:29 PM
it means, he make the animation before he landing ^^ and thats really gay :3

TheRohlikar
30/11/2016, 10:33 PM
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)