PDA

View Full Version : ApplyAnimation


Gooday
19/01/2012, 08:04 PM
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

2KY
19/01/2012, 08:10 PM
You'll need:

ApplyAnimation (http://wiki.sa-mp.com/wiki/ApplyAnimation), //Function
OnPlayerTakeDamage (http://wiki.sa-mp.com/wiki/OnPlayerTakeDamage), // Callback
SetTimerEx (http://wiki.sa-mp.com/wiki/SetTimerEx) //Function
ClearAnimations (http://wiki.sa-mp.com/wiki/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.

Gooday
19/01/2012, 08:16 PM
sorry but im a crap at scripting can you post a example? +REP!

2KY
19/01/2012, 08:35 PM
Sure.

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.