# \[Deprecated] Persistent Values

{% 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="/files/MauH1lJHvqNzmEDHYMDN" 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="/files/YwEbekUtGnVaydXKsMtI" 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="/files/JbbyN4v9uD7OTVr8Y2cd" 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="/files/gsx0L1L0YedsDu8iPomL" 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="/files/PBs6Keb2PmiLtY2w0tP8" 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="/files/jyQfYRVFCFsWOTdcLU1e" 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="/files/jYOJ17DnBDDBnD6Xy98x" 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="/files/JdLwUyOjDEXK988NilHN" 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: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

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

The question should be specific, self-contained, and written in natural language.
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.
