ClearAnimations
#1

Hey, I wanted so that if the player presses the space bar it would stop the animation but the thing is when I press the space bar it also slows down my player, how can I create something that checks if I'm currently using an animation?

This is the code
pawn Код:
if(newkeys & KEY_SPRINT) return ClearAnimations(playerid);
Reply
#2

The only reliable way would be to keep track of a bool for each player to see if he used an animation command or not, then if it's true, don't clear it.

pawn Код:
new bool:doingAnim[MAX_PLAYERS char];

CMD:piss(playerid, params[]) {
    //Piss animation, I don't remember it off the top of my head
    doingAnim{playerid} = true;
    return 1;
}

//When player hits the space bar
if (newkeys & KEY_SPRINT) {
    if (doingAnim{playerid}) {
        ClearAnimations(playerid);
        doingAnim{playerid} = false;
    }
}
Reply
#3

This is really not reliable because it a player changed his sprint to left shift like me there they whould need to click left shift, the best to to make a cmd like /stopanim or /sa like in my server.
Reply
#4

I have that way on my server too, but it's pretty annoying and it would be so much better if a key press would stop the animation. Good point, though.

It would work if the player was frozen somehow, though. I think most animations lock the player anyway (correct me if I'm wrong), or as a last resort, TogglePlayerControllable(). I'm thinking a command might be best too now that I think about it...
Reply
#5

yes most anims do lock the player, that's why a cmd is best, if you don't have a cmd and your locker Spring enter and jump should get you out of it.
Reply
#6

Ah, thanks for helping me out guys, I'm using both now.
Reply
#7

Quote:
Originally Posted by Aveger
Посмотреть сообщение
This is really not reliable because it a player changed his sprint to left shift like me there they whould need to click left shift, the best to to make a cmd like /stopanim or /sa like in my server.
That's a client-side thing. The client tells the server which key (according to the define in the SA:MP client) has been pressed and then that's why KEY_LEFT or KEY_RIGHT remains the same.

As for the issue, you can hook the PlayAnimation (or w/e the function name is) to toggle the bool.
Reply
#8

Oh thanks for explaining realcop i actually did not know that heheh but i still think using both would be nice.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)