Jump to content

setPedAnimation not working properly


John Smith

Recommended Posts

I have tried to edit freeroam's code, the setPedAnimation syntax and added few more arguments and put updatePosition argument to false, but anims still change coordinate positions

i am trying to disable movement when using anims

when an animation finishes in freeroam, new one starts because its looped and then it moves to player as more it loops

please help if you understand what i said

Link to comment

Do you want apply one animation and the ped no move it?

but not want frozzen it....

bool setPedAnimation ( ped thePed [, string block=nil, string anim=nil, int time=-1, bool loop=true, bool updatePosition=true, bool interruptable=true, bool freezeLastFrame = true] ) 

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.

time: how long the animation will run for in milliseconds.

loop: indicates whether or not the animation will loop.

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
  • Moderators

Well very simple:

local peds = getElementsByType("ped") 
local pedPositions = {} 
for i=1,#peds do 
    local ped = peds[i] 
    local x,y,z = getElementPosition(ped) 
    pedPositions[#pedPositions+1] = { 
        ["element"]=ped, 
        ["x"]=x, 
        ["y"]=y, 
        ["z"]=z 
    } 
end 
  
addEventHandler("onClientRender",root, 
function () 
    for i=#pedPositions,1,-1 do -- infers loop for using table.remove. 
        local pedData = pedPositions[i] 
        local ped = pedData["element"] 
        if isElement(ped) then 
            setElementPosition( 
                ped, 
                pedData["x"], 
                pedData["y"], 
                pedData["z"], 
                false -- don't interrupt the animation = false 
            ) 
        else 
            table.remove(pedPositions,i) 
        end 
    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...