multitheftauto / mtasa-blue

Multi Theft Auto is a game engine that incorporates an extendable network play element into a proprietary commercial single-player game.
https://multitheftauto.com
GNU General Public License v3.0
1.42k stars 437 forks source link

Ped rotation is always zero on client side if ped has been frozed after creating it #1291

Open Xenius97 opened 4 years ago

Xenius97 commented 4 years ago

Describe the bug Ped rotation is always zero on client side if ped has been frozed after creating it.

To reproduce

--- Serverside!
local peds = {
    {150, 1464.1395263672, -1002.5094604492, 26.828125, 90},
}

for i, v in ipairs(peds) do
    local ped = createPed(v[1], v[2], v[3], v[4], v[5], false)
    setElementFrozen(ped, true)
        setElementID(ped, "testPED")
end

Server side runcode: elem:ped[150]00000194E4B44F28 [element:ped] Result: vector3: { x = 0.000, y = 0.000, z = 90.000 } [userdata]

Client side runcode: getElementByID("testPED").rotation Result: vector3: { x = 0.000, y = 0.000, z = 0.000 } [userdata]

Version Multi Theft Auto v1.5.7-release-20406

Xenius97 commented 4 years ago

Without setElementFrozen:

Client side runcode: getElementByID("testPED").rotation Result: vector3: { x = 0.000, y = 0.000, z = 89.999 } [userdata]

Pirulax commented 4 years ago

Okay, so it seems like it related to bSynced being set to false, and has nothing to to with freezing the ped. The rotation is correctly set on client side in 'EntityAdd' packet. Gonna investigate further

Fixed. So the problem was, that we did set the stored rotations when creating m_pPlayerPed, but only in the interface(CPedInterface), which didnt affect the actual matrix(from which getRotation actually gets the rotation). Ill open a PR for the fix.

Also, im not even sure if this target and current rotation things are necessary at all. Gotta look into that as well.

Xenius97 commented 2 years ago

This issue still exiting. #1506 didn't solve it.

Lpsd commented 2 years ago

1506 hasn't been merged yet, did you build the client yourself with this fix included?

Xenius97 commented 2 years ago

1506 hasn't been merged yet, did you build the client yourself with this fix included?

No, i thought it's tested by someone since 2020. Didn't check PR status. 😄