I have some information stored on the server-side about each player, and I want clients to know about it when interacting. To boil it down to a single variable - each player has a boolean on the server-side, isMario. Players need to know whether every player they're "tracking" is or is not Mario. I already have packets set up such that I can have the server sync its isMario data about a player to anyone whenever I want, so it's just figuring out when to trigger that that's giving me trouble.
The most obvious solution that comes to mind is:
- When a player's
isMariochanges, the server sends a packet to every connected player telling them whether that player is or is not Mario now. - When a player joins the server, they receive packets telling them whether every connected player is or is not Mario, and every other player receives one packet telling them whether the new person is or is not Mario.
However this seems iffy. Clients don't need to know whether everyone is Mario at all times, they only need to know about the players they're tracking. So I'm assuming a better solution would be:
- When a player's
isMariochanges, the server sends a packet to everyone who is tracking that player usingplayerLookup.tracking(). - Whenever someone begins tracking another player, they receive a packet containing that other player's
isMariostatus.
The problem is that I have absolutely no idea how to accomplish that second part. Is there an event I can register a listener to? Do I have to use a mixin on something? Alternatively, am I just overlooking an easier way to accomplish the overall goal here?