Jump to content

setPedAnimation not working properly


John Smith

Recommended Posts

Posted

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

Posted

Something as this

setPedAnimation(theElement, "GANGS", "shake_carSH")

setElementFrozen(theElement, true)

and maybe when the playe press a key the animation stop and unfroze it

Posted

It should, try it again, maybe you wrote something wrong, but if not then it look's like it's a bug or it doesn't freeze the player. But I think you would get the same result with setElementFrozen as with setting updatePosition to false.

Sorry for bad English, hope you understand me!

  • Moderators
Posted

You can also freeze it by rendering.

(the ped isn't frozen in this video, but just to show you what is more possible when you render it)

Posted

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

Posted
Dont you think that i have read this before?

sorry my english is bad

i was asking about if not want frozen the ped .... and show the info trying to understand what you did but you do not like of this way and you are trying to do of other way the animation

sorry and good luck

  • Moderators
Posted

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) 

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