Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setPedLookAt does not work for remote players #509

Open
ArranTuna opened this issue Sep 20, 2018 · 2 comments
Open

setPedLookAt does not work for remote players #509

ArranTuna opened this issue Sep 20, 2018 · 2 comments
Labels
bug Something isn't working
Milestone

Comments

@ArranTuna
Copy link
Collaborator

ArranTuna commented Sep 20, 2018

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

@ArranTuna ArranTuna added the bug Something isn't working label Sep 20, 2018
@qaisjp qaisjp added this to the Backlog milestone Sep 20, 2018
@PlatinMTA
Copy link
Contributor

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
Copy link
Contributor

Fernando-A-Rocha commented Dec 21, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants