pun master vibe check

Sep 21st, 2021 (edited)
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // This is an alternative way of fixing masterclient stealing without the usage of a plugin
  2. // A plugin should really be employed when working with authoritative logic such as host delegation
  3. // But if the game doesn't use master transfer normally, it can be ignored subtly without affecting logic
  4. // PhotonNetwork.PlayerList generates an array every time you access it, don't spam this function if there's hundreds of players
  5. // An optimization could be; run once -> cache master ID -> update when the master leaves in OnEvent (event 254)
  7. public static bool IsRealMasterClient(int sender)
  8. {
  9.     if (!PhotonNetwork.InRoom)
  10.         throw new InvalidOperationException("Not currently connected");
  12.     // Thanks Nico (Rotolonico) for the tip about the playerlist already being sorted by ID
  13.     return sender ==  PhotonNetwork.PlayerList[0].ActorNumber;
  14. }
RAW Paste Data