Animation help
#1

Hello. I'm having troubles with animations.

I pre-load all the animation libraries using this:
https://sampforum.blast.hk/showthread.php?tid=568189

Then, when I execute an ApplyAnimation, not works at all. I have a taser and bean bullet system, and I've to apply the animation when the player gets in touch with the bullet. Here is the code:

Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    if (hittype == BULLET_HIT_TYPE_PLAYER)
	{
		if(PlayerInfo[playerid][pFaction] == 1 && Beans[playerid] == 1 && weaponid == 25)
		{
			if(Freezed[hitid] == 0)
			{
			    ClearAnimations(hitid);
	            ApplyAnimation(hitid, "SWEET", "LaFin_Sweet", 4.1, 0, 1, 1, 1, 0);
	            TogglePlayerControllable(hitid, 0);
	            Freezed[hitid] = 1;
	            SetTimerEx("BeansBullet", 10000, false, "i", hitid);
		   	}
		   	return 0;
		}
		else if(Taser[playerid] == 1 && GetPlayerWeapon(playerid) == 23)
		{
	       	if(Tased[hitid] == 1) return 1;
	       	new Float:x, Float:y, Float:z;
	       	GetPlayerPos(hitid, x, y, z);
	       	ClearAnimations(hitid);
	       	ApplyAnimation(hitid, "PED", "KO_skid_front",4.1,0,1,1,1,0);
	       	SetTimerEx("RemoveTaserEffects", 5000, 0, "i", hitid);
			TogglePlayerControllable(hitid, 0);
	       	Tased[hitid] = 1;
	       	return 0;
		}
	}
    return 1;
}
First time the Animation is not applied. Sometimes I can see the animation playing during 1 second or less...
Second, the player who gets the damage stays on foot, no animation is applied.

Anyone can help me? Thanks!
Reply
#2

You do that that
Код:
ClearAnimations(...);
Would Stop Any Animation right?
Reply
#3

Yes but I do CrearAnimations because the player can be in another animation and then I use ApplyAnimation to apply the new animation, is this a problem?
Reply
#4

You need to preload the anim a line or so before playing the anim rather than just once for example on connect it must be done before the new anim or every so often
Reply
#5

I'm using:

Код:
public OnPlayerConnect(playerid)
{
PreloadAnimLib(playerid,"BOMBER"); PreloadAnimLib(playerid,"RAPPING");
			PreloadAnimLib(playerid,"SHOP"); PreloadAnimLib(playerid,"BEACH");
			PreloadAnimLib(playerid,"SMOKING"); PreloadAnimLib(playerid,"FOOD");
			PreloadAnimLib(playerid,"ON_LOOKERS"); PreloadAnimLib(playerid,"DEALER");
			PreloadAnimLib(playerid,"CRACK"); PreloadAnimLib(playerid,"CARRY");
			PreloadAnimLib(playerid,"COP_AMBIENT"); PreloadAnimLib(playerid,"PARK");
			PreloadAnimLib(playerid,"INT_HOUSE"); PreloadAnimLib(playerid,"FOOD");
			PreloadAnimLib(playerid,"PED"); PreloadAnimLib(playerid,"SWEET");
}

PreloadAnimLib(playerid, animlib[])
{
    ApplyAnimation(playerid, animlib, "null", 0.0, 0, 0, 0, 0, 0);
}
And the animation still don't work...
Reply
#6

You got TogglePlayerControllable after the animation, that's the problem. TogglePlayerControllable clears the player's animations so you need to put it before the animation.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)