Skip to main content

Players and props

Accessing players

read:players

After identifying a player, you can access the underlying player object using Talo.CurrentPlayer. For the current player alias, you can use Talo.CurrentAlias.

You can also find a player by their ID using Talo.Players.Find(). Players retrieved this way are read-only: you can only modify or take actions on behalf of a player that was previously identified.

Searching for players

read:players

You can use Talo.Players.Search() to query players. This function accepts a single query parameter that will search your playerbase for matching player IDs, alias identifiers or prop values. You can use this function to find players by their username, their ID or if they have a prop with a specific value.

private async void SearchPlayers()
{
try
{
var searchPage = await Talo.Players.Search("bob");
if (searchPage.count == 0)
{
Debug.Log("No players found");
return;
}

var identifiers = new List<string>();
foreach (var player in searchPage.players)
{
identifiers.Add(player.GetAlias().identifier);
}

Debug.Log($"Found {searchPage.count} results: {string.Join(", ", identifiers)}");
}
catch (Exception ex)
{
Debug.LogError($"Search failed: {ex.Message}");
}
}

Getting and setting props

Players can have a list of arbitrary properties that are persisted across all of their aliases. These props are identified by their unique key and can have any string value. Keys can be up to 128 characters long and values can be up to 512 characters long.

All functions that modify props accept an optional update parameter (default true) that controls whether the player is synced with Talo after the change. Set it to false to batch multiple changes and avoid redundant debounces.

Getting props

You can retrieve the current player's props using Talo.CurrentPlayer.props. To retrieve a single prop use Talo.CurrentPlayer.GetProp() (where you can also specify a fallback).

var level = Talo.CurrentPlayer.GetProp("level", "1");
Debug.Log($"Level: {level}");

Setting props

write:players

You can set props using Talo.CurrentPlayer.SetProp(). If a prop with specified key doesn't exist it'll be created, otherwise the existing prop with the same key will be updated.

Talo.CurrentPlayer.SetProp("level", "5");

// Set multiple props without triggering a sync each time
Talo.CurrentPlayer.SetProp("level", "5", false);
Talo.CurrentPlayer.SetProp("class", "warrior", false);
Talo.CurrentPlayer.SetProp("xp", "1200"); // syncs here
warning

Player props are not linearisable - simultaneous requests may be applied out of order. You should avoid setting or deleting props in Update() functions.

Deleting props

write:players

Props can be deleted with Talo.CurrentPlayer.DeleteProp() or by using Talo.CurrentPlayer.SetProp() and setting the value to null.

Talo.CurrentPlayer.DeleteProp("level");

Prop arrays

Prop arrays allow you to store multiple values under a single key. Each item is stored as its own value (up to 512 characters each), with a maximum of 1000 items per array.

info

Array keys are internally suffixed with [] (e.g. a key of "inventoryItems" is stored as "inventoryItems[]").

When using the functions below, you should reference the key without the [] suffix.

Getting prop arrays

You can retrieve all values for a prop array using Talo.CurrentPlayer.GetPropArray(). It returns an IReadOnlyList<string> of the current values.

var items = Talo.CurrentPlayer.GetPropArray("inventoryItems");
Debug.Log($"Inventory: {string.Join(", ", items)}");

Setting prop arrays

write:players

Use Talo.CurrentPlayer.SetPropArray() to replace all values for a prop array key. Duplicate and empty values are ignored. The array must not be empty.

Talo.CurrentPlayer.SetPropArray("inventoryItems", new[] { "sword", "shield", "helmet" });

Inserting into prop arrays

write:players

Use Talo.CurrentPlayer.InsertIntoPropArray() to add a single value to an existing prop array. If the value already exists it will not be added again.

Talo.CurrentPlayer.InsertIntoPropArray("inventoryItems", "helmet");

Removing from prop arrays

write:players

Use Talo.CurrentPlayer.RemoveFromPropArray() to remove a single value from a prop array.

Talo.CurrentPlayer.RemoveFromPropArray("inventoryItems", "helmet");

Deleting prop arrays

write:players

Use Talo.CurrentPlayer.DeletePropArray() to delete an entire prop array.

Talo.CurrentPlayer.DeletePropArray("inventoryItems");

Handling rejected props

Player prop updates support partial success. If an update contains a mix of valid and invalid props, the valid props will be set and only the invalid ones will fail (see rejection reasons).

You can listen for rejected props using the Talo.Players.OnPropsRejected event:

private void OnEnable()
{
Talo.Players.OnPropsRejected += OnPropsRejected;
}

private void OnDisable()
{
Talo.Players.OnPropsRejected -= OnPropsRejected;
}

private void OnPropsRejected(RejectedProp[] rejectedProps)
{
foreach (var prop in rejectedProps)
{
// prop.key: the key of the rejected prop
// prop.error: the rejection reason code (e.g. "PROP_VALUE_TOO_LONG")
// prop.message: a human-readable description of the rejection
Debug.Log($"Rejected prop '{prop.key}': {prop.message} ({prop.error})");
}
}

Prop rejection reasons

The RejectedProp.GetReason() method returns a PropRejectionReason enum value:

ReasonDescription
PROP_KEY_TOO_LONGThe prop key exceeds 128 characters
PROP_VALUE_TOO_LONGThe prop value exceeds 512 characters
PROP_ARRAY_TOO_LONGThe prop array exceeds 1000 items
PROP_CONTAINS_PROFANITYThe prop key or value contains profanity
PROP_KEY_RESERVEDThe prop key is reserved by Talo
private void OnPropsRejected(RejectedProp[] rejectedProps)
{
foreach (var rejectedProp in rejectedProps)
{
switch (rejectedProp.GetReason())
{
case PropRejectionReason.PROP_KEY_TOO_LONG:
Debug.LogWarning($"Key too long: {rejectedProp.key}");
break;
case PropRejectionReason.PROP_VALUE_TOO_LONG:
Debug.LogWarning($"Value too long for key: {rejectedProp.key}");
break;
case PropRejectionReason.PROP_CONTAINS_PROFANITY:
Debug.LogWarning($"Profanity detected in key: {rejectedProp.key}");
break;
default:
Debug.LogWarning($"Prop '{rejectedProp.key}' was rejected: {rejectedProp.message}");
break;
}
}
}