Spawn player With OnPlayerPropertiesUpdate
Options
Hi,
I would like to create all players only when everyone is loading the room. So Idid this
But, i don't know how all player with master.
Does anyone have any ideas?
I would like to create all players only when everyone is loading the room. So Idid this
public override void OnPlayerPropertiesUpdate(Player targetPlayer, Hashtable changedProps)
{
if (changedProps.ContainsKey("PlayerLives"))
{
return;
}
if (!PhotonNetwork.IsMasterClient)
{
return;
}
PhotonRoom.room.playersInGame += 1;
if (PhotonRoom.room.playersInGame == PhotonRoom.room.playersInRoom)
{
if (changedProps.ContainsKey("PlayerLoadedLevel"))
{
if (CheckAllPlayerLoadedLevel())
{
Hashtable props = new Hashtable
{
{CountdownTimer.CountdownStartTime, (float) PhotonNetwork.Time}
};
PhotonNetwork.CurrentRoom.SetCustomProperties(props);
isReady = true;
}
}
}
}
private bool CheckAllPlayerLoadedLevel()
{
foreach (Player p in PhotonNetwork.PlayerList)
{
object playerLoadedLevel;
if (p.CustomProperties.TryGetValue("PlayerLoadedLevel", out playerLoadedLevel))
{
if ((bool)playerLoadedLevel)
{
continue;
}
}
return false;
}
return true;
}
But, i don't know how all player with master.
Does anyone have any ideas?
0