How do I add a number to a username if it already exists?

Get help using Construct 2

Post » Fri Sep 30, 2016 1:42 am

I am using the photon multiplayer plugin and everything works great except for this one problem I am having:

When a user enters a room and has chosen the same userid (username) as another user it simply shows up as blank.

Is there any way to check, upon entering a room, if another user already is using the same name/id so that it can set a new username for the user?
For example, if someone with the name "Player" entered a room and someone else was already in the room also using the name "Player" I would want to have the entering user's name be Player(1). If there were two other players with the name "Player" already in the room then the third player's name would be Player(2) etc...
B
16
S
4
G
4
Posts: 59
Reputation: 3,091

Post » Fri Sep 30, 2016 3:03 pm

The first question would be how you are storing the username.
Are you storing it as a global variable or as a dicitonary value or as an XML value?
The way you would check whether the name already exists, varies depending on how you store the usernames for your chatroom.
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091


Return to How do I....?

Who is online

Users browsing this forum: blackhornet, dop2000, evillair, mongoose665 and 59 guests