Difference between revisions of "FBInstant.player.setDataAsync"

From GiderosMobile
Line 2: Line 2:
 
'''Available since:''' Gideros 2018.3<br/>
 
'''Available since:''' Gideros 2018.3<br/>
 
=== Description ===
 
=== Description ===
<br />
+
<translate><br />
 
Set data to be saved to the designated cloud storage of the current player. The game can store up to 1MB of data for each unique player.<br />
 
Set data to be saved to the designated cloud storage of the current player. The game can store up to 1MB of data for each unique player.<br />
<br />
+
<br /></translate>
 
<source lang="lua">
 
<source lang="lua">
 
  FBInstant.player.setDataAsync(keys-value-pairs,callback)
 
  FBInstant.player.setDataAsync(keys-value-pairs,callback)
 
</source>
 
</source>
 
=== Parameters ===
 
=== Parameters ===
'''keys-value-pairs''': (table) A table containing a set of key-value pairs that should be persisted to cloud storage. The object must contain only serializable values - any non-serializable values will cause the entire modification to be rejected. <br/>
+
'''keys-value-pairs''': (table) <translate>A table containing a set of key-value pairs that should be persisted to cloud storage. The object must contain only serializable values - any non-serializable values will cause the entire modification to be rejected.</translate> <br/>
'''callback''': (function) A function that will be called with two arguments: true or nil if the operation failed, and an error code if the function failed.  NOTE: True does not necessarily mean that the input has already been persisted. Rather, it means that the data was valid and has been scheduled to be saved. It also guarantees that all values that were set are now available in player.getDataAsync <br/>
+
'''callback''': (function) <translate>A function that will be called with two arguments: true or nil if the operation failed, and an error code if the function failed.  NOTE: True does not necessarily mean that the input has already been persisted. Rather, it means that the data was valid and has been scheduled to be saved. It also guarantees that all values that were set are now available in player.getDataAsync</translate> <br/>
 
=== Examples ===
 
=== Examples ===
 
'''Example'''<br/>
 
'''Example'''<br/>
<source lang="lua"><br />
+
<source lang="lua">
 
FBInstant.player.setDataAsync({achievements={"medal1","medal2","medal3"},currentLife=300}, function(result,error)
 
FBInstant.player.setDataAsync({achievements={"medal1","medal2","medal3"},currentLife=300}, function(result,error)
 
     if result then
 
     if result then

Revision as of 13:38, 23 August 2018

Available since: Gideros 2018.3

Description


Set data to be saved to the designated cloud storage of the current player. The game can store up to 1MB of data for each unique player.

 FBInstant.player.setDataAsync(keys-value-pairs,callback)

Parameters

keys-value-pairs: (table) A table containing a set of key-value pairs that should be persisted to cloud storage. The object must contain only serializable values - any non-serializable values will cause the entire modification to be rejected.
callback: (function) A function that will be called with two arguments: true or nil if the operation failed, and an error code if the function failed. NOTE: True does not necessarily mean that the input has already been persisted. Rather, it means that the data was valid and has been scheduled to be saved. It also guarantees that all values that were set are now available in player.getDataAsync

Examples

Example

FBInstant.player.setDataAsync({achievements={"medal1","medal2","medal3"},currentLife=300}, function(result,error)
    if result then
		print("data is set")
	end
end)
<br/>