SA-MP Forums Archive
Anim when shot - 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: Anim when shot (/showthread.php?tid=596875)



Anim when shot - lucamsx - 23.12.2015

i wanted to make a gta 3-like effect for shotgun - player falls on their back when hit, facing his enemy. i've made this:
Код:
	if(weaponid == 25)
	{
		if(!IsPlayerInAnyVehicle(playerid))
		{
	    	new Float:issuerangle;
    		GetPlayerFacingAngle(issuerid, issuerangle);
	    	SetPlayerFacingAngle(playerid, issuerangle+180);
		ApplyAnimation(playerid,"BASEBALL","Bat_Hit_3", 4.1, 0, 1, 1, 0, 1, 1);
		}
	}
but seems it doesn't work, nothing happens.

edit: i changed the code to:
Код:
	if(weaponid == 25)
	{
		if(!IsPlayerInAnyVehicle(playerid))
		{
	    	new Float:issuerangle;
    		GetPlayerFacingAngle(issuerid, issuerangle);
	    	SetPlayerFacingAngle(playerid, issuerangle+180);
	    	ClearAnimations(playerid);
			ApplyAnimation(playerid,"BASEBALL","Bat_Hit_3", 4.1, false, true, true, true, true);
		}
	}
.
now it works, but 50% of the time, the shooter cant see the victims anim. any ideas?


Re: Anim when shot - SupperRobin6394 - 23.12.2015

OnPlayerTaleDamage (I think)


Re: Anim when shot - lucamsx - 23.12.2015

You think what? This code is already there.


Re: Anim when shot - Sew_Sumi - 23.12.2015

Quote:
Originally Posted by lucamsx
Посмотреть сообщение
now it works, but 50% of the time, the shooter cant see the victims anim. any ideas?
Did you preload the animation library, because if you haven't that'll be causing a sync issue, but it could also cause your first lot of code to appear not to work at all.



put this code

Код:
print("Debug");
in the if statements (Instead of Debug, something meaningful, like "Hit : Deagle") regarding where it hit in the code, using the weaponid to say where the code actually triggered.

This'll show it's a desync issue or not, and it will help out in showing you how to put debug messages in, to find where the faults actually are.


If it is desync and it is triggering, that means you need to preload the animations.

Код:
PreloadAnimLib



Re: Anim when shot - lucamsx - 24.12.2015

Well, i tried this method, and debug message is showing everytime somebody got hit with a shotgun.
I tried PreloadAnimLib before setting the falling animation for player, but nothing changed. About 50% of time when i shoot the player, i can only see him floating back a little. He sees his own animation tho. Same goes with me.


Re: Anim when shot - TwinkiDaBoss - 24.12.2015

Quote:
Originally Posted by lucamsx
Посмотреть сообщение
Well, i tried this method, and debug message is showing everytime somebody got hit with a shotgun.
I tried PreloadAnimLib before setting the falling animation for player, but nothing changed. About 50% of time when i shoot the player, i can only see him floating back a little. He sees his own animation tho. Same goes with me.
Have you tried applying the animation twice? Sometimes it helps with some animations. I know it sounds awkward but yeah.

Example:
PHP код:
ApplyAnimation(playerid,"BASEBALL","Bat_Hit_3"4.1falsetruetruetruetrue);
ApplyAnimation(playerid,"BASEBALL","Bat_Hit_3"4.1falsetruetruetruetrue); 



Re: Anim when shot - lucamsx - 24.12.2015

Applying anim twice doesn't seem to work. I've also tried changing animation parameters, but still nothing.


Re: Anim when shot - Abagail - 24.12.2015

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
Did you preload the animation library, because if you haven't that'll be causing a sync issue, but it could also cause your first lot of code to appear not to work at all.



put this code

Код:
print("Debug");
in the if statements (Instead of Debug, something meaningful, like "Hit : Deagle") regarding where it hit in the code, using the weaponid to say where the code actually triggered.

This'll show it's a desync issue or not, and it will help out in showing you how to put debug messages in, to find where the faults actually are.


If it is desync and it is triggering, that means you need to preload the animations.

Код:
PreloadAnimLib
PreloadAnimLib isn't a native SA-MP function by the way.


Re: Anim when shot - Sew_Sumi - 24.12.2015

Quote:
Originally Posted by Abagail
Посмотреть сообщение
PreloadAnimLib isn't a native SA-MP function by the way.
Rather than handing things to people on a plate, I rather leave some for them to complete, so it's obvious they are learning, not simply "reading", "following instructions" or copying and pasting.


Re: Anim when shot - lucamsx - 25.12.2015

Well, any other ideas?