fairyoggy Posted April 26, 2019 Share Posted April 26, 2019 (edited) 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) Expand Edited April 26, 2019 by slapz0r Link to comment
nxFairlywell Posted April 26, 2019 Share Posted April 26, 2019 -- 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
Gordon_G Posted April 26, 2019 Share Posted April 26, 2019 For performance reason I don't advise you to do that on a server with a lot of people connected Link to comment
fairyoggy Posted April 27, 2019 Author Share Posted April 27, 2019 On 26/04/2019 at 17:20, 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) Expand 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
nxFairlywell Posted April 27, 2019 Share Posted April 27, 2019 On 27/04/2019 at 07:45, slapz0r said: Rotation the heads of other players is still not visible. and I had problems with a local player. The head began to vibrate hard Expand Remove my edits and restore your code Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now