SA-MP Forums Archive
Stop an animation? - 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: Stop an animation? (/showthread.php?tid=608075)



Stop an animation? - Dayrion - 27.05.2016

Hello!
I have a stock which is making the player reloading. The player doing the animation, but he still with the animation.
I also try to set ClearAnimations(playerid) but like me though, this canceling player's animation. I, also, changed "timer" to try what change. Set to 1 second, do nothing. Set to 1 ms, cancel animation.
I don't want to set any timers.
Thanks for your help!
PHP код:
stock SetAnimationForWeapon(playeridweaponid)
{
    switch(
weaponid)
     {
           case 
22ApplyAnimation(playerid"COLT45""colt45_reload"4.101101);
        case 
23ApplyAnimation(playerid"SILENCED""Silence_reload"4.101101);
        case 
24ApplyAnimation(playerid"PYTHON""python_reload"4.101101);
        case 
2527ApplyAnimation(playerid"BUDDY""buddy_reload"4.101101);
        case 
26ApplyAnimation(playerid"COLT45""sawnoff_reload"4.101101);
        case 
29..313334ApplyAnimation(playerid"RIFLE""rifle_load"4.101111);
        case 
2832ApplyAnimation(playerid"TEC""tec_reload"4.101111);
        
//ApplyAnimation(playerid, animlib[], animname[], Float:fDelta, loop, lockx, locky, freeze, time, forcesync)
    
}
    return 
1;




Re: Stop an animation? - Konstantinos - 27.05.2016

There's time parameter which is in milliseconds. It never stops because you set it to 0, change its value to the interval you want the animation to be applied for how long.


Re: Stop an animation? - Dayrion - 27.05.2016

What is this interval? Time before cancelling anmiation? The time during the animation?

EDIT: This is not working! The animation still.



Re: Stop an animation? - iggy1 - 27.05.2016

Interval is amount of time to play animation in milliseconds. You are trying to play them for 1ms. I imagine that may be causing it, as your animations should only play for 1ms and not loop.

Try increasing to the amount of time you want the animation to play (assuming it's more than 1ms).

Your also leaving out for forcesync param, 10 parameters total. Incase you didn't notice and got parameters mixed up.


Re: Stop an animation? - Konstantinos - 27.05.2016

Actually the time is used when the loop is 1. Your parameters as iggy1 said are mixed up.

If you want to reload (do the animation) only once, set time to 0, freeze to 0 and loop to 0. I tested this with deagle:
pawn Код:
ApplyAnimation(playerid, "PYTHON", "python_reload", 4.1, 0, 1, 1, 0, 0, 1);



Re: Stop an animation? - karoliko - 27.05.2016

Im interested on this code for my server, can you share it to me please?


Re: Stop an animation? - Dayrion - 27.05.2016

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Actually the time is used when the loop is 1. Your parameters as iggy1 said are mixed up.

If you want to reload (do the animation) only once, set time to 0, freeze to 0 and loop to 0. I tested this with deagle:
pawn Код:
ApplyAnimation(playerid, "PYTHON", "python_reload", 4.1, 0, 1, 1, 0, 0, 1);
Alright, I put this
PHP код:
case 24ApplyAnimation(playerid"PYTHON""python_reload"4.1000001); 
and it's working but the player still freeze during the animation. :/
I want player can move even if he is reloading. I don't find where I can unfreeze the player.

EDIT: Even with this :
PHP код:
case 24ApplyAnimation(playerid"PYTHON""python_reload"4.1011001); 
This guy got the same problem. Unsolved : https://sampforum.blast.hk/showthread.php?tid=177384&page=2


Re: Stop an animation? - iggy1 - 27.05.2016

I think i get what you mean now, the player looses control while anim is played? So you can't run about while playing reloading animation? Unfortunately that's how anims work, you loose control while they play or get cancelled.

You will need some custom code to move the player while the animation is being played (SetPlayerPos/Angle/Velocity etc). Which most likely will not look very nice, or be very difficult to get it to look nice.


Re: Stop an animation? - Dayrion - 27.05.2016

There is a cleo mods which allows you to reload by pressing the key R. The player reload the gun and he can still walking or doing what he wants. I mean, even he's crounch he can reaload.
There is no issue exepect making the code by myself like iggy said ?


Re: Stop an animation? - Dayrion - 28.05.2016

Alright, this one allow you to move even if you are reloading BUT the animation still here.
PHP код:
case 24ApplyAnimation(playerid"PYTHON""python_reload"4.1000, -111);