Skip to main content

Unique Values


The module allows registering unique values project-wide that are associated with a player. Only the player-owner can modify and delete the value. Once registered, no other player can have the same unique value for a specific tag.

Examples of unique values:

  • Login / nickname;
  • Base name / city name;
  • One-of-a-kind item.
  • Owner's status in a selected region.
  • And much more.

Register Value

+1 Request

To register or update a unique value, you need to pass a tag and a value.

  • If the value has not been registered by the player, it will be added:
    • If no one else has the same value with this tag.
  • If the value already exists for the player with the same tag, it will be updated:
    • If no one else has the same value with this tag.

Tag / value size should not exceed 1 KB.

// Register
gp.uniques.register({ tag: 'login', value: 'Be$t_Devel0per' });

// Update by tag
gp.uniques.register({ tag: 'login', value: 'The_Be$t_Devel0per' });

Events upon value registration

// Successfully registered
gp.uniques.on('register', (uniqueValue) => {
// uniqueValue.tag
// uniqueValue.value

// Error during registration
gp.uniques.on('error:register', (error) => {});

Registration method with promises

const result = await gp.uniques.register({ tag: 'login', value: 'Be$t_Devel0per' });
* Whether the registration was successful
* @type {boolean}

Get Value

// Get
const value = gp.uniques.get('login'); // string

List of Values

All unique values registered by the player.

const values = gp.uniques.list;

Example content:

{ tag: 'login', value: 'Be$t_Devel0per' },
{ tag: 'cityName', value: 'Crabifornia' },
{ tag: 'item', value: 'THOUSAND_TRUTHS_SWORD' },
{ tag: 'title', value: 'GAME_LORD' },

Check Value

+1 Request

To check a unique value, you need to pass a tag and a value. This may be needed for real-time validation. Upon attempting to register a value, it will be checked again.

// Check
gp.uniques.check({ tag: 'login', value: 'Be$t_Devel0per' });

Events upon checking a value

// Checked successfully, no match found
gp.uniques.on('check', (uniqueValue) => {
// uniqueValue.tag
// uniqueValue.value

// Error during check
gp.uniques.on('error:check', (error) => {});

Check method with promises

const result = await gp.uniques.check({ tag: 'login', value: 'Be$t_Devel0per' });
* Checked successfully, no match found
* @type {boolean}

Delete Value

+1 Request

You can release an unnecessary value for other players to make it available again.

// Delete
gp.uniques.delete({ tag: 'login' });

Events upon deleting a value

// Deleted successfully
gp.uniques.on('delete', (uniqueValue) => {
// uniqueValue.tag
// uniqueValue.value

// Error during deletion
gp.uniques.on('error:delete', (error) => {});

Delete method with promises

const result = await gp.uniques.delete({ tag: 'login' });
* Deleted successfully
* @type {boolean}

Data Management

Through the admin panel, you can add, edit, and delete unique values in the "Unique Values" section of the project.

In the add form, you can:

  • Specify a tag within which the unique value will be created.
  • Specify the unique value (string).
  • Specify the ID of the player-owner to whom the value belongs; 0 reserved by the system.

Data Censorship

If you want to shield players from unwanted words, you can use the option of censoring values.

Censorship using AI. Benefits:

  • It uses understanding of context rather than brute force.
  • Provides high quality recognition, but resource costs are also high.
  • Recognizes complex cases, for example A$_H@LE, 2girls1cup, πздец / 3.14здец, and others.
  • Multilingualism, understanding of profanity and contextual insults in each language.

Censoring incurs an additional fee for each request. The minimum cost for 1 check is 3 requests, then +1 request for every 20 tokens of text (GPT tokens).

In the control panel under "Unique Values," create a rule for the desired tag.

In the add form, you can:

  • Specify a tag for the rule.
  • Configure censorship:
    • Specify the context of values:
      • Specify in English what the text is intended for, for example character name or game chat. This will help the AI understand if the text violates the rules. For example, if a player specifies Ugly Guy as a nickname, it is acceptable; however, if they write that in the chat, it might offend other players, though this depends on the full sentence context.
    • Forbid profanity and swear words.
    • Forbid links.
    • Forbid spam.
    • Forbid provocations that may offend players in some way.
    • Specify age restrictions for content.
      • In games rated 0+, it is undesirable to use any bad words. In games rated 16+, mild profanity and euphemisms without offensive context may be acceptable, for example, darn. In games rated 18+, profanity may be allowed, but not directed at players. The AI follows your context but may even find such words unsuitable within the context of 18+ games.

Data Types

Unique Value

tagstringValue taglogin

Error Codes

ErrorError Description
player_not_foundPlayer not found
empty_tagEmpty value tag passed
unique_value_not_foundValue with this tag not found
already_existsValue already taken
size_limit_exceededSize limit exceeded
bad_value_filter_censorValue failed censorship check
undefinedUnexpected error (check console for details)

Stay in Touch

Other documents of this chapter available Here. To get started, welcome to the Tutorials chapter.

GamePush Community Telegram: @gs_community.

For your suggestions e-mail: [email protected]

We Wish you Success!