User Data

Store and manage player data to enhance gameplay experience and retain progress.

There are two types of storage: local_storage and platform_internal. When writing to local storage, data is saved on the player's device. When writing to internal storage, data is saved on the platform's servers.

If you need to call storage methods in a sequence, make sure you wait for previous call to finish, so there is no potential data collisions.

Current Storage Type

Identify the default storage type to understand where data is being saved (local or server).

playgama_bridge_storage_default_type()

Possible values: local_storage, platform_internal.

Support Check

Verify if the specified storage type is supported on the platform to ensure compatibility.

playgama_bridge_storage_is_supported("platform_internal")

Availability Check

Check if the specified storage type is currently available for use to manage data storage effectively.

playgama_bridge_storage_is_available("platform_internal")

Load Data

Retrieve stored data based on a key or multiple keys to restore player progress or settings.

// Load data by key
var keys = ["coins", "level"]
playgama_bridge_storage_get(json_stringify(keys))

// callback via Async Social Event
if async_load[? "type"] == "playgama_bridge_storage_get_callback" {
	if async_load[? "success"] {
		var values = json_parse(async_load[? "data"])
		var coins = values[0]
		var level = values[1]
		
		if is_undefined(coins) {
			// there is no stored data for key "coins"
		}
		
		if is_undefined(level) {
			// there is no stored data for key "level"
		}
	}
}

// callback via script
function playgama_bridge_storage_get_callback(success, data) {
	if success {
		var values = json_parse(data)
		var coins = values[0]
		var level = values[1]
		
		if is_undefined(coins) {
			// there is no stored data for key "coins"
		}
		
		if is_undefined(level) {
			// there is no stored data for key "level"
		}
	}
}

Save Data

Save data to the specified storage with a key to retain player progress or settings.

var keys = ["coins", "level"]
var values = [42, "dungeon"]
playgama_bridge_storage_set(json_stringify(keys), json_stringify(values))

// callback via Async Social Event
if async_load[? "type"] == "playgama_bridge_storage_set_callback" {
	if async_load[? "success"] {
		// your logic
	}
}

// callback via script
function playgama_bridge_storage_set_callback(success) {
	if success {
		// your logic
	}
}

Delete Data

Remove data from the specified storage by key to manage player data and settings effectively.

var keys = ["coins", "level"]
playgama_bridge_storage_delete(json_stringify(keys))

// callback via Async Social Event
if async_load[? "type"] == "playgama_bridge_storage_delete_callback" {
	if async_load[? "success"] {
		// your logic
	}
}

// callback via script
function playgama_bridge_storage_delete_callback(success) {
	if success {
		// your logic
	}
}

All data operations interact with the default storage type. You can specify the storage type as the second argument. Ensure the storage is supported and available before using it.

var keys = ["coins", "level"]
var values = [42, "dungeon"]
var storage_type = "platform_internal"

playgama_bridge_storage_get(json_stringify(keys), storage_type)

playgama_bridge_storage_set(json_stringify(keys), json_stringify(values), storage_type)

playgama_bridge_storage_delete(json_stringify(keys), storage_type)

Last updated