Storage

Player storage allows you to store key/value data on the player. Storage items can be private or public, making possible

Retrieve Player Storage

To view Player storage in the web console, go to the player and select the storage tab. From here it's possible to view and edit the data for the player.

Retrieve Entire Player Storage From Game

LootLockerSDKManager.GetEntirePersistentStorage((response) =>
{
    if (response.success)
    {
        Debug.Log("Successfully retrieved player storage: " + response.payload.Length);
    } else
    {
        Debug.Log("Error getting player storage");
    }
});

Retrieve Single Storage Value From Game

string key = "some-key";
LootLockerSDKManager.GetSingleKeyPersistentStorage(key, (response) =>
{
    if (response.success)
    {
        if (response.payload != null)
        {
            Debug.Log("Successfully retrieved player storage with value: " + response.payload.value);
        } else
        {
            Debug.Log("Item with key " + key + " does not exist");
        }
    } else
    {
        Debug.Log("Error getting player storage");
    }
});

Update Player Storage

To update a single value for a key

LootLockerSDKManager.UpdateOrCreateKeyValue("some-key", "some new value", (getPersistentStoragResponse) =>
{
    if (getPersistentStoragResponse.success)
    {
        Debug.Log("Successfully updated player storage");
    }
    else
    {
        Debug.Log("Error updating player storage");
    }
});

To update or create multiple keys at the same time

LootLockerGetPersistentStorageRequest data = new LootLockerGetPersistentStorageRequest();
data.AddToPayload(new LootLockerPayload { key = "some-key", value = "Some new value" });
data.AddToPayload(new LootLockerPayload { key = "some-other-key", value = "Some other new value" });

LootLockerSDKManager.UpdateOrCreateKeyValue(data, (getPersistentStoragResponse) =>
{
    if (getPersistentStoragResponse.success)
    {
        Debug.Log("Successfully updated player storage");
    }
    else
    {
        Debug.Log("Error updating player storage");
    }
});

Remove Player Storage Item

LootLockerSDKManager.DeleteKeyValue("some-key", (getPersistentStoragResponse) =>
{
    if (getPersistentStoragResponse.success)
    {
        Debug.Log("Successfully removed key from player storage");
    }
    else
    {
        Debug.Log("Error removing key from player storage");
    }
});

Get Other Players Public Storage

For this you need the public UID of the other player.

LootLockerSDKManager.GetOtherPlayersPublicKeyValuePairs("92AR9254", (response) =>
{
    if (response.success)
    {
        Debug.Log("Successfully retrieved storage for other player " + response.payload.Length);
    }
    else
    {
        Debug.Log("Error retrieving storage for other player");
    }
});

Last updated