Stop an animation?
#1

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;

Reply
#2

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.
Reply
#3

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

EDIT: This is not working! The animation still.
Reply
#4

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.
Reply
#5

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);
Reply
#6

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

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
Reply
#8

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.
Reply
#9

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 ?
Reply
#10

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); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)