Jump to content

Head script


fairyoggy

Recommended Posts

I have script for head (head rotation by mouse). but it's cliend side and only 1 player sees this. I mean only 1 player can see this actions(Example You can see only your head rotation but not other players) How to make it translate to the server so that all players see the head rotation? 

Quote

 

addEventHandler("onClientRender", getRootElement(), function()

for k,player in ipairs(getElementsByType("player")) do
if getElementHealth(player) >= 1 then
local width, height = guiGetScreenSize ()
local lx, ly, lz = getWorldFromScreenPosition ( width/2, height/2, 10 )
setPedLookAt(player, lx, ly, lz)
end 
end
   
end)

 

 

Edited by slapz0r
Link to comment
-- remove setPedLookAt function and replace it to :
triggerServerEvent("onMyEvent",localPlayer,player,lx,ly,lz)

then from server to client :

addEvent("onMyEvent",true)
addEventHandler("onMyEvent",root,
  function(ped,lx,ly,lz)
    for k, v in ipairs (getElementsByType("player")) do
 		 triggerClientEvent(v,"onClientMyEvent",v,ped,lx,ly,lz);
    end
 end
)

then you'll receive this event in the client side onClientMyEvent

and put the (SetPedLookAt) function inside the event function ..

addEvent("onClientMyEvent",true);
function eventFunc(ped,lx,ly,lz)
  setPedLookAt(ped,lx,ly,lz);
end
addEventHandler("onClientMyEvent",root,eventFunc)

 

Link to comment
14 hours ago, NX_CI said:
-- remove setPedLookAt function and replace it to :
triggerServerEvent("onMyEvent",localPlayer,player,lx,ly,lz)

then from server to client :

addEvent("onMyEvent",true)
addEventHandler("onMyEvent",root,
  function(ped,lx,ly,lz)
    for k, v in ipairs (getElementsByType("player")) do
 		 triggerClientEvent(v,"onClientMyEvent",v,ped,lx,ly,lz);
    end
 end
)

then you'll receive this event in the client side onClientMyEvent

and put the (SetPedLookAt) function inside the event function ..

addEvent("onClientMyEvent",true);
function eventFunc(ped,lx,ly,lz)
  setPedLookAt(ped,lx,ly,lz);
end
addEventHandler("onClientMyEvent",root,eventFunc)

 

Rotation the heads of other players is still not visible. and I had problems with a local player. The head began to vibrate hard

Link to comment

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