question

tedforwardpub avatar image
tedforwardpub asked

Question about the Setting: Append randomly generated digits

We are working on a random name generator so that players can quickly get into the game with a auto generated display name. We want a system that we do not have to worry about getting duplicate random names. So in the setting there is the "Append randomly generated digits to the player's display name" option. Does this ensure that no duplicate random numbers are generated? I would think not, right? As we can set the length of the digit ourselves?


So is there anything in the API that would help setup such a system?

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
JayZuo avatar image
JayZuo answered

The "Append randomly generated digits to the player's display name" option would ensure that no duplicate display name are generated. However, please note this depends upon what you set as the random suffix length, and the total user base. If you were to set it to 1 digit, then obviously only 10 people could enter the same display name. For APIs, PlayFab doesn't provide API to generate unique display name. But you can use the error returned by UpdateUserTitleDisplayName method to help you setting up such a system.

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

tedforwardpub avatar image tedforwardpub commented ·

Great, thanks for the info. So the random number generated will be a unique one? So, for example, if we used a 4 digit number that would give us 9999 unique numbers, correct?

I did the math and if we added just 4 digits to our currency random name generator that would give us 12 million possible random names. That is plenty for an initial launch.


I am wondering though what happens if the numbers are exhausted? As in your example, if we entered a length of 1 what happens if all 10 are used and another name is created? Does the count start all over?

0 Likes 0 ·
brendan avatar image brendan tedforwardpub commented ·

The service makes a good-faith effort - it will randomly generate a number in the range you've specified (number of digits) up to three times, appending that to the name that was sent. If that doesn't result in a unique display name after three tries, it will return the NameNotAvailable error.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.