Leg Break Animation bug (+rep)
#1

Hello, I've been scripting a Leg Breaking system similar to the one seen on LSRP,
and the animation seems to bug out and it freezes the player and whenever the animation stops playing it freezes the player, I've tried using a timer which stops the players animations and that doesnt work ethier,
here is my code,

Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if (pLegBroken[playerid])
	{
		if(newkeys & KEY_SPRINT || newkeys & KEY_JUMP)
		OnAnim{playerid} = true;
		ApplyAnimation(playerid,"PED","FALL_collapse",4.1,0,0,0,1,0);
		timerLegBreak[playerid] = SetTimerEx("LegBreakTimer", 2000, false, "d", playerid);
	}
Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
	if(issuerid != INVALID_PLAYER_ID && weaponid >= 22 && weaponid <= 38 && (bodypart == 7 || bodypart == 8))
    {
		if(pLegBroken[playerid] == false)
		{
			pLegBroken[playerid] = true;
			OnAnim{playerid} = true;
			FreezePlayer(playerid);
			ApplyAnimation(playerid,"PED","FALL_collapse",4.1,0,0,0,1,0);
   			SCM(playerid, COLOR_LIGHTRED, "-> You've been hit in the leg, you're going to struggle with running and jumping.");
   			timerLegBreak[playerid] = SetTimerEx("LegBreakTimer", 1000, false, "d", playerid);
    	}
	}
Код:
forward LegBreakTimer(playerid);
public LegBreakTimer(playerid)
{
	StopPlayerAnims(playerid);
}
Reply
#2

bump.
Reply
#3

https://sampwiki.blast.hk/wiki/ApplyAnimation

You have the "freeze" parameter 1, so the player will be frozen.

Also, before you run the timer, you should kill it to avoid multiple timers which can possibly be the cause of your legbreak bug.

pawn Код:
KillTimer(timerLegBreak[playerid]);
timerLegBreak[playerid] = SetTimerEx("LegBreakTimer", 2000, false, "d", playerid);
Reply
#4

Look Carefully, he has Freezing Param to 0.
Код:
 ApplyAnimation(playerid,"PED","FALL_collapse",4.1,0,0,0,1,0);
Problem is
Код:
 FreezePlayer(playerid);
Set somewhere after Animation to TogglePlayerControlAble(playerid, true);(or whatever you use for unfreeze) there needs to be somewhere that unfreezes player. add it in public LegBreakTimer(playerid) along with Stop Animation.

also the other problem is you are not looping animation. if you loop, player may not be freeze.

Use this:
Код:
 ApplyAnimation(playerid,"PED","FALL_collapse",4.1,1,0,0,0,0,1);
also Use i for playerid not d in settimer.
Код:
 SetTimerEx("LegBreakTimer", 2000, false, "i", playerid);
Hope it helps
Reply
#5

why you not create variable for /stopanim or what you use on yor server for stop anim .
not freeze player, anim stil play and player cannot stop that

Код:
 if (pLegBroken[playerid] == true)
{
  SCM(playerid,COLOR,"Cannot Stop anim When Leg Broken");
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)