Jump to content

setPedLookAt sync


smw94

Recommended Posts

can anyone help with sync ing setPedLookAt ? this is my code, other player always look to the north, while local player work perfectly, thanks before

client side

  
local sx, sy = guiGetScreenSize () 
  
-- addEventHandler("onClientPreRender", getRootElement(),  
-- function() 
function rotateOwnHead() 
    -- body 
    if getElementHealth(localPlayer) >= 1 then 
        local lx, ly, lz = getWorldFromScreenPosition ( sx/2, sy/2, 10 ) 
        triggerLatentServerEvent("moveHeadSync",1000,true,localPlayer,lx,ly,lz) 
    end  
end 
  
addEventHandler("onClientResourceStart",root, 
function () 
    setTimer(rotateOwnHead, 200, 0 ) 
end) 
  
-- end) 
  
  
function rotateHead(x,y,z) 
    setPedAimTarget(source, x,y,z) 
    setPedLookAt(source, x,y,z, -1, 0) 
end 
addEvent("rotateHead",true) 
addEventHandler("rotateHead",getRootElement(),rotateHead) 
  

server side

  
function moveHeadSync(x,y,z) 
    -- outputDebugString(tostring(getPlayerName(source)..": X : "..x)) 
    triggerLatentClientEvent(root, "rotateHead",1000,true, source,x,y,z) 
end 
addEvent("moveHeadSync",true) 
addEventHandler("moveHeadSync",getRootElement(),moveHeadSync) 
  

Edited by Guest
Link to comment
  • 2 weeks later...

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