[OneSync] Vehicle ID's the same at a distance

Good afternoon,

I’ve been developing a lighting system for a while now, and have come across an issue when trying to make the resource OneSync compatible. I’m leaning toward this being down to OneSync essentially having players in their own session until they’re at a closer range, however, I’m unsure.

I have the console printing the vehicle identifiers for two players each time a key is pressed. When in range, both vehicles have different ID’s as I imagine they should - Meaning I can control the vehicles individually, such as enabling/disabling extras.

However once the second player reaches a certain distance away from player one and presses the button, the ID for their vehicle matches that of player 1. This means that when player 2, for example, activates an extra via the client it doesn’t just activate the extra for their vehicle it does so for the other player’s vehicle too.

Is there a workaround to avoid this? I would assume this would involve networking the vehicles or something along those lines?

Thank you

I’m not clear on what exactly you are doing, but issuing commands from the server to the client that owns the vehicle would be the easiest way to go about it.

I don’t think I explained it as well as I could have -

Player presses a key (Default: Q)
|
A server event is called, saying the client pressed the key.
|
A client event is called from that event to tell every other client that particular player pressed the key.
|
Every single client then toggles the extras for the vehicle that the original player is in (Using the native that retrieves the players vehicle). The extras are those that have been added to the JSON file. e.g. extra 1&2. Which in this case is lights in an emergency vehicle’s lightbar.

This works perfectly fine in close proximity, and as intended. To debug, I’ve printed out the player ID and the vehicle ID every time the button is pressed. And when in close range, it would show that player 1 for example has enabled extras for vehicle (e.g.) 4825 and if I then press my key it would show player 2 has enabled extras for (e.g.) 5617.

However, when player 1 gets far enough away and presses the key it prints in the console that player 1 has enabled extras for 5617 which is my vehicle and therefore controls my vehicle. Same goes for if I press the key, it would show as their vehicle on their end.

I hope this better explains the dilemma

You should only need to send the event to the vehicle owner, as changing it on their client will change it on all clients. Furthermore, if the client pressing Q is the driver of the vehicle you want to change, you don’t need any server elements at all, you can just have them change the extra and it will sync.