Skip to content

$persistence

Values saved between sessions.

15 natives. Read-only natives only look things up; the rest change something. Parameter types use the language's names (Types).

clear_all_staged_values

$persistence.clear_all_staged_values(user: User)

Removes all staged values for the given user.

ParameterTypeMeaning
userUserThe user the value belongs to.

get_key_exists

read-only
$persistence.get_key_exists(key: string, key_list: list, user: User) -> bool

Determine if a key exists already.

ParameterTypeMeaning
keystringThe unique key to search for.
key_listlistList to use as the unique key. Will be used over 'key' parameter if specified.
userUserThe user the key belongs to.

Returns bool: True if the key exists.

get_nth_staged_key

read-only
$persistence.get_nth_staged_key(n: int, user: User) -> string

Return the nth key of staged data for the given user.

ParameterTypeMeaning
nintWhich index to return.
userUserThe user the value belongs to.

Returns string: The key string.

get_staged_key_count

read-only
$persistence.get_staged_key_count(user: User) -> int

Return how many staged keys have been set for the given user.

ParameterTypeMeaning
userUserThe user the value belongs to.

Returns int: The number of staged keys that have been set.

get_staged_value

read-only
$persistence.get_staged_value(key: string, key_list: list, user: User) -> int

Gets a staged value for the given user.

ParameterTypeMeaning
keystringThe unique key to access.
key_listlistList to use as the unique key. Will be used over 'key' parameter if specified.
userUserThe user the value belongs to.

Returns int: The staged value for the key, or -1 if not found. Use persistence.has_staged_key(...) if you need to be sure of its existence.

get_value_as_float

read-only
$persistence.get_value_as_float(key: string, key_list: list, user: User) -> float

Get a persistent value from the backend services as a float.

ParameterTypeMeaning
keystringThe unique key to retrieve this value.
key_listlistList to use as the unique key. Will be used over 'key' parameter if specified.
userUserThe user the value belongs to.

Returns float: The value stored for this key as a float.

get_value_as_int

read-only
$persistence.get_value_as_int(key: string, key_list: list, user: User) -> int

Get a persistent value from the backend services as an int.

ParameterTypeMeaning
keystringThe unique key to retrieve this value.
key_listlistList to use as the unique key. Will be used over 'key' parameter if specified.
userUserThe user the value belongs to.

Returns int: The value stored for this key as an int.

get_value_as_object_ref

read-only
$persistence.get_value_as_object_ref(key: string, key_list: list, user: User) -> Reference

Get a persistent value from the backend services as a ref to a loaded object. Returns null if the specified object is not loaded, or not found.

ParameterTypeMeaning
keystringThe unique key to retrieve this value.
key_listlistList to use as the unique key. Will be used over 'key' parameter if specified.
userUserThe user the value belongs to.

Returns Reference: The value stored for this key as a ref.

get_value_as_string

read-only
$persistence.get_value_as_string(key: string, key_list: list, user: User) -> string

Get a persistent value from the backend services as a string.

ParameterTypeMeaning
keystringThe unique key to retrieve this value.
key_listlistList to use as the unique key. Will be used over 'key' parameter if specified.
userUserThe user the value belongs to.

Returns string: The value stored for this key as a string.

get_value_as_world_time_delta_ms

read-only
$persistence.get_value_as_world_time_delta_ms(key: string, key_list: list, user: User) -> int

Get a duration in milliseconds since the time set via set_world_time_value. If the duration is too large, will return INT_MAX and not warn.

ParameterTypeMeaning
keystringThe unique key to retrieve this value.
key_listlistList to use as the unique key. Will be used over 'key' parameter if specified.
userUserThe user the value belongs to.

Returns int: The duration in milliseconds.

has_received_persistence_for_user

read-only
$persistence.has_received_persistence_for_user(user: User) -> bool

Determine if we have received persistence values from the backend for a particular user. The user's persistence may be empty.

ParameterTypeMeaning
userUserThe user to query.

Returns bool: True if we have received an update for this user, false otherwise.

has_staged_key

read-only
$persistence.has_staged_key(key: string, key_list: list, user: User) -> bool

Determine if there exists a key in the staged data.

ParameterTypeMeaning
keystringThe unique key look for.
key_listlistList to use as the unique key. Will be used over 'key' parameter if specified.
userUserThe user the value belongs to.

Returns bool: Whether the key exists or not.

set_staged_value

$persistence.set_staged_value(key: string, key_list: list, user: User, value: int, flags: int)

Sets a staged value for the given user.

ParameterTypeMeaning
keystringThe unique key to store this value under.
key_listlistList to use as the unique key. Will be used over 'key' parameter if specified.
userUserThe user the value belongs to.
valueintThe value to store.
flagsintThe flags for the key. See vgame_persistence_staged_value_flags_t.

set_value

$persistence.set_value(key: string, key_list: list, user: User, value: var, write_type: int)

Sets a persistent value in the backend services. get_value may not immediately return this value, until it receives it from the backend.

ParameterTypeMeaning
keystringThe unique key to store this value under.
key_listlistList to use as the unique key. Will be used over 'key' parameter if specified.
userUserThe user the value belongs to.
valuevarThe value to store.
write_typeintWrite behavior e.g. k_online_write_type_replace (default), k_online_write_type_greater_than.

set_world_time_value

$persistence.set_world_time_value(key: string, key_list: list, user: User, offset_ms: int)

Sets a persistent value in the backend services to the current world time in nanoseconds. The value is accessible via get_value_as_world_time_delta_ms.

ParameterTypeMeaning
keystringThe unique key to store this value under.
key_listlistList to use as the unique key. Will be used over 'key' parameter if specified.
userUserThe user the value belongs to.
offset_msintAn offset in millseconds to the time to set.