SA-MP Forums Archive
ApplyAnimation - 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: ApplyAnimation (/showthread.php?tid=312067)



ApplyAnimation - Gooday - 19.01.2012

So: i would like to make a script for the cops who:

*cop uses the baton to another player*

*apply player anymation CRACK*

So whehn a cop uses the baton to another player the other player got a animation for 20 secs


Re: ApplyAnimation - 2KY - 19.01.2012

You'll need:

ApplyAnimation, //Function
OnPlayerTakeDamage, // Callback
SetTimerEx //Function
ClearAnimations //Function

Simply, inside of the callback, check if their weapon (the issuerid) is a police baton, and apply the animation (don't forget to apply it twice, unless you preload animations!) to the playerid (the player taking the damage) and set a timer to clear their animations using ClearAnimations(playerid);

Simple.


Re: ApplyAnimation - Gooday - 19.01.2012

sorry but im a crap at scripting can you post a example? +REP!


Re: ApplyAnimation - 2KY - 19.01.2012

Sure.

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    if(issuerid != INVALID_PLAYER_ID) {
   
        switch(weaponid) {
       
            case 3: //Police baton!
            {
                ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
                ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0); //Apply it twice!
                TogglePlayerControllable(playerid, 0);
                SetTimerEx("ClearAnims", 20*1000, 0, "i", playerid);
            }
        }
   
    }
    return 1;
}

forward ClearAnims(playerid);
public ClearAnims(playerid) { return ClearAnimations(playerid), TogglePlayerControllable(playerid, 1); }
Something like that.