ClearAnimations - 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: ClearAnimations (
/showthread.php?tid=444878)
ClearAnimations -
RALL0 - 18.06.2013
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);
Re: ClearAnimations -
Alternative112 - 18.06.2013
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;
}
}
Re: ClearAnimations -
SwisherSweet - 18.06.2013
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.
Re: ClearAnimations -
Alternative112 - 18.06.2013
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...
Re: ClearAnimations -
SwisherSweet - 18.06.2013
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.
Re: ClearAnimations -
RALL0 - 18.06.2013
Ah, thanks for helping me out guys, I'm using both now.
Re: ClearAnimations -
Scenario - 18.06.2013
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.
Re: ClearAnimations -
SwisherSweet - 18.06.2013
Oh thanks for explaining realcop i actually did not know that heheh but i still think using both would be nice.