Jump to content

LookSync | of where a player looks with his head


Recommended Posts

[English]
You will be able to see where the players are looking in real time, and this system is optimized to only process the players who are in your visual range.

[Español]
Podrás ver hacia dónde miran los jugadores en tiempo real y este sistema está optimizado para procesar solo a los jugadores que están dentro de tu rango visual.

NOTE: It is synchronized with setElementData and getElementData all client-side to avoid using unnecessary triggers since they consume more CPU resources.

Post Link: https://community.multitheftauto.com/index.php?p=resources&s=details&id=18881

32308.webp

Link to comment

@BranD

Your script spams element data every 100ms, this is not good for the server. Synchronization calls will be too excessive and it will result in horrible lag.

Your script also won't work properly as it's obtaining Z position of 10 with getWorldFromScreenPosition(width/2, height/2, 10), resulting in players' heads looking down or up if they're not at that height on the map.

I had come up with a simple optimized solution that is 100% clientside: https://community.multitheftauto.com/index.php?p=resources&s=details&id=18882

Please take this as constructive criticism, no offense.

Edited by FernandoMTA
Link to comment
2 hours ago, FernandoMTA said:

@BranD

Your script spams element data every 100ms, this is not good for the server. Synchronization calls will be too excessive and it will result in horrible lag.

Your script also won't work properly as it's obtaining Z position of 10 with getWorldFromScreenPosition(width/2, height/2, 10), resulting in players' heads looking down or up if they're not at that height on the map.

I had come up with a simple optimized solution that is 100% clientside: https://community.multitheftauto.com/index.php?p=resources&s=details&id=18882

Please take this as constructive criticism, no offense.

the effect breaks when Ped is aiming, i tried using the isPedAiming function from the wiki to perhaps make it revert to stock lookAt settings but couldn't, give that a try maybe u can.

Link to comment

I understand the criticism, but the elementData is not synchronized on the server-side, it is only client-side, it will not affect the performance of the server, plus it only takes the visible elements of the player.

Link to comment
9 hours ago, BranD said:

I understand the criticism, but the elementData is not synchronized on the server-side, it is only client-side, it will not affect the performance of the server, plus it only takes the visible elements of the player.

if the element data isn't actually synced ( client - server ), it will have no effect since you won't be getting actual data of the other players tho

Link to comment
2 hours ago, SDabdlmounaim96 said:

Si los datos del elemento no están realmente sincronizados (cliente-servidor), no tendrá ningún efecto ya que no obtendrás datos reales de los otros jugadores.

I recommend that you test the system with more than 30 players, you will notice that it does not produce any negative effect on the server, the synchronization is client to client, not client to server and server to client.

2 hours ago, SDabdlmounaim96 said:

Si los datos del elemento no están realmente sincronizados (cliente-servidor), no tendrá ningún efecto ya que no obtendrás datos reales de los otros jugadores.

Previously, the solution for some was to use triggers, but that has an impact on the server's CPU.

Link to comment

@BranD @SDabdlmounaim96 Sorry but what you guys are saying about element data doesn't make sense. Look at the script BranD posted. It does setElementData on the localPlayer with the sync value to true (default), it is synchronized and BrenD's comment above is wrong. All other clients have this synced to them and can do getElementData on their side, to retrieve other players looking at position. This is how he syncs the looking at position, it's with element data that is transferred from the client to the server and then to all clients.

Doing this every 100ms is not a good idea period.

I'll look into what you said about ped aiming.

2 hours ago, BranD said:

I recommend that you test the system with more than 30 players, you will notice that it does not produce any negative effect on the server, the synchronization is client to client, not client to server and server to client.

Previously, the solution for some was to use triggers, but that has an impact on the server's CPU.

There is no such thing as client to client synchronization 

Link to comment
  • 3 weeks later...
On 14/01/2024 at 18:30, FernandoMTA said:

In the end I saw your code and I liked it, but there is a small error that you could correct, when you use the gameSpeed above 1 the head will bug, the solution is simple, put the following: setPedLookAt(player, vx, vy, z, -1, 0)
Anyway, I appreciate your contribution to the community.

Link to comment

This is an undocumented bug, but changing localPlayer's look at position prevents them from grabbing onto particularly high ledges they normally can grab onto. If you care about players being able to perform parkour normally, just like they would do in a singleplayer, you should avoid using setPedLookAt() on localPlayer.

Link to comment
11 hours ago, BranD said:

In the end I saw your code and I liked it, but there is a small error that you could correct, when you use the gameSpeed above 1 the head will bug, the solution is simple, put the following: setPedLookAt(player, vx, vy, z, -1, 0)
Anyway, I appreciate your contribution to the community.

Ah that bug is unfortunate :( However, passing -1 as the time parameter in setPedLookAt will make the head face that direction forever, and this is not a good idea because you want the player's head to reset in some circumstances (when they're aiming, for example, as coded in the script). 🤔

4 hours ago, Stan1y said:

This is an undocumented bug, but changing localPlayer's look at position prevents them from grabbing onto particularly high ledges they normally can grab onto. If you care about players being able to perform parkour normally, just like they would do in a singleplayer, you should avoid using setPedLookAt() on localPlayer.

That's interesting. I'll test it. You should report it here if you have proof :-)

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