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.37k stars 423 forks source link

setPedLookAt does not work for remote players #509

Open ArranTuna opened 5 years ago

ArranTuna commented 5 years ago

Describe the bug This will work for the local player, when it comes to a remote player it will return true but you will not see that players head move.

To Reproduce

for key, value in ipairs(getElementsByType("player")) do
    local rot = getPedCameraRotation(value)
    local x, y, z = getElementPosition(value)
    local vx = x + math.sin(math.rad(rot)) * 10
    local vy = y + math.cos(math.rad(rot)) * 10
    setPedLookAt(value, vx, vy, 10, 3000)
end

After outputting the values from getPedCameraRotation and the vx, vy values, they are definitely changing for when the remote player moves his head, meaning this bug is within setPedLookAt.

Also try: crun setPedLookAt(getPlayerFromNick("name"), 0, 0, 0, -1)

You will not see his head move, despite it returning true.

Additional context From https://bugs.mtasa.com/view.php?id=4325

PlatinMTA commented 5 years ago

I remember making it work on MTA 1.5.5 using setPedAimTarget as the wiki says, but after an update (i don't know which one) this trick stopped working. It would be cool to pin point where the problem is and get this solved.

Fernando-A-Rocha commented 8 months ago

I was digging through the Wiki and found this issue linked on the setPedLookAt page. It says there that for remote players, you have to use setPedAimTarget before setPedLookAt. With this information and the script in this Issue's main post, I made this which is functional and smooth (tested with other players). Hope it helps somebody.

https://community.multitheftauto.com/index.php?p=resources&s=details&id=18882