SetPlayerPos and Animation bug...
#1

Dear!

I Already tried to ask from a friendly user, if he can see any problem in my code, but he says it is okay. But problem is still this:

This happens from the menu item. When entering to CP, it freezes a player automatically to prevent player moving out of CP. I'm trying to put a player to a chair and start the eating animation, but nothing happens and view keeps same as it is when scrolling in the menu (camera). Animation seems to work, tested it as a command.

Here is the code:

pawn Код:
// On player selected menu row:
TogglePlayerControllable(playerid, 1);
SetPlayerVirtualWorld(playerid, 4);
SetPlayerPos(playerid, 450.6630, -90.9404, 999.7083);
SetCameraBehindPlayer(playerid);
SetPVarInt(playerid, "IsEating", 1);
new RandomHPP = random(51);
new Float:RandomHP = float(RandomHPP);
new Float:HP;
GetPlayerHealth(playerid, HP);
if(RandomHP + HP <= 100.0) SetPlayerHealth(playerid, HP + RandomHP);
if(RandomHP + HP > 100.0) SetPlayerHealth(playerid, 100.0);
ApplyAnimation(playerid, "FOOD", "FF_Sit_Eat1", 4.1, 1, 0, 0, 1, 0, 1);
SetTimerEx("StopEating", 10000, false, "i", playerid);
TogglePlayerControllable(playerid, 0);
 
public StopEating(playerid)
{
        if(GetPVarInt(playerid, "IsEating") == 1)
        {
                SetPVarInt(playerid, "IsEating", 0);
                ClearAnimations(playerid, 1);
                SetPlayerVirtualWorld(playerid, 4);
                SetPlayerPos(playerid, 449.8693, -83.6513, 999.5547);
                SetCameraBehindPlayer(playerid);
                ShowMenuForPlayer(SarvShop, playerid);
        }
}
I Repeat that, the player is frozen, when he access the menu.

Thanks for your reply in advance, hopefully we can resolve this together!

Sincerely,
CrossUSAAF.
Reply
#2

Ignore this, misread the problem.
Reply
#3

Quote:
Originally Posted by BenTaylorUK
Посмотреть сообщение
Ignore this, misread the problem.
Thank you atleast for trying to help me. Now I'm wondering is the problem that, I Freeze the player when he enters to CP? Can it cause that, it won't move the player to exact position in same virtual world and start the eating and sit animation?
Reply
#4

First of all, make sure your animations have been preloaded. A way to do this can be found by FakeCop228 (first one I found when searching):
http://forum.sa-mp.com/showthread.ph...54#post2438154

Then this way, you won't have to apply the animation twice in order for it to run. Also, I cannot see any lines that are enabling your player to move again... in your 'StopEating' Timer, you need to add a line that allows the player to move again. So to unfreeze the player again, you just need the line:
pawn Код:
TogglePlayerControllable(playerid, 1);
Reply
#5

Quote:
Originally Posted by BenzoAMG
Посмотреть сообщение
First of all, make sure your animations have been preloaded. A way to do this can be found by FakeCop228 (first one I found when searching):
http://forum.sa-mp.com/showthread.ph...54#post2438154

Then this way, you won't have to apply the animation twice in order for it to run. Also, I cannot see any lines that are enabling your player to move again... in your 'StopEating' Timer, you need to add a line that allows the player to move again. So to unfreeze the player again, you just need the line:
pawn Код:
TogglePlayerControllable(playerid, 1);
Thanks for your helpful post. The idea with "StopEating" is that, it moves the player back to CP that has the menu, so I Won't unfreeze the player in this case.

EDIT: Animation works now, moved the order and using your suggested way, thanks. But the player IS still in wrong position, it won't rotate the player to my position, that I Set!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)