Jump to content

setPedAnimation problem


Xwad

Recommended Posts

Hi! I have a problem with setPedAnimation. Theres a bind in my script, and if a player press the bind then he will start doing this animation:

  
setPedAnimation ( source, "SILENCED", "SilenceCrouchfire", 1, false, false, false, true ) 
  

server side

The animation is working correctly but the problem is that if a player dies and goes back to the player who is doing the animation then he will see nothing, no animation (just standing). I mean if forexample player1 is starting the animation then player2 will see the animation (what the player1 is doing) but if player2 dies and goes back to player1 then he wont see the animation anymore (he will just see standing).. BUT if i use this code then its working 100%

  
setPedAnimation ( source, "SILENCED", "SilenceCrouchfire", 1 ) 
  

but this animation is not what i want

Link to comment
  • Moderators

[size=6][b]Optional Arguments[/b][/size] 
  
NOTE: When using optional arguments, you must supply all arguments before the one you wish to use. For more information on optional arguments, see Optional Arguments. 
  
    block: the animation block's name. 
    anim: the name of the animation within the block. 
    [b]time: how long the animation will run for in milliseconds.[/b] [u][color=#00FF00][b]To -1?[/b][/color][/u] 
[b]    loop: indicates whether or not the animation will loop.[/b] [u][color=#00FF00][b]To true?[/b][/color][/u] 
    updatePosition: will change the actual coordinates of the ped according to the animation. Use this for e.g. walking animations. 
    interruptable: if set to 'false' other tasks wont be able to interupt the animation. Setting this to 'false' also gives this function more power to override other animations that are running. For example, squatting after a jump can be terminated. 
    freezeLastFrame: ... (From 1.1 onwards). 

https://wiki.multitheftauto.com/wiki/SetPedAnimation

Link to comment
its not working:/ now its the same like this: setPedAnimation ( source, "SILENCED", "SilenceCrouchfire", 1 )

the animation is always restarting. and i want to make that its not moving

IIYAMA set the animation to a looping state, this might cause some unexpected results. Turn the looping off like so;

setPedAnimation ( source, "SILENCED", "SilenceCrouchfire", -1, false, false, false, true ) 

Link to comment

server.lua

  
function attach(veh) 
        --local mid = getElementModel ( veh ) 
        --if weapOff[mid] then 
        setPedAnimation ( source, "SILENCED", "SilenceCrouchfire", 1, false, false, false, true ) 
        attachElements ( source, weapon_base, 0.05, -0.62, 1.1, 0, 0, 90 )  
        setElementCollisionsEnabled ( source, false ) 
        toggleControl (source,"fire", false) 
        setElementData ( source, "attachedToWeapon_v", veh ) 
        setElementData ( source, "currentCol", nil ) 
        setElementData ( source, "attachedToWeapon_w", weap ) 
        setElementData ( veh, "playerOnWeapon", source ) 
    end 
  --end 
addEvent("attachPlayerToMinigun", true) 
addEventHandler("attachPlayerToMinigun",getRootElement(), attach) 
  

Link to comment

server

  
anim = {} 
  
function attach(veh) 
        --local mid = getElementModel ( veh ) 
        --if weapOff[mid] then 
        setPedAnimation ( source, "SILENCED", "SilenceCrouchfire", 1, false, false, false, true ) 
        anim[source] = true 
        attachElements ( source, weapon_base, 0.05, -0.62, 1.1, 0, 0, 90 ) 
        setElementCollisionsEnabled ( source, false ) 
        toggleControl (source,"fire", false) 
        setElementData ( source, "attachedToWeapon_v", veh ) 
        setElementData ( source, "currentCol", nil ) 
        setElementData ( source, "attachedToWeapon_w", weap ) 
        setElementData ( veh, "playerOnWeapon", source ) 
        triggerClientEvent( "syncanim", resourceRoot, anim) 
    end 
  --end 
addEvent("attachPlayerToMinigun", true) 
addEventHandler("attachPlayerToMinigun",getRootElement(), attach) 
  

client

  
animcache = {} 
  
addEvent("syncanim", true) 
addEventHandler("syncanim", root,  
   function (anim) 
      for players in ipairs(anim) do 
         if ( not animcache[players] ) then 
            setPedAnimation(players) 
         end 
         setPedAnimation(players, "SILENCED", "SilenceCrouchfire", 1, false, false, false, true) 
      end 
      animcache = anim 
    end 
) 
  

Link to comment
server
  
anim = {} 
  
function attach(veh) 
        --local mid = getElementModel ( veh ) 
        --if weapOff[mid] then 
        setPedAnimation ( source, "SILENCED", "SilenceCrouchfire", 1, false, false, false, true ) 
        anim[source] = true 
        attachElements ( source, weapon_base, 0.05, -0.62, 1.1, 0, 0, 90 ) 
        setElementCollisionsEnabled ( source, false ) 
        toggleControl (source,"fire", false) 
        setElementData ( source, "attachedToWeapon_v", veh ) 
        setElementData ( source, "currentCol", nil ) 
        setElementData ( source, "attachedToWeapon_w", weap ) 
        setElementData ( veh, "playerOnWeapon", source ) 
        triggerClientEvent( "syncanim", resourceRoot, anim) 
    end 
  --end 
addEvent("attachPlayerToMinigun", true) 
addEventHandler("attachPlayerToMinigun",getRootElement(), attach) 
  

client

  
animcache = {} 
  
addEvent("syncanim", true) 
addEventHandler("syncanim", root,  
   function (anim) 
      for players in ipairs(anim) do 
         if ( not animcache[players] ) then 
            setPedAnimation(players) 
         end 
         setPedAnimation(players, "SILENCED", "SilenceCrouchfire", 1, false, false, false, true) 
      end 
      animcache = anim 
    end 
) 
  

What the actual f...? You're caching an animation which has been synced by MTA theirself. OP is telling us that the animation is being looped, not being desynced.

Something that does make a light turn on in my head is the bug someone reported on the bugtracker ( can't find it atm ) where dead peds would keep staying after you stream then out/in after they died. Did the fix for peds mess up the animations for players??

edit; this report, #9112. It might also be caused for the users.

Link to comment

What the actual f...? You're caching an animation which has been synced by MTA theirself. OP is telling us that the animation is being looped, not being desynced.

Something that does make a light turn on in my head is the bug someone reported on the bugtracker ( can't find it atm ) where dead peds would keep staying after you stream then out/in after they died. Did the fix for peds mess up the animations for players??

edit; this report, #9112. It might also be caused for the users.

Calm your tits, uh.

  
  
animcache = {} 
  
addEvent("syncanim", true) 
addEventHandler("syncanim", root, 
   function (anim) 
      animcache = anim 
    end 
) 
  
addEventHandler("onClientElementStreamIn", root, 
   function () 
      if ( animcache[source] ) then          
         setPedAnimation(players, "SILENCED", "SilenceCrouchfire", 1, false, false, false, true) 
      end 
   end 
) 
  

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...