> For the complete documentation index, see [llms.txt](https://docs.otherside.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.otherside.xyz/platform-documentation/creation/unreal-development/features-and-tutorials/accounts/persistent-values.md).

# \[Deprecated] Persistent Values

An easy way to persist values inside of an actor, using the KVStore

{% hint style="danger" %}
Deprecated, please speak to support for further info.

**15/04/2025:** MSquared is consolidating its assorted persistence/KeyValue systems into a single API which we will expose to downstream users. Please instead use the [KV Store Service](/platform-documentation/creation/unreal-development/features-and-tutorials/online-services/kv-store-service.md).
{% endhint %}

**BPMC\_PersistentValuesBase** is a Morpheus blueprint component and is the base class for saving, querying and loading values. There are two other components which inherit from that class for persisting String and Int values, **BPMC\_PersistentValuesString** and **BPMC\_PersistentValuesInt**. The purpose of these components is to easily wrap the process of persisting values in one place. You can add as many components as you like to an actor.

## Setup <a href="#setup" id="setup"></a>

It’s very simple to setup these components, you just add them as a component to an actor and setup the configurable values in the Class Defaults. Under **Config > Setup**, there is an **EventKey** (Name type) which determines the unique key type associated with these persisted values. Each component should be setup with the intention of persisting values specific for an event or feature. String values are stored in a **String Array** and Int values are stored in a **`Name<>Int Map`**, where each name should be unique to the Int value being persisted.

<figure><img src="https://970394512-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ft3SBfOIsRz4GCNFFpae7%2Fuploads%2Fgit-blob-8ec85404e408138843ba5d3e226e0cf32821f8e9%2Fimage%20(741).png?alt=media" alt=""><figcaption><p>Adding an Event Key</p></figcaption></figure>

{% hint style="warning" %}
There needs to be a valid **`EventKey`** for these components to work. You can either manually setup the value in the Class Defaults or dynamically by calling **`DynamicallyOverrideEventKey()`**
{% endhint %}

<figure><img src="https://970394512-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ft3SBfOIsRz4GCNFFpae7%2Fuploads%2Fgit-blob-d3a4c9cb7ff780e6e9bbc954af10d7e830aff5ca%2Fimage%20(742).png?alt=media" alt=""><figcaption></figcaption></figure>

You can also dynamically override the values that are being persisted by calling the relevant function for each type of component, **DynamicallyOverrideStringValues()** or **DynamicallyOverrideIntValues()**.

<figure><img src="https://970394512-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ft3SBfOIsRz4GCNFFpae7%2Fuploads%2Fgit-blob-448edc4c8ef8e4c9ac927016dd94ad93808e8f6a%2Fimage.webp?alt=media" alt=""><figcaption><p>Int and String Event Keys made in Blueprints</p></figcaption></figure>

## Save <a href="#save-query-load" id="save-query-load"></a>

To save the values there are a few different functions that can be called.

* SaveAll()
* SaveSingleValue(String)
* SaveSingleValue(Int)

<figure><img src="https://970394512-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ft3SBfOIsRz4GCNFFpae7%2Fuploads%2Fgit-blob-247c95a1d439b466736726b570be63c1cf75b281%2Fimage%20(1).webp?alt=media" alt=""><figcaption><p>Save</p></figcaption></figure>

## Persistent Saving

These will save the passed in value to the player’s web profile in the KVStore if **UpdateValueInDataStore** is *TRUE* (which is default). This will mean it is saved persistently across sessions and events.

## Query

To load the values there are a few different functions that can be called.

* QueryAndLoadAll()
* QueryAndLoadSingleValue(String)
* QueryAndLoadSingleValue(Name) → This is for the Int component

<figure><img src="https://970394512-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ft3SBfOIsRz4GCNFFpae7%2Fuploads%2Fgit-blob-55105e93bf857c5d08055852e1e20c6ca49cb4a9%2Fimage%20(2).webp?alt=media" alt=""><figcaption><p>Query</p></figcaption></figure>

## Load

Once these functions are called and completed the components will store them. For Strings it’s **GetPersistedStringValues()** and for Ints it’s **GetPersistedIntValues()**.

<figure><img src="https://970394512-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ft3SBfOIsRz4GCNFFpae7%2Fuploads%2Fgit-blob-beb0b96341089146d554ecb8c058972b7639b4ff%2Fimage%20(3).webp?alt=media" alt=""><figcaption><p>Load</p></figcaption></figure>

## Bindings <a href="#bindings" id="bindings"></a>

There are two general delegates that can be bound to by any component inheriting from the base class:

* BindToSavedDelegate()
* BindToLoadedDelegate()

There are also specific ones for Strings and Ints to know when the values are saved/queried/loaded.

* BindToAllStringDelegates()
* BindToStringSavedDelegate()
* BindToStringLoadedDelegate()
* BindToStringQueriedDelegate()
* BindToAllInDelegates()
* BindToIntSavedDelegate()
* BindToIntLoadedDelegate()
* BindToInQueriedDelegate()

<figure><img src="https://970394512-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ft3SBfOIsRz4GCNFFpae7%2Fuploads%2Fgit-blob-8b5b0ea563a38493ba936de4055ac60669ef39ce%2Fimage%20(4).webp?alt=media" alt=""><figcaption><p>Binding</p></figcaption></figure>

The handle functions always returns a **Key** and **PersistentComponent** to know which one it’s related to. For specific ones it will return a String or an Int value. You can use the general ones and always cast the component to the type you are using if you have a few persisted components attached to an actor.

<figure><img src="https://970394512-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ft3SBfOIsRz4GCNFFpae7%2Fuploads%2Fgit-blob-1ec7c44ed51a8d37a620e2df4d353794321ea20e%2Fimage%20(5).webp?alt=media" alt=""><figcaption><p>Persistent Component</p></figcaption></figure>

There’s currently **no support** for **Struct** values as you can’t store wildcard variables in blueprints. However, if you require one for a specific Struct a new child class can easily be made inheriting from the base class and set up in it’s own component.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.otherside.xyz/platform-documentation/creation/unreal-development/features-and-tutorials/accounts/persistent-values.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
