Animation doesn't get applied
#1

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;
}
Reply
#2

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

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;
}
Reply
#4

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
Reply
#5

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.
Reply
#6

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

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)