Data Store – Giavapps Game Jolt API

 

About Data Store Functions

 

For more info about Data Store functions please visit the following link: http://gamejolt.com/api/doc/game/data-store

 

Score Functions

 

gj_datastore_fetch_global(string key) Returns data from the Data Store. This function returns the id of the HTTP request. For more info: http://gamejolt.com/api/doc/game/data-store/fetch

string key: the key of the data item you’d like to fetch.

 

gj_datastore_fetch_user(string key) Returns data from the Data Store for the user. This function returns the id of the HTTP request. For more info: http://gamejolt.com/api/doc/game/data-store/fetch

string key: the key of the data item you’d like to fetch.

 

gj_datastore_set_global(string key, string data) Sets data in the Data Store. This function returns the id of the HTTP request. For more info: http://gamejolt.com/api/doc/game/data-store/set

string key: the key of the data item you’d like to set.

string data: the data you’d like to set.

 

gj_datastore_set_user(string key, string data) Sets data in the Data Store for the user. This function returns the id of the HTTP request. For more info: http://gamejolt.com/api/doc/game/data-store/set

string key: the key of the data item you’d like to set.

string data: the data you’d like to set.

 

gj_datastore_update_global(string key, string operation, string value) Updates data in the Data Store. This function returns the id of the HTTP request. For more info: http://gamejolt.com/api/doc/game/data-store/update

string key: the key of the data item you’d like to update.

string operation: the operation that you’d like to perform. The mathematic operations are add, subtract, multiply and divide. The string operations are append and prepend.

string value: the value that you’d like to work with on the data store.

 

gj_datastore_update_user(string key, string operation, string value) Updates data in the Data Store for the user. This function returns the id of the HTTP request. For more info: http://gamejolt.com/api/doc/game/data-store/update

string key: the key of the data item you’d like to update.

string operation: the operation that you’d like to perform. The mathematic operations are add, subtract, multiply and divide. The string operations are append and prepend.

string value: the value that you’d like to work with on the data store.

 

gj_datastore_remove_global(string key) Removes data from the Data Store. This function returns the id of the HTTP request. For more info: http://gamejolt.com/api/doc/game/data-store/remove

string key: the key of the data item you’d like to remove.

 

gj_datastore_remove_user(string key) Removes data from the Data Store for the user. This function returns the id of the HTTP request. For more info: http://gamejolt.com/api/doc/game/data-store/remove

string key: the key of the data item you’d like to remove.

 

gj_datastore_get_keys_global() Returns all the keys in the game’s global Data Store. This function returns the id of the HTTP request. For more info: http://gamejolt.com/api/doc/game/data-store/get-keys

 

gj_datastore_get_keys_user() Returns all the keys in the game’s user Data Store. This function returns the id of the HTTP request. For more info: http://gamejolt.com/api/doc/game/data-store/get-keys

 

Code Examples

 

Setting Data In The Game’s Global Data Store

 

Create Event

 

gj_init("game_id","private_key");//Initializes Giavapps Game Jolt API
request_user_auth = gj_user_auth("username","user_token");//Authenticates the user
request_datastore_set_global = –1;//Request for setting data in the Data Store

 

Game End Event

 

gj_deinit();//Deinitializes Giavapps Game Jolt API

 

Async – HTTP Event

 

if(gj_http_status() != 0){exit;}//Checks if the status is complete

gj_http_result();//Retrieves result data for gj_result_* functions

if(gj_http_id() == request_user_auth)//Checks if the id is equal to the http request id
{

if(gj_result_success())
{
show_debug_message("THE USER’S CREDENTIALS ARE VALID!");
request_datastore_set_global = gj_datastore_set_global("global","data");//Sets data in the Data Store
}
else
{
show_debug_message("THE USER’S CREDENTIALS ARE INVALID!");
}

}
else if(gj_http_id() == request_datastore_set_global)//Checks if the id is equal to the http request id
{

if(gj_result_success())
{
show_debug_message("DATA HAS BEEN SET!");
}
else
{
show_debug_message("DATA HAS NOT BEEN SET!");
}

}

 

Comments are closed.