SA-MP Forums Archive
Animation doesn't get applied - 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: Animation doesn't get applied (/showthread.php?tid=664515)



Animation doesn't get applied - andrejc999 - 02.03.2019

So I made a robbing system for ATMs and the animation doesn't get applied for some reason.

I tried setting it twice but still nothing so I decided to make a command just for the animation.
I have to execute it twice before it starts working. Why?

Here's the code:

Код:
CMD:robbankomat(playerid, params[])
{
	if(robanjeBankomata[playerid] == 1) return SCM(playerid, COLOR_WHITE, "* Vec robate.");
	if(robanjeTimer[playerid] > 0) return SCM(playerid, COLOR_WHITE, "* Morate sacekati 20 minuta od proslog robanja.");
	if(IsPlayerInAnyVehicle(playerid)) return SCM(playerid, COLOR_WHITE, "{007AF4}[BK] {FFFFFF}Niste kod bankomata!");
	for(new b=0, s=MAX_BANKOMAT;b<s;b++)
	{
	    if(IPP(playerid, 1, bankomatInfo[b][bX], bankomatInfo[b][bY], bankomatInfo[b][bZ]))
	    {
	        if(bankomatInfo[b][robTimer] > 0) return SCM(playerid, COLOR_WHITE, "* Sacekajte malo.");
	        robanjeBankomata[playerid] = 1;
	        pInfo[playerid][pBankomatRob] = 1200;
	        robanjeTimer[playerid] = 300;
	        bankomatInfo[b][robTimer] = 1200;
	        ClearAnimations(playerid, 1);
	        ApplyAnimation(playerid, "BOMBER", "BOM_Plant_Loop", 4.0, 1, 0, 0, 1, 0);
	        PI[playerid][pWl] = 6;
	        return 1;
	    }
	}
	SCM(playerid, COLOR_WHITE, "{007AF4}[BK] {FFFFFF}Niste kod bankomata!");
	return 1;
}



Re: Animation doesn't get applied - Swarn - 02.03.2019

Hey, you'll need to preload all the animations when OnPlayerConnect is called. https://sampforum.blast.hk/showthread.php?tid=265119


Re: Animation doesn't get applied - andrejc999 - 02.03.2019

Oh makes sense, thanks works now.

EDIT:

When I freeze the player the animation doesn't get applied. Any idea why?

Код:
ApplyAnimation(playerid, "BOMBER", "BOM_Plant_Loop", 4.0, 1, 0, 0, 1, 0);
TogglePlayerControllable_AC(playerid, false);

//Stock function
stock TogglePlayerControllable_AC(playerid, toggle)
{
	Controllable[playerid] = toggle;
	TogglePlayerControllable(playerid, toggle);
	return 1;
}



Re: Animation doesn't get applied - Swarn - 02.03.2019

From what I know you can't TogglePlayerControllable and then apply an animation, TogglePlayerControllable makes it so the player is literally frozen, and unable to do anything (moving/mouse moving), it's like your play is forced to stand straight. you can always set the freeze Param in the ApplyAnimation to 1 if you don't want the player to move.

Or I might be getting it the wrong way round, TogglePlayerControllable then apply to animation and tell me if it makes a difference, I doubt it will as TogglePlayerControllable has priority (I think)

Either way, if it doesn't work then the answer is above and you'll have to rely on the freeze Param in the ApplyAnimation


Re: Animation doesn't get applied - andrejc999 - 02.03.2019

Didn't know that, thanks.

Anyway I found a workaround but I was wondering why it does that so I that I know for the future.


Re: Animation doesn't get applied - Swarn - 02.03.2019

I'm guessing it's use for admin purposes but I can't say that for sure.


Re: Animation doesn't get applied - NaS - 02.03.2019

Quote:
Originally Posted by Swarn
Посмотреть сообщение
From what I know you can't TogglePlayerControllable and then apply an animation, TogglePlayerControllable makes it so the player is literally frozen, and unable to do anything (moving/mouse moving), it's like your play is forced to stand straight. you can always set the freeze Param in the ApplyAnimation to 1 if you don't want the player to move.

Or I might be getting it the wrong way round, TogglePlayerControllable then apply to animation and tell me if it makes a difference, I doubt it will as TogglePlayerControllable has priority (I think)

Either way, if it doesn't work then the answer is above and you'll have to rely on the freeze Param in the ApplyAnimation
TogglePlayerControllable does not literally freeze the player. As the name suggests, it toggles the player (un)controllable. Animations do still work, they just get interrupted.

If you want to apply an animation, apply it after using TogglePlayerControllable.
Since packet priorities aren't used for every function, you might want to put a small delay between the two as well if there are still issues.