hrtht Posted March 13, 2020 Share Posted March 13, 2020 (edited) How to see the other player every time he moves his head? current scripts only leave it looking to one side. Edited March 13, 2020 by hrtht Link to comment
Addlibs Posted March 13, 2020 Share Posted March 13, 2020 Share the code that you need help with, or at least tell us which script it is if it's from MTASA community resources website. Link to comment
hrtht Posted March 13, 2020 Author Share Posted March 13, 2020 3 hours ago, MrTasty said: Share the code that you need help with, or at least tell us which script it is if it's from MTASA community resources website. 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) Link to comment
Addlibs Posted March 13, 2020 Share Posted March 13, 2020 You're setting everyone's look-at coordinates to the centre of the localPlayer's screen, not the respective player's screen. Also, last time I used setPedLookAt, it didn't work for remote players correctly. Also, read the Wiki notices (specifically the first one - don't run this on onClientRender): Note: Avoid calling setPedLookAt every frame as this can cause bugs like being invincible to burning. Note: For remote players, you have to use setPedAimTarget before setPedLookAt. Link to comment
hrtht Posted March 13, 2020 Author Share Posted March 13, 2020 3 hours ago, MrTasty said: You're setting everyone's look-at coordinates to the centre of the localPlayer's screen, not the respective player's screen. Also, last time I used setPedLookAt, it didn't work for remote players correctly. Also, read the Wiki notices (specifically the first one - don't run this on onClientRender): Note: Avoid calling setPedLookAt every frame as this can cause bugs like being invincible to burning. Note: For remote players, you have to use setPedAimTarget before setPedLookAt. I started days ago on this.. if you can send me the code it would be great man Link to comment
iDannz [Breno] Posted March 16, 2020 Share Posted March 16, 2020 (edited) All you should do is get new look at coordinates -> send to server -> sync to others clients but remember; dont try to destroy your server's network --serverside addEvent('syncLookAt', true) addEventHandler('syncLookAt', root, function(x,y,z) triggerLatentClientEvent("setLookAt", 30000, false, client, x,y,z) -- triggerClientEvent("setLookAt", client, x,y,z) end) --clientside local screenW, screenH = guiGetScreenSize() setTimer(function() local x,y,z = getWorldFromScreenPosition(screenW*0.5, screenH*0.5, 10) triggerLatentServerEvent("syncLookAt", 30000, false, localPlayer, x,y,z) -- triggerServerEvent("syncLookAt", localPlayer, x,y,z) end, 200, 0) addEvent('setLookAt', true) addEventHandler('setLookAt', root, function(x,y,z) setPedLookAt(source, x,y,z) end) Edited March 16, 2020 by iDannz [Breno] 1 Link to comment
hrtht Posted March 16, 2020 Author Share Posted March 16, 2020 3 hours ago, iDannz [Breno] said: All you should do is get new look at coordinates -> send to server -> sync to others clients but remember; dont try to destroy your server's network --serverside addEvent('syncLookAt', true) addEventHandler('syncLookAt', root, function(x,y,z) triggerLatentClientEvent("setLookAt", 30000, false, client, x,y,z) -- triggerClientEvent("setLookAt", client, x,y,z) end) --clientside local screenW, screenH = guiGetScreenSize() setTimer(function() local x,y,z = getWorldFromScreenPosition(screenW*0.5, screenH*0.5, 10) triggerLatentServerEvent("syncLookAt", 30000, false, localPlayer, x,y,z) -- triggerServerEvent("syncLookAt", localPlayer, x,y,z) end, 200, 0) addEvent('setLookAt', true) addEventHandler('setLookAt', root, function(x,y,z) setPedLookAt(source, x,y,z) end) Still doesn't work, the head is stuck to the right, I want it for all not just local player man Link to comment
iDannz [Breno] Posted March 16, 2020 Share Posted March 16, 2020 17 hours ago, hrtht said: Still doesn't work, the head is stuck to the right, I want it for all not just local player man its working fine here, just tested it now. Link to comment
fairyoggy Posted March 21, 2020 Share Posted March 21, 2020 On 17/03/2020 at 00:49, iDannz [Breno] said: its working fine here, just tested it now. I would also like to know the answer to this question. This only works for the local client. that is, you see where the head is turning, and for the other player you have your head "turned in one direction and froze" although you turn your head. On the local side, everything is fine, but how to implement this correctly for other players? Link to comment
DREFTHUN Posted April 10, 2020 Share Posted April 10, 2020 It is bugged. setPedLookAt Issues Issue ID Description #4325 setPedLookAt does not work for remote players Link to comment
Hoffmann Posted April 10, 2020 Share Posted April 10, 2020 Note: For remote players, you have to use setPedAimTarget before setPedLookAt. 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