Duplicate UserIDs

Hi!

So I've been working with photon for a bit over a year now and am loving it, when I first started using it I had setup so that the Photon NickName would be a person's steam name, so when they joined I'd just need to access that. In order to prevent duplicate names I hard-coded in something that checks each player in the room, and if their name was the same it'd add a "(1)" to the end of their name (then repeat for 2,3,4,5,etc.) Now it'd been a while since I had updated (didn't want to risk breaking anything) so I did that today and found out that i can no longer join rooms with a player in there who already has my name, making my workaround obsolete (since that was done after connection).

I've been digging through to see what I can do and short of re-coding any display to just show the steam name and setting the UserID to the unique steamID I can't seem to find anything else. Before I jump into recoding all of that is there any other way I can work around this?

The error I get when joining a room is this: Operation failed: OperationResponse 226: ReturnCode: 32746 (Join failed: UserId '(Omitted Username)' already joined the specified game (JoinMode=0).). Parameters: {} Server: GameServer

Thanks for any assistance!

Comments

  • UPDATE: So I did a bit more on this today and tried the following;

    Added the "OnPhotonJoinRoomFailed ( object[] codeAndMsg)" function, and if the returncode was the duplicate id, it called another function in "OnConnectedToMaster" that set their name (temporarily for a workaround) to their username + "(1)" then attempted to join the room again (stored the room name locally if they received the error)

    I printed out the userid and username when it begun to reconnect and it shows the updated Username(1), however the error is still thrown, showing the old username ("Username") instead of "Username(1)". Any insight/ideas to why that's happening?
  • Hi @Ufando,

    Thank you for choosing Photon!

    There are differences between:

    1. UserID (or UserId, userId, userID, userid)

    - should not be null or empty.
    - should be unique inside the same room per player.
    - cannot be changed once the player is authenticated/connected.
    - if not set during authentication by the client or by third-party authentication provider (e.g. Steam), Photon server will assign a GUID.
    - used to identify the player when rejoining a room.

    and

    2. Nickname (or NickName, nickName, nickname, Name, name, PlayerName, Playername, playerName, playername, UserName, Username, userName, username, etc.)

    - can be left null or empty.
    - more than one player can share the same value inside the same room.
    - can be changed at any time by the player using SetProperties operation/method(s).

    So I think that you should assign Steam ID (or whatever that is called) as UserID and Steam's DisplayName (or whatever they call it if it exists) as Nickname.
    Please send an email to [email protected] to request access to Steam Authentication if you need it.
  • Thanks for the reply! I can't believe how simple the fix was, I just messed up the order when trying something similar earlier. I set the PhotonNetwork.playername to the steam id, then in OnJoinedLobby changed the nickname to the steam display name and it all works! Thanks so much!
Sign In or Register to comment.