Little help about ApplyAnimation
#1

I am making teargas system for a tdm server, it works but i got a problem with the choking animation.
When an enemy teargases someone, the player who got teargas'ed can see the animation but not others.

Here's the code for the teargas system
PHP код:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
     if(
GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
    {
        if(
pressed(KEY_FIRE))
        {
            if(
GetPlayerWeapon(playerid) == 17)
            {
                new 
Float:xFloat:yFloat:z;
                
GetPlayerPos(playeridxyz);
                foreach(
Playeri)
                {
                    if(
IsPlayerInRangeOfPoint(i7.0xyz))
                    {
                        if(
== playerid) continue;
                        if(
GetPVarInt(i"mask") == 0)
                        {
                            if(
pInfo[i][pTeam] == pInfo[playerid][pTeam]) continue;
                            
ApplyAnimation(i"ped""gas_cwr"4.1000050000);
                        }
                    }
                }
            }
        }
    }
    return 
1;

I tried loading the animlib like this

PHP код:
PreloadAnimLib(playeridanimlib[])
{
    
ApplyAnimation(playerid,animlib,"null",0.0,0,0,0,0,0);
}
public 
OnPlayerSpawn(playerid)
{
    
PreloadAnimLib(playerid"ped");
    return 
1;

But it's still not working, what am i doing wrong here?
Reply
#2

I have the same problem, when i only see the animation if i type the command twice..
Reply
#3

/Bump, tried to fix but no luck. Anyone can help?
Reply
#4

https://sampwiki.blast.hk/wiki/ApplyAnimation

Quote:

forcesync
Set to 1 to make server sync the animation with all other players in streaming radius (optional). 2 works same as 1, but will ONLY apply the animation to streamed-in players, but NOT the actual player being animated (useful for npc animations and persistent animations when players are being streamed)

Reply
#5

Please use search, it's been a problem for a long time, and it was always simple to fix: Pre-Load Animation libraries ... and force sync the apply animation, thats all
PHP код:
                            ApplyAnimation(i"ped""gas_cwr"4.1000050000);
                                                                                      ^^^
Not forcesyncing it 
Reply
#6

Well, i am not that kind of guy who randomly posts for help unless the problem becomes little tough. Yes I did set forcesync to 1 but still, somehow it doesn't work at all.
Reply
#7

Well my bad then, but still there is something wrong with the code you are running, but everything you wrote here works fine,
Only suggestions I got is
A) try other anims to see if they are working correctly or not
B) If it's only this particular anim, apply it whenever a player spawns, then quickly reset their anim, as far as I know if a player already done the animation, he will see others do it as well ...
Reply
#8

https://sampwiki.blast.hk/wiki/SetPlayerSpecialAction
Reply
#9

I just figured out that if i set the time to 0 and not 5000, others can see the animation but the animation is fast. I need it to stay for like 5 seconds at least. If i set the time to 5000 milliseconds, the animation works as i want but not visible for other players. I guess this is a default bug from samp? I am pretty sure there is a way to make it work cause i've been in a server where this animation stays for 5 seconds and others can clearly see it.

Quote:
Originally Posted by Meller
Посмотреть сообщение
And how would i set the choking animation with this?

EDIT: Fixed myself. Thanks for helping tho.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)