Skip to content

Ped rotation sync is broken when using setElementFrozen instantly #4556

@guibzo

Description

@guibzo

Describe the bug

There is a bug where when you spawn a ped with a certain rotation and freeze him, go away and come back, the ped resets its rotation and starts to look other direction (resets to 0).

It seems to be related to this, but I am using a update version right now and still have about the same problem.

This only happens if you use setElementFrozen immediately after spawning the ped.

Steps to reproduce

-- server
addEventHandler("onResourceStart", resourceRoot, function()
  local x, y, z = unpack({ 2076.55, -1587.19, 13.48 })
  local ped = createPed(4, x, y, z)
  setElementRotation(ped, 0, 0, 270)

  iprint("server spawn rot", getElementRotation(ped)) -- logs 0, 0, 270

  setElementFrozen(ped, true) -- if you do this immediately, it will not sync correctly.
  -- if you do this tho, it will work
  -- setTimer(function()
  --   setElementFrozen(ped, true)
  -- end, 500, 1)

  setPedAnimation(ped, "COP_AMBIENT", "Copbrowse_loop", -1, true, false, false, false)
  setElementData(ped, "customped", true)
end)

-- client
addEventHandler("onClientElementStreamIn", root, function()
  local element = source

  local isPed = getElementData(element, "customped")
  if isPed then
    -- returns 0, 0, 0 if setElementFrozen has no delay, or 0, 0, 270 if it has
    iprint("client stream rot", element, getElementRotation(element)) 
  end
end)

Version

25775 (Windows 10, 64-bit)

Additional context

No response

Relevant log output

Security Policy

  • I have read and understood the Security Policy and this issue is not security related.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions