kibook / pmms

Synchronized media player for FiveM and RedM
136 stars 57 forks source link

Only sync media players with closest players #36

Open dolutattoo opened 2 years ago

dolutattoo commented 2 years ago

Hi,

Currently, every players receive the pmms:sync once there is at least 1 media player running. It would be great to find a solution so if a player is not near any media player, the server doesn't send the event. Maybe statebags/globalstate can help with that?

Im a begginer, so Im sorry if this doesnt makes any sense. Im just trying to help and understand :)

Ekinoxx0 commented 2 years ago

This seems like minor optimization, it would probably most costly to calls natives to check distance with every other player rather than send an event to -1

Statebag could work great for networked entities as StateBagChangeHandler is effective to know if the entity is in radius

TakeFiveGames commented 2 years ago

I'd argue that a strong enough server host would be more efficient than sending a 1MB sync multiple times a second unnecessarily. Anything that avoids packet flooding or sync issues for minimal impact. In the current case, the server is sending events to all clients where the majority are probably not using that source, resulting in a lot of net events. In the described case, the server is taking on a bit heavier of a load itself and in return not syncing players that don't need it. With that said, not everyone has a deddy on hand with a ton of CPU and RAM available. I'd be interested in perhaps a toggle that lets you choose.

Legacy-TacticalGamingInteractive commented 2 years ago

Is there a way that we can limit how many active streams from pmms are going at once in the server? Maybe that can help?