OnPlayerEnteredRoom( Player newplayer ) not working
Options
The function OnPlayerEnteredRoom
works after player entered a room, BUT, the newplayer.UserId is empty.
I have no reference of what userId the other player have, so I cant send something to the other player.
anyone has an Idea why the newplayer.UserId is empty?
public override void OnPlayerEnteredRoom(Player newPlayer)
{
print("someone join the room player id:" + newPlayer.UserId);
}
works after player entered a room, BUT, the newplayer.UserId is empty.
I have no reference of what userId the other player have, so I cant send something to the other player.
anyone has an Idea why the newplayer.UserId is empty?
public override void OnPlayerEnteredRoom(Player newPlayer)
{
print("someone join the room player id:" + newPlayer.UserId);
}
0
Comments
-
0
-
Hi, thank you it works!,
Btw how can I get the player ID of the one who created the room?
Im trying to figure it out
PhotonNetwork.CurrentRoom.Players
but no luck
0 -
Hi @tataygames,
There is no built-in way to know the ID of the room creator.
However, initially the room creator should be the master client until he/she leaves or the master client is explicitly switched.
So check PhotonNetwork.CurrentRoom.MasterClient.
You could, also, embed the UserID of the creator inside the room name when creating it using some special pattern/format. This way, you can extract it whenever you need from any client even if the creator leaves the room.0 -
Hi thanks for the reply.
Btw I made a solution to get the userid of the enemy if his the creator of that room
for ( int i = 0; i <= PhotonNetwork.PlayerList.Length-1; i++)
{
if (PhotonNetwork.PlayerList.IsMasterClient)
{
classicMatch_enemyUserID = PhotonNetwork.PlayerList.UserId;
}
}0 -
Hi @tataygames,
You don't need that for loop.
PhotonNetwork.MasterClient or PhotonNetwork.CurrentRoom.MasterClient are enough.0 -
oh okay thanks!0