Get login in your game in 5 minutes. Select your language below.
C# Unity3D
Blueprints Unreal
C++ Unreal Engine
JS Playcanvas, PixiJS, BabylonJS
API Full REST API
Getting Started
Game Connection and Variables
Signing game users up
Signing game users in
Creating store items on the web
Using the store in your game
Using Credits
Custom user data
In game leaderboard
Forgot Password
Class Methods
Use GameFuse C# in your Unity project to easily add authenticaion, user data, leaderboards, in game stores and more all without writing and hosting any servers, or writing any API code. Its never been easier to store your data online! GameFuse is always free for hobby and small indie projects. With larger usage there are metered usage fees.
The first step of integrating GameFuse with your project, is to make an account
After creating your account, add your first game and note the ID and API Token.
With this setup, you can now connect via your game client. Download the library and unzip the code from the Github, then add to your Unity project in the Scripts folder.
If you would like to see an example of how the code works, check out
At this point in time, you would add the prefab in this folder GameFuseInitializer
You can also build this manually by adding new GameObject to your first scene, and add a number of script componenets:
At this point in time you have the library installed in your game, and you are ready to connect
Use GameFuse in your UnrealEngine project to easily add authenticaion, user data, leaderboards, in game stores and more all without writing and hosting any servers, or writing any API code. Its never been easier to store your data online! GameFuse is always free for hobby and small indie projects. With larger usage there are metered usage fees.
The first step of integrating GameFuse with your project, is to make an account
After creating your account, add your first game and note the ID and API Token.
With this setup, you can now connect via your game client. Download the Plugin and unzip the code from the the Unreal Store or Github, then add to your UnrealEngine project in the Plugins folder and Enable it inside the Engine.
after this, add "GameFuse" plugin into your Project.build.cs
Click on the following link to see an example of GameFuse implemented in Unreal 5.2.1
Use GameFuse in your UnrealEngine project to easily add authenticaion, user data, leaderboards, in game stores and more all without writing and hosting any servers, or writing any API code. Its never been easier to store your data online! GameFuse is always free for hobby and small indie projects. With larger usage there are metered usage fees.
The first step of integrating GameFuse with your project, is to make an account
After creating your account, add your first game and note the ID and API Token.
With this setup, you can now connect via your game client. Download the Plugin and unzip the code from the the Unreal Store or Github, then add to your UnrealEngine project in the Plugins folder and Enable it inside the Engine.
Click on the following link to see an example of GameFuse implemented in Unreal 5.2.1
Use GameFuse Javascript in your JS Game project to easily add authenticaion, user data, leaderboards, in game stores and more all without writing and hosting any servers, or writing any API code. Its never been easier to store your data online! GameFuse is always free for hobby and small indie projects. With larger usage there are metered usage fees.
The first step of integrating GameFuse with your project, is to make an account at https://www.gamefuse.co. After creating your account, add your first game and note the ID and API Token. With this setup, you can now connect via your game client.
If your game engine has an editable HTML file, you can paste the following tag in the header of the HTML document:
<script src="https://cdn.jsdelivr.net/gh/game-fuse/game-fuse-js@main/V2/gameFuseFull.js"></script>
Playcanvas has a different method, in your scene, go to the settings wheel on the top bar, then click on "external scripts" on the left panel that is opened, then paste the following:
"https://cdn.jsdelivr.net/gh/game-fuse/game-fuse-js@main/V2/gameFuseFull.js".
This effectivly does the same thing as the prior method on build.
If you would like to see an example in action, check out here
The first step of integrating GameFuse with your project, is to make an account at https://www.gamefuse.co. After creating your account, you can begin making API calls.
The first step in using GameFuse after it is installed and your account is regestered is to run the SetUpGame function. After this step you can run other functions to register users, sign in users, read and write game data.
At the top of any script you want to use the GameFuse library in, you will need to do:
using GameFuseCSharp;
In any script on your first scene you can run:
void Start () {
var gameID = 'Your Game ID Here';
var gameToken 'your Game Token Here';
# 3rd param is the function below, GameFuse will call this function when it is done connecting your game
GameFuse.SetUpGame(gameToken, gameID, GameSetUpCallback);
}
void GameSetUpCallback(string message, bool hasError) {
if (hasError)
{
Debug.Log("Error connecting game: "+message);
}
else
{
Debug.Log("Game Connected Successfully")
foreach (GameFuseStoreItem storeItem in GameFuse.GetStoreItems())
{
Debug.Log(storeItem.GetName() + ": " + storeItem.GetCost());
}
}
}
* 401 - failed to verify game
* 500 - unknown server error
Your Game Variables will be downloaded when you verify and connect with your game, but you can also re-fetch them whwnever you like.
In any script run:
void Start () {
var gameID = 'Your Game ID Here';
var gameToken 'your Game Token Here';
# 3rd param is the function below, GameFuse will call this function when it is done connecting your game
GameFuse.FetchGameVariables(gameID, gameToken, VariablesFetched);
}
void VariablesFetched(string message, bool hasError) {
if (hasError)
{
Debug.Log("Error connecting game: "+message);
}
else
{
Debug.Log("Game Connected Successfully")
}
}
* 404 - Failed to fetch game variables, check your token and id
* 500 - unknown server error
The initial action after installing GameFuse and registering your account is to execute the 'SetUpGame' function. Following this step, you can proceed to call other functions for user registration, user sign-in, and reading or writing game data. It's advisable to include the 'SetUpGame' function in your GameMode to ensure it's invoked when your game begins.
Make sure to include this header to enable the utilization of GameFuse functions:
#include "GameFuseManager.h"
In any script on your first scene you can run:
void AMyGameModeBase::Start()
{
const FString GameId = "{your-game-id}";
const FString Token = "{your-game-token}";
constexpr bool bSeedStore = false;
FManagerCallback CompletionCallback;
CompletionCallback.BindDynamic(this, &AMyGameModeBase::GameSetUpCallback);
UGameFuseManager::SetUpGame(GameId, Token, bSeedStore, CompletionCallback);
}
void AMyGameModeBase::GameSetUpCallback(bool bSuccess, const FString& Response)
{
if(bSuccess)
{
UE_LOG(LogTemp, Display, TEXT("SetUp Game Success"));
UE_LOG(LogTemp, Display, TEXT("Result : %s"), *Response);
}else
{
UE_LOG(LogTemp, Error, TEXT("SetUp Game Failed"));
UE_LOG(LogTemp, Error, TEXT("Result : %s"), *Response);
}
}
* 401 - failed to verify game
* 500 - unknown server error
Your Game Variables will be downloaded when you verify and connect with your game, but you can also re-fetch them whwnever you like.
void UMyObject::Start()
{
FManagerCallback CompletionCallback;
CompletionCallback.BindDynamic(this, &UMyObject::VariablesFetchedCallback);
UGameFuseManager::FetchGameVariables(CompletionCallback);
}
void UMyObject::VariablesFetchedCallback(bool bSuccess, const FString& Response)
{
if(bSuccess)
{
UE_LOG(LogTemp, Display, TEXT("Game Connected Successfully"));
UE_LOG(LogTemp, Display, TEXT("Result : %s"), *Response);
TMap < FString, FString > OurVariables = UGameFuseManager::GetGameVariables();
}else
{
UE_LOG(LogTemp, Error, TEXT("Error connecting game"));
UE_LOG(LogTemp, Error, TEXT("Result : %s"), *Response);
}
}
* 404 - Failed to fetch game variables, check your token and id
* 500 - unknown server error
The first step in using GameFuse after it is installed and your account is regestered is to use the SetUpGame node. After this step you can run other nodes to register users, sign in users, read and write game data.
In any blueprints on your game, use the "SetUpGame" node as part of your game's initialization process. This means it should be one of the first things that happen when your game starts
Your Game Variables will be fetch when you verify and connect with your game, but you can also re-fetch them whwnever you like.
In any Blueprints use:
The first step in using GameFuse after it is installed and your account is regestered is to run the SetUpGame function. After this step you can run other functions to register users, sign in users, read and write game data.
In any script on your first scene you can run:
start () {
var gameID = 'Your Game ID Here';
var gameToken 'your Game Token Here';
# 3rd param is the function below, GameFuse will call this function when it is done connecting your game
let self = this;
GameFuse.setUpGame(gameID, gameToken, function(message,hasError){self.gameSetUp(message,hasError)}, true);
}
gameSetUp(message, hasError) {
if (hasError)
{
console.log("Error connecting game: "+message);
}
else
{
console.log("Game Connected Successfully")
foreach (GameFuseStoreItem storeItem in GameFuse.GetStoreItems())
{
console.log(storeItem.getName() + ": " + storeItem.getCost());
}
}
}
* 401 - failed to verify game
* 500 - unknown server error
Your Game Variables will be downloaded when you verify and connect with your game, but you can also re-fetch them whwnever you like.
In any script run:
void Start () {
var gameID = 'Your Game ID Here';
var gameToken 'your Game Token Here';
# 3rd param is the function below, GameFuse will call this function when it is done connecting your game
GameFuse.fetchGameVariables(gameID, gameToken, function(message,hasError){self.variablesFetched(message,hasError)});
}
void variablesFetched(string message, bool hasError) {
if (hasError)
{
console.log("Error connecting game: "+message);
}
else
{
console.log("Game Connected Successfully")
console.log(`Game Variables: ${GameFuse.Instance.GetGameVariable({your key})}`)
}
}
* 404 - Failed to fetch game variables, check your token and id
* 500 - unknown server error
Once an account is created, you can verify your game and hit the connect endpoint to verfiy your game before using GameFuse enpoints with specific users:
https://gamefuse.co/api/v2/games/verify.json?game_id={game id}&game_token={api token}
It will have the following URL parameters:
game_id: {found on your GameFuse.co dashboard}
game_token: {API token found on your GameFuse.co dashboard}
This will return a response with the following json:
{
"id": {DB unique id of the game},
"name": {name of the game},
"token": {api token of the game},
"description": {game description},
"game_variables": [
{
"id": {game_variable id 1},
"key": {game_variable key 1},
"value": {game_variable id 1}
},
{
"id": {game_variable id 2},
"key": {game_variable key 2},
"value": {game_variable id 2}
}...
]
}
* 401 - failed to verify game
* 500 - unknown server error
This is not a required step, but can be useful to verify a connection before logging in specific users
Your Game Variables will be downloaded when you verify and connect with your game, but you can also re-fetch them whwnever you like.
https://gamefuse.co/api/v2/games/fetch_game_variables.json?game_id={game id}&game_token={api token}
It will have the following URL parameters:
game_id: {found on your GameFuse.co dashboard}
game_token: {API token found on your GameFuse.co dashboard}
This will return a response with the following json:
{
"id": {DB unique id of the game},
"name": {name of the game},
"token": {api token of the game},
"description": {game description},
"game_variables": [
{
"id": {game_variable id 1},
"key": {game_variable key 1},
"value": {game_variable id 1}
},
{
"id": {game_variable id 2},
"key": {game_variable key 2},
"value": {game_variable id 2}
}...
]
}
* 404 - Failed to fetch game variables, check your token and id
* 500 - unknown server error
Enable users to sign up in your Unity game with the following code. They will be saved on your GameFuse Game and can then login from other devices since the data is saved online. Add a method on a MonoBehavior on your sign up scene after you have collected your inputted username and password. Maybe this is on a a button function for a 'submit' or 'register' button. Username is mandatory but it is just for display. Later sign in attempts will use email not username
#Feed in your users email, username and password here
void SignUp (email, password, password_confirmation, username) {
#5th parameter is the callback when execution is complete
GameFuse.SignUp(userEmail, "password", "password", username, SignedUp);
}
void SignedUp(string message, bool hasError) {
if (hasError)
{
Debug.Log("Error signign up: "+message);
}
else
{
Debug.Log("Signed Up: " + GameFuseUser.CurrentUser.GetUsername());
}
}
* 404 - Failed to fetch game variables, check your token and id
* 500 - unknown server error
Enable users to sign up in your UnrealEngine game with the following code. They will be saved on your GameFuse Game and can then login from other devices since the data is saved online.
void UMyObject::SignUp(const FString& Email, const FString& Password, const FString& PasswordConfirmation,
const FString& Username)
{
FUserCallback CompletionCallback;
CompletionCallback.BindDynamic(this, &UMyObject::SignedUpCallback);
UGameFuseUser* GameFuseUser = GEtgaMeinstance()->getsubsysTEm < uGameFuseuser > ();
GameFuseUser->SignUp(Email, Password, PasswordConfirmation, Username, CompletionCallback);
}
void UMyObject::SignedUpCallback(bool bSuccess, const FString& Response)
{
if(bSuccess)
{
UE_LOG(LogTemp, Display, TEXT("Game Connected Successfully"));
UE_LOG(LogTemp, Display, TEXT("Result : %s"), *Response);
}else
{
UE_LOG(LogTemp, Error, TEXT("Error connecting game"));
UE_LOG(LogTemp, Error, TEXT("Result : %s"), *Response);
}
}
To access the game user object form anywhere in the code, you can use the subsystem:
UGameFuseUser* GameFuseUser = GetGameInstance()->GetSubsystem < UGameFuseUser > ();
* 404 - Failed to fetch game variables, check your token and id
* 500 - unknown server error
Enable users to sign up in your UnrealEngine game with the following node. They will be saved on your GameFuse Game and can then login from other devices since the data is saved online.
In any of your game's blueprints, simply right-click and initiate a search for "GetGameFuseUser." Utilize this subsystem node to acquire a GameFuseUser Object. Once you have this object, you can proceed by dragging it and searching for the "SignUp" node.
Enable users to sign up in your Unity game with the following code. They will be saved on your GameFuse Game and can then login from other devices since the data is saved online. Add a method on a script on your sign up scene after you have collected your inputted username and password. Maybe this is on a a button function for a 'submit' or 'register' button. Username is mandatory but it is just for display. Later sign in attempts will use email not username
#Feed in your users email, username and password here
signUp (email, password, password_confirmation, username) {
#5th parameter is the callback when execution is complete
let self = this;
GameFuse.signUp(this.userEmail, "password", "password", this.username, function(message,hasError){self.signedUp(message,hasError)});
}
signedUp(message, hasError) {
if (hasError)
{
console.log("Error signign up: "+message);
}
else
{
console.log("Signed Up: " + GameFuseUser.CurrentUser.getUsername());
}
}
* 404 - Failed to fetch game variables, check your token and id
* 500 - unknown server error
Once your account is verified, you should take note of that API token and ID, you will need it on each subsequent request. To sign a new user up in your game, you can hit
https://gamefuse.co/api/v2/users?email={email}&password={password}&password_confirmation={password_confirmation}&username={username}&game_id={game id}&game_token={api token}
It will have the following URL parameters:
email: {users email, used for login and forgot password functionality}
password: {users password}
password_confirmation: {users password}
username: {users display name, used on leaderboards, must be unique for your game}
game_id: {found on your GameFuse.co dashboard}
game_token: {API token found on your GameFuse.co dashboard}
This will return a response with the following json:
{
"id": {users id},
"username": {users display username},
"email": {system email - a combination of game id and email},
"display_email": {users actual email, used for notifications and login}
"credits": {number of credits user has, these can be used in your in game store},
"score": {a generic score metric that you can use},
"last_login": {timestamp of last login},
"number_of_logins": {total logins},
"authentication_token": {authentication token, this must be saved and added as a parameter to all authenticated requests},
"events_total": {running api hits for this user},
"events_current_month": {running api hits for this user for this month},
"game_sessions_total": {unique game session for this user},
"game_sessions_current_month": {unique game session for this user for this month}
}
* 404 - Failed to fetch game variables, check your token and id
* 500 - unknown server error
Signing In Follows the same protocal as signing up, just with different parateters. As always, there is a callback function to let you know your sign in has been successful or not. Email and password (not username), will be used to sign in
#Feed in your users email and password here
void SignIn (email, password, SignedIn) {
#3rd parameter is the callback when execution is complete
GameFuse.SignIn(userEmail, password, SignedIn);
}
void SignedIn(string message, bool hasError) {
if (hasError)
{
Debug.Log("Error signign up: "+message);
}
else
{
Debug.Log("Logged In: " + GameFuseUser.CurrentUser.GetUsername());
Debug.Log("Current Credits: " + GameFuseUser.CurrentUser.GetCredits());
}
}
# 404 - Incorrect Password
# 404 - User Not Found!
# 402 - Game is disabled - developer check GameFuse dashboard
* 500 - unknown server error
Signing In Follows the same protocal as signing up, just with different parateters. As always, there is a callback function to let you know your sign in has been successful or not. Email and password (not username), will be used to sign in
void UMyObject::SignIn(const FString& Email, const FString& Password)
{
FUserCallback CompletionCallback;
CompletionCallback.BindDynamic(this, &UMyObject::SignedInCallback);
UGameFuseUser* GameFuseUser = GEtgaMeinstance()->getsubsysTEm < uGameFuseuser > ();
GameFuseUser->SignIn(Email, Password, CompletionCallback);
}
void UMyObject::SignedInCallback(bool bSuccess, const FString& Response)
{
if(bSuccess)
{
UE_LOG(LogTemp, Display, TEXT("Game Connected Successfully"));
UE_LOG(LogTemp, Display, TEXT("Result : %s"), *Response);
}else
{
UE_LOG(LogTemp, Error, TEXT("Error connecting game"));
UE_LOG(LogTemp, Error, TEXT("Result : %s"), *Response);
}
}
# 404 - Incorrect Password
# 404 - User Not Found!
# 402 - Game is disabled - developer check GameFuse dashboard
* 500 - unknown server error
Signing In Follows the same protocol as signing up, just with different parameters. As always, there is a callback custom event to let you know your sign in has been successful or not. Email and password (not username), will be used to sign in.
Signing In Follows the same protocal as signing up, just with different parateters. As always, there is a callback function to let you know your sign in has been successful or not. Email and password (not username), will be used to sign in
#Feed in your users email and password here
signIn (email, password, SignedIn) {
#3rd parameter is the callback when execution is complete
let self = this;
GameFuse.signIn(this.userEmail, "password", function(message,hasError){self.signedIn(message,hasError)});
}
signedIn(message, hasError) {
if (hasError)
{
console.log("Error signign in: "+message);
}
else
{
console.log("Logged In: " + GameFuseUser.CurrentUser.getUsername());
console.log("Current Credits: " + GameFuseUser.CurrentUser.getCredits());
}
}
# 404 - Incorrect Password
# 404 - User Not Found!
# 402 - Game is disabled - developer check GameFuse dashboard
* 500 - unknown server error
After sign up, you should provide a sign in function for users to login later
https://gamefuse.co/api/v2/sessions?email={email}&password={password}&game_id={game id}&game_token={api token}
It will have the following URL parameters:
email: {users email, used for login and forgot password functionality}
password: {users password}
game_id: {found on your GameFuse.co dashboard}
game_token: {API token found on your GameFuse.co dashboard}
This will return a response with the following json:
{
"id": {users id},
"username": {users display username},
"email": {system email - a combination of game id and email},
"display_email": {users actual email, used for notifications and login}
"credits": {number of credits user has, these can be used in your in game store},
"score": {a generic score metric that you can use},
"last_login": {timestamp of last login},
"number_of_logins": {total logins},
"authentication_token": {authentication token, this must be saved and added as a parameter to all authenticated requests},
"events_total": {running api hits for this user},
"events_current_month": {running api hits for this user for this month},
"game_sessions_total": {unique game session for this user},
"game_sessions_current_month": {unique game session for this user for this month}
}
# 404 - Incorrect Password
# 404 - User Not Found!
# 402 - Game is disabled - developer check GameFuse dashboard
* 500 - unknown server error
To create store items on the web, navigate to your GameFuse.co home page, and sign in if you are not already You can click on your Game on the homepage you want to add items for. On this page if you scroll down to the Store Items section, you will see + STORE ITEM button, here you can add in Name, Cost, Description, and Category. All are mandatory but do not need to used in your game. The store feature does not integrate real payment systems, this is for items you want your users to be able to "unlock" with in-game-currency or with achievements in the game. How you configure that is up to you.
Store Items Library are downloaded upon SignIn() and SignUp(), The Items will be refreshed every time the user signs in or signs up again. To access store items and attributes by calling the following code. This doesnt sync them with the available items on the server, it is simply showing you the results downloaded on sign in or sign up.
foreach (GameFuseStoreItem storeItem in GameFuse.GetStoreItems())
{
Debug.Log(storeItem.GetName()); //FireBow
Debug.Log(storeItem.GetCategory()); //BowAndArrows
Debug.Log(storeItem.GetId()); //12
Debug.Log(storeItem.GetDescription()); //A bow and arrow item that shoots fire arrows
Debug.Log(storeItem.GetCost()); // 500 (credits)
Debug.log(storeItem.GetIconUrl()); // (url of image associated with the store item)
}
To access purchased store items by your current logged in user call the following. Because these are downloaded on login, there is no callback for this! It is already available! This will throw an error if you are not signed in already
List < GameFuseStoreItem > items = GameFuseUser.CurrentUser.GetPurchasedStoreItems();
To Purchase a store item simply call the code below. Because this function talks to the server, it will require a callback. If the user doesnt have enough credits on their account (see next section), the purchase will fail This function will refresh the GameFuseUser.CurrentUser.purchasedStoreItems List with the new item
void PurchaseItem(store_item){
Debug.Log(GameFuseUser.CurrentUser.purchasedStoreItems.Count); // Prints 0
GameFuseUser.PurchaseStoreItem(GameFuse.GetStoreItems().First, PurchasedItemCallback)
}
void PurchasedItemCallback(string message, bool hasError) {
if (hasError)
{
Debug.Log("Error purchasing item: "+message);
}
else
{
Debug.Log("Purchased Item");
Debug.Log(GameFuseUser.CurrentUser.purchasedStoreItems.Count); // Prints 1
}
}
* 500 - unknown server error
Store Items Plugin will fetched upon 'FetchGameVariables()', The Items will be refreshed every time you call 'FetchGameVariables()' again. To access store items and attributes by calling the following code. This will sync them with the available items on the server.
void UMyObject::FetchStoreItems()
{
FManagerCallback CompletionCallback;
CompletionCallback.BindDynamic(this, &UMyObject::SignedInCallback);
UGameFuseManager::FetchGameVariables(CompletionCallback);
}
void UMyObject::OnStoreItemsFetchedCallback(bool bSuccess, const FString& Response)
{
if(bSuccess)
{
UE_LOG(LogTemp, Display, TEXT("Game Connected Successfully"));
UE_LOG(LogTemp, Display, TEXT("Result : %s"), *Response);
TArray< UGameFuseStoreItem* > StoreItems = UGameFuseManager::GetGameStoreItems();
for (UGameFuseStoreItem* StoreItem : StoreItems) {
if (StoreItem) {
UE_LOG(LogTemp, Display, TEXT("Name: %s"), *StoreItem->GetName());
UE_LOG(LogTemp, Display, TEXT("Category: %s"), *StoreItem->GetCategory());
UE_LOG(LogTemp, Display, TEXT("ID: %d"), StoreItem->GetId());
UE_LOG(LogTemp, Display, TEXT("Description: %s"), *StoreItem->GetDescription());
UE_LOG(LogTemp, Display, TEXT("Cost: %d (credits)"), StoreItem->GetCost());
UE_LOG(LogTemp, Display, TEXT("Icon URL: %s"), *StoreItem->GetIconUrl());
}
}
}else
{
UE_LOG(LogTemp, Error, TEXT("Error connecting game"));
UE_LOG(LogTemp, Error, TEXT("Result : %s"), *Response);
}
}
To access purchased store items by your current logged in user call the following. Because these are downloaded on login, there is no callback for this! It is already available! This will throw an error if you are not signed in already
void UMyObject::FetchUserPurchasedStoreItems()
{
FUserCallback CompletionCallback;
CompletionCallback.BindDynamic(this, &UMyObject::OnFetchUserPurchasedStoreItemsCallback);
UGameFuseUser* GameFuseUser = GEtgaMeinstance()->getsubsysTEm < uGameFuseuser > ();
GameFuseUser->FetchPurchaseStoreItems(false, CompletionCallback);
}
void UMyObject::OnFetchUserPurchasedStoreItemsCallback(bool bSuccess, const FString& Response)
{
if(bSuccess)
{
UE_LOG(LogTemp, Display, TEXT("Game Connected Successfully"));
UE_LOG(LogTemp, Display, TEXT("Result : %s"), *Response);
UGameFuseUser* GameFuseUser = GEtgaMeinstance()->getsubsysTEm < uGameFuseuser > ();
TArray < UGameFuseStoreItem* > StoreItems = GameFuseUser->GetPurchasedStoreItems();
}else
{
UE_LOG(LogTemp, Error, TEXT("Error connecting game"));
UE_LOG(LogTemp, Error, TEXT("Result : %s"), *Response);
}
}
To Purchase a store item simply call the code below. Because this function talks to the server, it will require a callback. If the user doesnt have enough credits on their account (see next section), the purchase will fail This function will refresh the GameFuseUser.CurrentUser.purchasedStoreItems List with the new item
void UMyObject::PurchaseStoreItem(UGameFuseStoreItem* StoreItem)
{
FUserCallback CompletionCallback;
CompletionCallback.BindDynamic(this, &UMyObject::OnFetchUserPurchasedStoreItemsCallback);
UGameFuseUser* GameFuseUser = GEtgaMeinstance()->getsubsysTEm < uGameFuseuser > ();
GameFuseUser->PurchaseStoreItem(StoreItem, CompletionCallback);
// Purchase Store Item With Id
// const int StoreItemID = < your-store-item-id > ;
// GameFuseUser->PurchaseStoreItemWithId(StoreItemID, CompletionCallback);
}
void UMyObject::OnPurchaseStoreItemCallback(bool bSuccess, const FString& Response)
{
if(bSuccess)
{
UE_LOG(LogTemp, Display, TEXT("Game Connected Successfully"));
UE_LOG(LogTemp, Display, TEXT("Result : %s"), *Response);
}else
{
UE_LOG(LogTemp, Error, TEXT("Error connecting game"));
UE_LOG(LogTemp, Error, TEXT("Result : %s"), *Response);
}
}
* 500 - unknown server error
Store Items Library are fetched upon SignIn and SignUp, The Items will be refreshed every time the user signs in or signs up again. To access store items and attributes by calling the following node. This doesn't sync them with the available items on the server, it is simply showing you the results downloaded on sign in or sign up.
To access purchased store items by your current logged in user call the following. Because these are downloaded on login, there is no callback for this! It is already available! This will throw an error if you are not signed in already.
To Purchase a store item simply call the node below. Because this node talks to the server, it will require a callback. If the user doesn't have enough credits on their account (see next section), the purchase will fail. This function will refresh the Purchased Store Items List with the new item.
Store Items Library are downloaded upon SignIn() and SignUp(), The Items will be refreshed every time the user signs in or signs up again. To access store items and attributes by calling the following code. This doesnt sync them with the available items on the server, it is simply showing you the results downloaded on sign in or sign up.
for (const storeItem of GameFuse.getStoreItems()) {
console.log(storeItem.getName()); //FireBow
console.log(storeItem.getCategory()); //BowAndArrows
console.log(storeItem.getId()); //12
console.log(storeItem.getDescription()); //A bow and arrow item that shoots fire arrows
console.log(storeItem.getCost()); // 500 (credits)
console.log(storeItem.getIconUrl()); // (url of image associated with the store item)
}
To access purchased store items by your current logged in user call the following. Because these are downloaded on login, there is no callback for this! It is already available! This will throw an error if you are not signed in already
const items = GameFuseUser.CurrentUser.getPurchasedStoreItems();
%p.quickSand To Purchase a store item simply call the code below. Because this function talks to the server, it will require a callback. If the user doesnt have enough credits on their account (see next section), the purchase will fail This function will refresh the GameFuseUser.CurrentUser.purchasedStoreItems List with the new item
PurchaseItem(store_item){
let self = this;
console.log(GameFuseUser.CurrentUser.getPurchasedStoreItems().length); // Prints 0
GameFuseUser.PurchaseStoreItem(GameFuse.GetStoreItems().First, function(message,hasError){self.PurchasedItemCallback(message,hasError)})
}
PurchasedItemCallback(message, hasError) {
if (hasError)
{
console.log("Error purchasing item: "+message);
}
else
{
console.log("Purchased Item");
console.log(GameFuseUser.CurrentUser.getPurchasedStoreItems().length); // Prints 1
}
}
* 500 - unknown server error
To grab all your store items available on your store you can call:
https://gamefuse.co/api/v2/games/store_items?game_id={game id}&game_token={api token}
It will have the following URL parameters:
game_id: {found on your GameFuse.co dashboard}
game_token: {API token found on your GameFuse.co dashboard}
This will return a response with the following json:
{
"store_items": [
{
"id": {first item id},
"name": {first item name},
"cost": {first item cost},
"description": {first item description},
"category": {first item category},
"icon_url": {linked image url for this store item}
},
{
"id": {second item id},
"name": {second item name},
"cost": {second item cost},
"description": {second item description},
"category": {second item category},
"icon_url": {linked image url for this store item}
},
...
]
}
This is a non-authenticated request, a user doesnt need to be signed in since there is no user specific data
* 404 - Failed to verify game
* 500 - unknown server error
To purchase a store item, a user must be signed in and have enough credits. This is our first authenticated request and must have an 'access_token' parameter recieved from a sign_in or sign_up response.
https://gamefuse.co/api/v2/users/{signed in user id}/purchase_game_user_store_item?store_item_id={id of store item}
It will have the following Headers:
authentication_token: {found in sign_in or sign_up response, authentication token for user session}
It will have the following URL parameters:
store_item_id: {item id of store item}
This will return a response with the following json. It has users remaining credits, and a list of all their purchased store items
{
"credits": {users remaining credits},
"game_user_store_items": [
{
"id": {purchased item 1 id},
"name": {purchased item 1 name},
"cost": {purchased item 1 cost},
"description": "{purchased item 1 description},
"category": {purchased item 1 category},
"icon_url": {linked image url for purchased item 1}
},
{
"id": {purchased item 2 id},
"name": {purchased item 2 name},
"cost": {purchased item 2 cost},
"description": "{purchased item 2 description},
"category": {purchased item 2 category},
"icon_url": {linked image url for purchased item 2}
},
...
]
}
* 403 - Already Purchased
* 403 - Not Enough Credits
* 404 - Item not found
* 500 - unknown server error
To revoke a store item purchase, a user must be signed in.
https://gamefuse.co/api/v2/users/{signed in user id}/remove_game_user_store_item?store_item_id={id of store item to delete}
It will have the following Headers:
authentication_token: {found in sign_in or sign_up response, authentication token for user session}
It will have the following URL parameters:
store_item_id: {item id of store item to delete}
This will return a response with the following json. It has users remaining credits, and a list of all their purchased store items
{
"credits": {users remaining credits},
"game_user_store_items": [
{
"id": {purchased item 1 id},
"name": {purchased item 1 name},
"cost": {purchased item 1 cost},
"description": "{purchased item 1 description},
"category": {purchased item 1 category},
"icon_url": {linked image url for purchased item 1}
},
{
"id": {purchased item 2 id},
"name": {purchased item 2 name},
"cost": {purchased item 2 cost},
"description": "{purchased item 2 description},
"category": {purchased item 2 category},
"icon_url": {linked image url for purchased item 2}
},
...
]
}
* 404 - Store item does not exist, or was not purchase
* 500 - unknown server error
To check out all of the users purchased store items
https://gamefuse.co/api/v2/users/{signed in user id}/game_user_store_items
It will have the following Headers:
authentication_token: {found in sign_in or sign_up response, authentication token for user session}
This will return a response with the following json. It has users remaining credits, and a list of all their purchased store items
{
"credits": {users remaining credits},
"game_user_store_items": [
{
"id": {purchased item 1 id},
"name": {purchased item 1 name},
"cost": {purchased item 1 cost},
"description": "{purchased item 1 description},
"category": {purchased item 1 category},
"icon_url": {linked image url for purchased item 1}
},
{
"id": {purchased item 2 id},
"name": {purchased item 2 name},
"cost": {purchased item 2 cost},
"description": "{purchased item 2 description},
"category": {purchased item 2 category},
"icon_url": {linked image url for purchased item 2}
},
...
]
}
* 500 - unknown server error
Credits are a numeric attribute of each game user. It is a simple integer value. You can add them manually and they are detracted automatically upon store item purchases Below is a script to demonstrate the full lifecycle of credits on a signed in user. First it prints the credits your signed in user has, then prints the cost of the first store item, then it adds credits to your user. Because this syncs with the server, it requires a callback. Upon success, you will see the user now has more credits when logged. At this point in time you can then run the purchase store item function successfully.
void Start(){
Debug.Log(GameFuseUser.CurrentUser.credits; // Prints 0
Debug.Log(GameFuse.GetStoreItems().First.cost) // Prints 25 (or whatever you set your first item to on the web dashboard)
GameFuseUser.CurrentUser.AddCredits(50, AddCreditsCallback);
}
void AddCreditsCallback(string message, bool hasError)
{
if (hasError)
{
Debug.Log("Error adding credits: " + message);
}
else
{
Debug.Log(GameFuseUser.CurrentUser.credits; // Prints 50
GameFuseUser.PurchaseStoreItem(GameFuse.GetStoreItems().First, PurchasedItemCallback)
}
}
void PurchasedItemCallback(string message, bool hasError) {
if (hasError)
{
Debug.Log("Error purchasing item: "+message);
}
else
{
Debug.Log("Purchased Item");
Debug.Log("Current Credits: " + GameFuseUser.CurrentUser.GetCredits());
}
}
* 400 - Please include a credits param
* 500 - unknown server error
Credits are a numeric attribute of each game user. It is a simple integer value. You can add them manually and they are detracted automatically upon store item purchases Below is a script to demonstrate the full lifecycle of credits on a signed in user. First it prints the credits your signed in user has, then prints the cost of the first store item, then it adds credits to your user. Because this syncs with the server, it requires a callback. Upon success, you will see the user now has more credits when logged. At this point in time you can then run the purchase store item function successfully.
void UMyObject::UsingCredits()
{
FUserCallback CompletionCallback;
CompletionCallback.BindDynamic(this, &UMyObject::OnCreditAddedCallback);
UGameFuseUser* GameFuseUser = GEtgaMeinstance()->getsubsysTEm < uGameFuseuser > ();
TArray < UGameFuseStoreItem* > StoreItems = UGameFuseManager::GetGameStoreItems();
UE_LOG(LogTemp, Error, TEXT("current credits : %d"), GameFuseUser->GetCredits());
UE_LOG(LogTemp, Error, TEXT("first store item price : %d"), (UGameFuseManager::GetGameStoreItems().Top()->GetCost()));
GameFuseUser->AddCredits(50, CompletionCallback);
}
void UMyObject::OnCreditAddedCallback(bool bSuccess, const FString& Response)
{
if(bSuccess)
{
UE_LOG(LogTemp, Display, TEXT("Game Connected Successfully"));
UE_LOG(LogTemp, Display, TEXT("Result : %s"), *Response);
FUserCallback CompletionCallback;
CompletionCallback.BindDynamic(this, &UMyObject::OnPurchaseStoreItemCallback);
UGameFuseUser* GameFuseUser = GEtgaMeinstance()->getsubsysTEm < uGameFuseuser > ();
GameFuseUser->PurchaseStoreItem(UGameFuseManager::GetGameStoreItems().Top(), CompletionCallback);
}else
{
UE_LOG(LogTemp, Error, TEXT("Error connecting game"));
UE_LOG(LogTemp, Error, TEXT("Result : %s"), *Response);
}
}
void UMyObject::OnPurchaseStoreItemCallback(bool bSuccess, const FString& Response)
{
if(bSuccess)
{
UE_LOG(LogTemp, Display, TEXT("Game Connected Successfully"));
UE_LOG(LogTemp, Display, TEXT("Result : %s"), *Response);
}else
{
UE_LOG(LogTemp, Error, TEXT("Error connecting game"));
UE_LOG(LogTemp, Error, TEXT("Result : %s"), *Response);
}
}
* 400 - Please include a credits param
* 500 - unknown server error
Credits are a numeric attribute of each game user. It is a simple integer value. You can add them manually and they are detracted automatically upon store item purchases. Below is a script to demonstrate the full lifecycle of credits on a signed-in user. First, it prints the credits your signed-in user has, then prints the cost of the first store item, then it adds credits to your user. Because this syncs with the server, it requires a callback. Upon success, you will see the user now has more credits when logged. At this point in time, you can then run the purchase store item function successfully.
Credits are a numeric attribute of each game user. It is a simple integer value. You can add them manually and they are detracted automatically upon store item purchases Below is a script to demonstrate the full lifecycle of credits on a signed in user. First it prints the credits your signed in user has, then prints the cost of the first store item, then it adds credits to your user. Because this syncs with the server, it requires a callback. Upon success, you will see the user now has more credits when logged. At this point in time you can then run the purchase store item function successfully.
Start(){
let self = this;
console.log(GameFuseUser.CurrentUser.getCredits()); // Prints 0
console.log(GameFuse.getStoreItems()[0].cost) // Prints 25 (or whatever you set your first item to on the web dashboard)
GameFuseUser.CurrentUser.AddCredits(50, function(message,hasError){self.AddCreditsCallback(message,hasError)});
}
AddCreditsCallback(message, hasError)
{
if (hasError)
{
console.log("Error adding credits: " + message);
}
else
{
let self = this;
console.log(GameFuseUser.CurrentUser.getCredits(); // Prints 50
GameFuseUser.PurchaseStoreItem(GameFuse.GetStoreItems()[0], function(message,hasError){self.PurchasedItemCallback(message,hasError)})
}
}
PurchasedItemCallback(message, hasError) {
if (hasError)
{
console.log("Error purchasing item: "+message);
}
else
{
console.log("Purchased Item");
console.log("Current Credits: " + GameFuseUser.CurrentUser.GetCredits());
}
}
* 400 - Please include a credits param
* 500 - unknown server error
Credits are a numeric attribute of each game user. It is a simple integer value. You can add them manually and they are detracted automatically upon store item purchases. You can manually add and remove them via an API call, in addition to purchasing store items with them.
To alter the amount of credits a users has relativly, use:
https://gamefuse.co/api/v2/users/{signed in user id}/add_credits?credits={credits to add}
It will have the following Headers:
authentication_token: {found in sign_in or sign_up response, authentication token for user session}
It will have the following URL parameters:
credits: {the amount of credits positive or negative you want to alter the users current credits by}
This will return a response with the following json. It has users remaining credits, and a list of all their purchased store items
{
"id": {users id},
"username": {users display username},
"email": {system email - a combination of game id and email},
"display_email": {users actual email, used for notifications and login}
"credits": {number of credits user has, these can be used in your in game store},
"score": {a generic score metric that you can use},
"last_login": {timestamp of last login},
"number_of_logins": {total logins},
"authentication_token": {authentication token, this must be saved and added as a parameter to all authenticated requests},
"events_total": {running api hits for this user},
"events_current_month": {running api hits for this user for this month},
"game_sessions_total": {unique game session for this user},
"game_sessions_current_month": {unique game session for this user for this month}
}
* 400 - Please include a credits param
* 500 - unknown server error
To set the amount of credits a users has absolutly, meaning the credits param will be the users new credits total, use:
https://gamefuse.co/api/v2/users/{signed in user id}/set_credits?credits={credits to add}
It will have the following Headers:
authentication_token: {found in sign_in or sign_up response, authentication token for user session}
It will have the following URL parameters:
credits: {the amount of credits a user will now have}
This will return a response with the following json:
{
"id": {users id},
"username": {users display username},
"email": {system email - a combination of game id and email},
"display_email": {users actual email, used for notifications and login}
"credits": {number of credits user has, these can be used in your in game store},
"score": {a generic score metric that you can use},
"last_login": {timestamp of last login},
"number_of_logins": {total logins},
"authentication_token": {authentication token, this must be saved and added as a parameter to all authenticated requests},
"events_total": {running api hits for this user},
"events_current_month": {running api hits for this user for this month},
"game_sessions_total": {unique game session for this user},
"game_sessions_current_month": {unique game session for this user for this month}
}
* 400 - Please include a credits param
* 500 - unknown server error
Custom user data or Key Value pairs are a simple way to save any kind of data for a particular user. Some examples might be {"world_2_unlocked":"true"}, {"player_color","red"}, {"favorite_food","Onion"} These are downloaded to your system upon login, and synced when one is updated. You can access with GameFuseUser.CurrentUser.attributes
All values and keys must be strings. If you want to use other data structures like arrays, you could stringify the array on save, and convert the saved string to an array on load:
void Start(){
Debug.Log(GameFuseUser.CurrentUser.attributes.Count); // Prints 0
Debug.Log(GameFuseUser.CurrentUser.GetAttributeValue("CURRENT_LEVEL") == null); // Prints true
GameFuseUser.CurrentUser.SetAttribute("CURRENT_LEVEL", "5", SetAttributeCallback);
}
void SetAttributeCallback(string message, bool hasError) {
if (hasError)
{
Debug.Log("Error setting attribute: "+message);
}
else
{
Debug.Log(GameFuseUser.CurrentUser.GetAttributeValue("CURRENT_LEVEL")); // Prints "5"
}
}
You can also batch update a custom dictionary of key value pairs like this, or set local attributes then sync them all at once later. Dirty Attributes can be checked at any time to see which keys are not synced with the database.
void Start(){
Debug.Log(GameFuseUser.CurrentUser.attributes.Count); // Prints 0
Dictionary < string, string > attributesToUpdate = new Dictionary < string, string >
{
{ "POINTS", "1000" },
{ "LEVEL", "5" },
{ "CHARACTER", "Ninja" }
};
GameFuseUser.CurrentUser.SetAttributes(attributesToUpdate, SetAttributesCallback);
}
void SetAttributesCallback(string message, bool hasError) {
if (hasError)
{
Debug.Log("Error setting attribute: "+message);
}
else
{
Debug.Log("Batch update complete");
Debug.Log(GameFuseUser.CurrentUser.GetAttributeValue("POINTS")); // Prints "1000"
Debug.Log(GameFuseUser.CurrentUser.GetAttributeValue("LEVEL")); // Prints "5"
GameFuseUser.CurrentUser.SetAttributeLocal("POINTS", "2000"); //will set locally but not sync with db
GameFuseUser.CurrentUser.SetAttributeLocal("LEVEL", "6"); //will set locally but not sync with db
Debug.Log("Dirty Vars"); //will print variables changed locally
foreach (var attribute in GameFuseUser.CurrentUser.GetDirtyAttributes()){
Debug.Log(attribute.Key+": "+attribute.Value);
}
GameFuseUser.CurrentUser.SyncLocalAttributes(AttributesSynced); //will update "SCORE" + "LEVEL"
}
}
void AttributesSynced(string message, bool hasError){
if (hasError)
{
Debug.Log("Error syncing attributes: "+message);
}
else
{
Debug.Log("Sync Success");
Debug.Log("Dirty Vars"); //will be empty now that sync is done
foreach (var attribute in GameFuseUser.CurrentUser.GetDirtyAttributes()){
Debug.Log(attribute.Key+": "+attribute.Value);
}
}
}
* 400 - each attribute a 'key' and 'value' parameter
* 400 - missing or invalid parameters
* 500 - unknown server error
Custom user data or Key Value pairs are a simple way to save any kind of data for a particular user. Some examples might be {"world_2_unlocked":"true"}, {"player_color","red"}, {"favorite_food","Onion"} These will fetched to your system after calling 'FetchAttributes()'.
All values and keys must be strings. If you want to use other data structures like arrays, you could stringify the array on save, and convert the saved string to an array on load:
void UMyObject::FetchAttributes()
{
FUserCallback CompletionCallback;
CompletionCallback.BindDynamic(this, &UMyObject::OnAttributesFetchedCallback);
UGameFuseUser* GameFuseUser = GEtgaMeinstance()->getsubsysTEm < uGameFuseuser > ();
GameFuseUser->FetchAttributes(false, CompletionCallback);
}
void UMyObject::OnAttributesFetchedCallback(bool bSuccess, const FString& Response)
{
if(bSuccess)
{
UE_LOG(LogTemp, Display, TEXT("Game Connected Successfully"));
UE_LOG(LogTemp, Display, TEXT("Result : %s"), *Response);
UGameFuseUser* GameFuseUser = GEtgaMeinstance()->getsubsysTEm < uGameFuseuser > ();
TMap Attributes = GameFuseUser->GetAttributes();
}else
{
UE_LOG(LogTemp, Error, TEXT("Error connecting game"));
UE_LOG(LogTemp, Error, TEXT("Result : %s"), *Response);
}
}
void UMyObject::AddAttributes()
{
FUserCallback CompletionCallback;
CompletionCallback.BindDynamic(this, &UMyObject::OnAttributesFetchedCallback);
UGameFuseUser* GameFuseUser = GEtgaMeinstance()->getsubsysTEm < uGameFuseuser > ();
GameFuseUser->SetAttribute("CURRENT_LEVEL", "5", CompletionCallback);
}
void UMyObject::OnAttributesAddedCallback(bool bSuccess, const FString& Response)
{
if(bSuccess)
{
UE_LOG(LogTemp, Display, TEXT("Game Connected Successfully"));
UE_LOG(LogTemp, Display, TEXT("Result : %s"), *Response);
}else
{
UE_LOG(LogTemp, Error, TEXT("Error connecting game"));
UE_LOG(LogTemp, Error, TEXT("Result : %s"), *Response);
}
}
* 400 - each attribute a 'key' and 'value' parameter
* 400 - missing or invalid parameters
* 500 - unknown server error
Custom user data or Key Value pairs are a simple way to save any kind of data for a particular user. Some examples might be {"world_2_unlocked":"true"}, {"player_color","red"}, {"favorite_food","Onion"}. These are downloaded to your system upon login, and synced when one is updated. You can access with Get Attributes node like this:
All values and keys must be strings. If you want to use other data structures like arrays, you could stringify the array on save, and convert the saved string to an array on load:
Custom user data or Key Value pairs are a simple way to save any kind of data for a particular user. Some examples might be {"world_2_unlocked":"true"}, {"player_color","red"}, {"favorite_food","Onion"} These are downloaded to your system upon login, and synced when one is updated. You can access with GameFuseUser.CurrentUser.attributes
All values and keys must be strings. If you want to use other data structures like arrays, you could stringify the array on save, and convert the saved string to an array on load.Start(){
let self = this;
console.log(GameFuseUser.CurrentUser.attributes.length); // Prints 0
console.log(GameFuseUser.CurrentUser.GetAttributeValue("CURRENT_LEVEL") == null); // Prints true
GameFuseUser.CurrentUser.SetAttribute("CURRENT_LEVEL", "5", function(message,hasError){self.SetAttributeCallback(message,hasError)});
}
SetAttributeCallback(message, hasError) {
if (hasError)
{
console.log("Error setting attribute: "+message);
}
else
{
console.log(GameFuseUser.CurrentUser.GetAttributeValue("CURRENT_LEVEL")); // Prints "5"
}
}
ou can also batch update a custom dictionary of key value pairs like this, or set local attributes then sync them all at once later. Dirty Attributes can be checked at any time to see which keys are not synced with the database.
Start(){
console.log(GameFuseUser.CurrentUser.attributes.Count); // Prints 0
attributesToUpdate = {{ "POINTS": "1000" },{ "LEVEL": "5" },{ "CHARACTER": "Ninja" }};
GameFuseUser.CurrentUser.setAttributes(attributesToUpdate, function(message,hasError){self.setAttributesCallback(message,hasError)});
}
setAttributesCallback(message, hasError) {
if (hasError)
{
console.log("Error setting attribute: "+message);
}
else
{
console.log("Batch update complete");
console.log(GameFuseUser.CurrentUser.getAttributeValue("POINTS")); // Prints "1000"
console.log(GameFuseUser.CurrentUser.getAttributeValue("LEVEL")); // Prints "5"
GameFuseUser.CurrentUser.setAttributeLocal("POINTS", "2000"); //will set locally but not sync with db
GameFuseUser.CurrentUser.setAttributeLocal("LEVEL", "6"); //will set locally but not sync with db
console.log("Dirty Vars"); //will print variables changed locally
console.log(GameFuseUser.CurrentUser.getDirtyAttributes());
GameFuseUser.CurrentUser.syncLocalAttributes(function(message,hasError){self.attributesSynced(message,hasError)}); //will update "SCORE" + "LEVEL"
}
}
attributesSynced(message, hasError){
if (hasError)
{
console.log("Error syncing attributes: "+message);
}
else
{
console.log("Sync Success");
console.log("Dirty Vars"); //will be empty now that sync is done
console.log(GameFuseUser.CurrentUser.getDirtyAttributes());
}
}
* 400 - each attribute a 'key' and 'value' parameter
* 400 - missing or invalid parameters
* 500 - unknown server error
User data can be set in a number of ways. Score can be set with a specific API call to set or relativly add to score. You can also set custom user data where you can assign any key to any value. Whether you use it for a players "current_level", "color", "XP" or anything else you can think of, it can be done with the custom data.
To alter the amount of scores a users has relativly, use:
https://gamefuse.co/api/v2/users/{signed in user id}/add_scores?&scores={scores to add}
It will have the following Headers:
authentication_token: {found in sign_in or sign_up response, authentication token for user session}
It will have the following URL parameters:
scores: {the amount of scores positive or negative you want to alter the users current scores by}
This will return a response with the following json. It has users remaining scores, and a list of all their purchased store items
{
"id": {users id},
"username": {users display username},
"email": {system email - a combination of game id and email},
"display_email": {users actual email, used for notifications and login}
"credits": {number of credits user has, these can be used in your in game store},
"score": {a generic score metric that you can use},
"last_login": {timestamp of last login},
"number_of_logins": {total logins},
"authentication_token": {authentication token, this must be saved and added as a parameter to all authenticated requests},
"events_total": {running api hits for this user},
"events_current_month": {running api hits for this user for this month},
"game_sessions_total": {unique game session for this user},
"game_sessions_current_month": {unique game session for this user for this month}
}
* 400 - Please include a score param
* 500 - unknown server error
To set the amount of scores a users has absolutly, meaning the scores param will be the users new scores total, use:
https://gamefuse.co/api/v2/users/{signed in user id}/set_scores?&scores={scores to add}
It will have the following Headers:
authentication_token: {found in sign_in or sign_up response, authentication token for user session}
It will have the following URL parameters:
scores: {the amount of scores a user will now have}
This will return a response with the following json:
{
"id": {users id},
"username": {users display username},
"email": {system email - a combination of game id and email},
"display_email": {users actual email, used for notifications and login}
"credits": {number of credits user has, these can be used in your in game store},
"score": {a generic score metric that you can use},
"last_login": {timestamp of last login},
"number_of_logins": {total logins},
"authentication_token": {authentication token, this must be saved and added as a parameter to all authenticated requests},
"events_total": {running api hits for this user},
"events_current_month": {running api hits for this user for this month},
"game_sessions_total": {unique game session for this user},
"game_sessions_current_month": {unique game session for this user for this month}
}
* 400 - Please include a score param
* 500 - unknown server error
Set any key to any value. It will be in a string format but can be converted in your programs language to any type.
https://gamefuse.co/api/v2/users/{signed in user id}/add_game_user_attribute?&key={key to add}&value={value to add}&attributes={json of attributes defined below}
It will have the following Headers:
authentication_token: {found in sign_in or sign_up response, authentication token for user session}
It will have the following URL parameters:
key: {the key of the datum you are trying to save}
value: {the value of the datum you are trying to save}
attributes: {json of the format [{"key": key1, "value": value1}, {"key": key2, "value":value2}...] for batch updating }
This will return a response containing all the users attributes (custom data) with the following json:
{
"game_user_attributes": [
{
"id": {id of first attribute},
"key": {key of first attribute},
"value": {value of first attribute}
},
{
"id": {id of second attribute},
"key": {key of second attribute},
"value": {value of second attribute}
},
...
]
}
* 400 - each attribute a 'key' and 'value' parameter
* 400 - missing or invalid parameters
* 500 - unknown server error
remove any key and its value
https://gamefuse.co/api/v2/users/{signed in user id}/remove_game_user_attributes?&key={key to add}
It will have the following Headers:
authentication_token: {found in sign_in or sign_up response, authentication token for user session}
It will have the following URL parameters:
key: {the key of the datum you are trying to remove}
This will return a response containing all the users attributes (custom data) with the following json:
{
"game_user_attributes": [
{
"id": {id of first attribute},
"key": {key of first attribute},
"value": {value of first attribute}
},
{
"id": {id of second attribute},
"key": {key of second attribute},
"value": {value of second attribute}
},
...
]
}
* 400 - User does not have item with specified key
* 500 - unknown server error
Get a list of all the signed in users custom attributes
https://gamefuse.co/api/v2/users/{signed in user id}/game_user_attributes?
It will have the following Headers:
authentication_token: {found in sign_in or sign_up response, authentication token for user session}
This will return a response containing all the users attributes (custom data) with the following json:
{
"game_user_attributes": [
{
"id": {id of first attribute},
"key": {key of first attribute},
"value": {value of first attribute}
},
{
"id": {id of second attribute},
"key": {key of second attribute},
"value": {value of second attribute}
},
...
]
}
* 500 - unknown server error
Leaderboards can be easily created within GameFuse From the Unity game client, a Leaderboard Entry can be added with a leaderboard_name, score, and extra_attributes (metadata) for the current signed in user Leaderboards can be downloaded for a specific leaderboard_name, which would gather all the high scores in order for all users in the game or Leaderboards can be downloaded for a specific user, so that you can download the current users leaderboard data for all leaderboard_names. The below example shows submitting 2 leaderboard entries, then retrieving them for the game, and for the current user
void Start(){
var extraAttributes = new Dictionary < string, string > ();
extraAttributes.Add("deaths", "15");
extraAttributes.Add("Jewels", "12");
GameFuseUser.CurrentUser.AddLeaderboardEntry("Game1Leaderboard",10, extraAttributes, LeaderboardEntryAdded);
}
void LeaderboardEntryAdded(string message, bool hasError)
{
if (hasError)
{
print("Error adding leaderboard entry: " + message);
}
else
{
print("Set Leaderboard Entry 2");
var extraAttributes = new Dictionary < string, string > ();
extraAttributes.Add("deaths", "25");
extraAttributes.Add("Jewels", "15");
GameFuseUser.CurrentUser.AddLeaderboardEntry("Game1Leaderboard", 7, extraAttributes, LeaderboardEntryAdded2);
}
}
void LeaderboardEntryAdded2(string message, bool hasError)
{
if (hasError)
{
print("Error adding leaderboard entry 2: " + message);
}
else
{
print("Set Leaderboard Entry 2");
GameFuseUser.CurrentUser.GetLeaderboard(5, true, LeaderboardEntriesRetrieved);
}
}
void LeaderboardEntriesRetrieved(string message, bool hasError)
{
if (hasError)
{
print("Error loading leaderboard entries: " + message);
}
else
{
print("Got leaderboard entries for specific user!");
foreach( GameFuseLeaderboardEntry entry in GameFuse.Instance.leaderboardEntries)
{
print(entry.GetUsername() + ": " + entry.GetScore().ToString() + ": " + entry.GetLeaderboardName() );
foreach (KeyValuePair < string,string > kvPair in entry.GetExtraAttributes())
{
print(kvPair.Key + ": " + kvPair.Value);
}
}
GameFuse.Instance.GetLeaderboard(5, true, "Game1Leaderboard", LeaderboardEntriesRetrievedAll);
}
}
void LeaderboardEntriesRetrievedAll(string message, bool hasError)
{
if (hasError)
{
print("Error loading leaderboard entries: " + message);
}
else
{
print("Got leaderboard entries for whole game!");
foreach (GameFuseLeaderboardEntry entry in GameFuse.Instance.leaderboardEntries)
{
print(entry.GetUsername() + ": " + entry.GetScore().ToString() + ": " + entry.GetLeaderboardName());
foreach (KeyValuePair < string, string > kvPair in entry.GetExtraAttributes())
{
print(kvPair.Key + ": " + kvPair.Value);
}
}
}
}
You can also clear all leaderboard entries for a particular leaderboard_name for the current user like this:
void Start(){
var extraAttributes = new Dictionary < string, string > ();
extraAttributes.Add("deaths", "15");
extraAttributes.Add("Jewels", "12");
GameFuseUser.CurrentUser.AddLeaderboardEntry("Game2Leaderboard",10, extraAttributes, LeaderboardEntryAdded);
}
void LeaderboardEntryAdded(string message, bool hasError)
{
if (hasError)
{
print("Error adding leaderboard entry: " + message);
}
else
{
print("Clear Leaderboard Entry 2");
GameFuseUser.CurrentUser.ClearLeaderboardEntries("Game2Leaderboard", LeaderboardEntryCleared);
}
}
void LeaderboardEntryCleared(string message, bool hasError)
{
if (hasError)
{
print("Error adding leaderboard entry: " + message);
}
else
{
print("User will no longer have leaderboard entries for 'Game2Leaderboard'");
}
}
# GameFuseUser.CurrentUser.AddLeaderboardEntry
* 401 - "can only add entries for current user"
* 400 - "invalid extra attributes"
* 500 - unknown server error
# GameFuseUser.CurrentUser.GetLeaderboard
* 401 - "can only get entries for current user"
* 500 - unknown server error
# GameFuse.Instance.GetLeaderboard
* 404 - No entries for this leaderboard name ___
* 500 - unknown server error
# GameFuseUser.CurrentUser.ClearLeaderboardEntries
* 401 - "can only clear entries for current user"
* 500 - unknown server error
Leaderboards can be easily created within GameFuse From the Unreal Engine game client, a Leaderboard Entry can be added with a leaderboard_name, score, and extra_attributes (metadata) for the current signed in user Leaderboards can be downloaded for a specific leaderboard_name, which would gather all the high scores in order for all users in the game or Leaderboards can be downloaded for a specific user, so that you can download the current users leaderboard data for all leaderboard_names. The below example shows submitting 2 leaderboard entries, then retrieving them for the game, and for the current user
void UMyObject::AddLeaderboard()
{
FUserCallback CompletionCallback;
CompletionCallback.BindDynamic(this, &UMyObject::OnAttributesFetchedCallback);
UGameFuseUser* GameFuseUser = GEtgaMeinstance()->getsubsysTEm < uGameFuseuser > ();
TMap < FString, FString > ExtraAttributes;
ExtraAttributes.Add("deaths","15");
ExtraAttributes.Add("Jewels","12");
GameFuseUser->AddLeaderboardEntryWithAttributes("leaderboard_name", GameFuseUser->GetScore(), ExtraAttributes, CompletionCallback);
// Adding Leaderboard without extra attributes
//GameFuseUser->AddLeaderboardEntry("leaderboard_name", GameFuseUser->GetScore(), CompletionCallback);
}
void UMyObject::OnLeaderboardAddedCallback(bool bSuccess, const FString& Response)
{
if(bSuccess)
{
UE_LOG(LogTemp, Display, TEXT("Game Connected Successfully"));
UE_LOG(LogTemp, Display, TEXT("Result : %s"), *Response);
}else
{
UE_LOG(LogTemp, Error, TEXT("Error connecting game"));
UE_LOG(LogTemp, Error, TEXT("Result : %s"), *Response);
}
}
void UMyObject::GetMyLeaderboards()
{
FUserCallback CompletionCallback;
CompletionCallback.BindDynamic(this, &UMyObject::OnMyLeaderboardsFetchedCallback);
UGameFuseUser* GameFuseUser = GEtgaMeinstance()->getsubsysTEm < uGameFuseuser > ();
GameFuseUser->FetchMyLeaderboardEntries(12, false, CompletionCallback);
}
void UMyObject::OnMyLeaderboardsFetchedCallback(bool bSuccess, const FString& Response)
{
if(bSuccess)
{
UE_LOG(LogTemp, Display, TEXT("Game Connected Successfully"));
UE_LOG(LogTemp, Display, TEXT("Result : %s"), *Response);
UGameFuseUser* GameFuseUser = GEtgaMeinstance()->getsubsysTEm < uGameFuseuser > ();
TArray < UGameFuseLeaderboardEntry* > MyLeaderboards = GameFuseUser->GetLeaderboards();
}else
{
UE_LOG(LogTemp, Error, TEXT("Error connecting game"));
UE_LOG(LogTemp, Error, TEXT("Result : %s"), *Response);
}
}
void UMyObject::GetLeaderboards()
{
FManagerCallback CompletionCallback;
CompletionCallback.BindDynamic(this, &UMyObject::OnLeaderboardsFetchedCallback);
UGameFuseUser* GameFuseUser = GEtgaMeinstance()->getsubsysTEm < uGameFuseuser > ();
UGameFuseManager::FetchLeaderboardEntries(GameFuseUser, 15, false, "leaderboard_name", CompletionCallback);
}
void UMyObject::OnLeaderboardsFetchedCallback(bool bSuccess, const FString& Response)
{
if(bSuccess)
{
UE_LOG(LogTemp, Display, TEXT("Game Connected Successfully"));
UE_LOG(LogTemp, Display, TEXT("Result : %s"), *Response);
TArray < UGameFuseLeaderboardEntry* > Leaderboards = UGameFuseManager::GetLeaderboard();
}else
{
UE_LOG(LogTemp, Error, TEXT("Error connecting game"));
UE_LOG(LogTemp, Error, TEXT("Result : %s"), *Response);
}
}
You can also clear all leaderboard entries for a particular leaderboard_name for the current user like this:
void UMyObject::ClearMyLeaderboards()
{
FUserCallback CompletionCallback;
CompletionCallback.BindDynamic(this, &UMyObject::OnMyLeaderboardsClearedCallback);
UGameFuseUser* GameFuseUser = GEtgaMeinstance()->getsubsysTEm < uGameFuseuser > ();
GameFuseUser->ClearLeaderboardEntry("leaderboard_name", CompletionCallback);
}
void UMyObject::OnMyLeaderboardsClearedCallback(bool bSuccess, const FString& Response)
{
if(bSuccess)
{
UE_LOG(LogTemp, Display, TEXT("Game Connected Successfully"));
UE_LOG(LogTemp, Display, TEXT("Result : %s"), *Response);
}else
{
UE_LOG(LogTemp, Error, TEXT("Error connecting game"));
UE_LOG(LogTemp, Error, TEXT("Result : %s"), *Response);
}
}
# GameFuseUser->AddLeaderboardEntryWithAttributes
* 401 - "can only add entries for current user"
* 400 - "invalid extra attributes"
* 500 - unknown server error
# GameFuseUser->GetLeaderboards
* 401 - "can only get entries for current user"
* 500 - unknown server error
# UGameFuseManager::GetLeaderboard
* 404 - No entries for this leaderboard name ___
* 500 - unknown server error
# GameFuseUser->ClearLeaderboardEntry
* 401 - "can only clear entries for current user"
* 500 - unknown server error
Leaderboards can be easily created within GameFuse. From the Unreal Engine game client, you can use the "Add Leaderboard Entry" node to add a score to a leaderboard with a specified name. Alternatively, you can utilize the "Add Leaderboard Entry With Attributes" node to add a score, along with extra attributes (metadata), to a leaderboard with a specific name.
Leaderboards can be fetched in two ways: for a specific "Your Leaderboard Name," which gathers all the high scores for all users in the game, or for a specific user. In the latter case, you can download the current user's leaderboard data for all instances of "Your Leaderboard Name."
You can also clear all leaderboard entries for a particular "Your Leaderboard Name" for the current user like this:
Leaderboards can be easily created within GameFuse From any JS game client, a Leaderboard Entry can be added with a leaderboard_name, score, and extra_attributes (metadata) for the current signed in user Leaderboards can be downloaded for a specific leaderboard_name, which would gather all the high scores in order for all users in the game or Leaderboards can be downloaded for a specific user, so that you can download the current users leaderboard data for all leaderboard_names The below example shows submitting 2 leaderboard entries, then retrieving them for the game, and for the current user
Start(){
let self = this
var extraAttributes = {};
extraAttributes["deaths"] = "15";
extraAttributes["Jewels"] = "12";
GameFuseUser.CurrentUser.AddLeaderboardEntry("Game1Leaderboard",10, extraAttributes, function(message,hasError){self.LeaderboardEntryAdded(message,hasError)});
}
LeaderboardEntryAdded(message, hasError)
{
let self = this;
if (hasError)
{
print("Error adding leaderboard entry: " + message);
}
else
{
print("Set Leaderboard Entry 2");
var extraAttributes = {};
extraAttributes.["deaths"] = "25";
extraAttributes.["Jewels"] = "15";
GameFuseUser.CurrentUser.AddLeaderboardEntry("Game1Leaderboard", 7, extraAttributes, function(message,hasError){self.LeaderboardEntryAdded2(message,hasError)});
}
}
LeaderboardEntryAdded2(message, hasError)
{
let self = this;
if (hasError)
{
print("Error adding leaderboard entry 2: " + message);
}
else
{
print("Set Leaderboard Entry 2");
GameFuseUser.CurrentUser.GetLeaderboard(5, true, function(message,hasError){self.LeaderboardEntriesRetrieved(message,hasError)});
}
}
LeaderboardEntriesRetrieved(message, hasError)
{
if (hasError)
{
print("Error loading leaderboard entries: " + message);
}
else
{
let self = this;
print("Got leaderboard entries for specific user!");
for (const entry of GameFuse.Instance.leaderboardEntries) {
console.log(entry.getUsername() + ": " + entry.getScore().toString() + ": " + entry.getLeaderboardName());
const extraAttributes = entry.getExtraAttributes();
for (const key in extraAttributes) {
console.log(key + ": " + extraAttributes[key]);
}
}
GameFuse.Instance.GetLeaderboard(5, true, "Game1Leaderboard", function(message,hasError){self.LeaderboardEntriesRetrievedAll(message,hasError)});
}
}
LeaderboardEntriesRetrievedAll(message, hasError)
{
if (hasError)
{
print("Error loading leaderboard entries: " + message);
}
else
{
let self = this;
print("Got leaderboard entries for whole game!");
for (const entry of GameFuse.Instance.leaderboardEntries) {
console.log(entry.getUsername() + ": " + entry.getScore().toString() + ": " + entry.getLeaderboardName());
const extraAttributes = entry.getExtraAttributes();
for (const key in extraAttributes) {
console.log(key + ": " + extraAttributes[key]);
}
}
}
}
You can also clear all leaderboard entries for a particular leaderboard_name for the current user like this:
Start(){
let self = this;
var extraAttributes = {};
extraAttributes["deaths"] = "15";
extraAttributes["Jewels"] = "12";
GameFuseUser.CurrentUser.AddLeaderboardEntry("Game2Leaderboard",10, extraAttributes, function(message,hasError){self.LeaderboardEntryAdded(message,hasError)});
}
LeaderboardEntryAdded(message, hasError)
{
let self = this;
if (hasError)
{
print("Error adding leaderboard entry: " + message);
}
else
{
print("Clear Leaderboard Entry 2");
GameFuseUser.CurrentUser.ClearLeaderboardEntries("Game2Leaderboard", function(message,hasError){self.LeaderboardEntryCleared(message,hasError)});
}
}
LeaderboardEntryCleared(message, hasError)
{
if (hasError)
{
print("Error adding leaderboard entry: " + message);
}
else
{
print("User will no longer have leaderboard entries for 'Game2Leaderboard'");
}
}
# GameFuseUser.CurrentUser.AddLeaderboardEntry
* 401 - "can only add entries for current user"
* 400 - "invalid extra attributes"
* 500 - unknown server error
# GameFuseUser.CurrentUser.GetLeaderboard
* 401 - "can only get entries for current user"
* 500 - unknown server error
# GameFuse.Instance.GetLeaderboard
* 404 - No entries for this leaderboard name ___
* 500 - unknown server error
# GameFuseUser.CurrentUser.ClearLeaderboardEntries
* 401 - "can only clear entries for current user"
* 500 - unknown server error
TLeaderboards can be easily created within GameFuse From your JS game client, a Leaderboard Entry can be added with a leaderboard_name, score, and extra_attributes (metadata) for the current signed in user Leaderboards can be downloaded for a specific leaderboard_name, which would gather all the high scores in order for all users in the game or Leaderboards can be downloaded for a specific user, so that you can download the current users leaderboard data for all leaderboard_names
Add a leaderboard entry to a specific leaderboard within your game designated by 'leaderboard_name', these can be pulled later and compared to other users.
https://gamefuse.co/api/v2/users/{user id}/add_leaderboard_entry?score={score for the leaderboard}&leaderboard_name={leaderboard name}&extra_attributes={hash of extra data to save to the leaderboard entry}
It will have the following URL parameters:
score: {score for the leaderboard}
leaderboard_name: {leaderboard name within game}
extra_attributes: {hash of custom data}
This will return a response containing all the users attributes (custom data) with the following json:
{
"id": {users id},
"username": {users display username},
"email": {system email - a combination of game id and email},
"display_email": {users actual email, used for notifications and login}
"credits": {number of credits user has, these can be used in your in game store},
"score": {a generic score metric that you can use},
"last_login": {timestamp of last login},
"number_of_logins": {total logins},
"authentication_token": {authentication token, this must be saved and added as a parameter to all authenticated requests},
"events_total": {running api hits for this user},
"events_current_month": {running api hits for this user for this month},
"game_sessions_total": {unique game session for this user},
"game_sessions_current_month": {unique game session for this user for this month}
}
* 401 - "can only add entries for current user"
* 400 - "invalid extra attributes"
* 500 - unknown server error
Clear all leaderboard entries for a specific user.
https://gamefuse.co/api/v2/users/{user id}/clear_my_leaderboard_entries?
It will have the following Headers:
authentication_token: {found in sign_in or sign_up response, authentication token for user session}
This will return a response containing all the users attributes (custom data) with the following json:
{
"id": {users id},
"username": {users display username},
"email": {system email - a combination of game id and email},
"display_email": {users actual email, used for notifications and login}
"credits": {number of credits user has, these can be used in your in game store},
"score": {a generic score metric that you can use},
"last_login": {timestamp of last login},
"number_of_logins": {total logins},
"authentication_token": {authentication token, this must be saved and added as a parameter to all authenticated requests},
"events_total": {running api hits for this user},
"events_current_month": {running api hits for this user for this month},
"game_sessions_total": {unique game session for this user},
"game_sessions_current_month": {unique game session for this user for this month}
}
* 401 - "can only clear entries for current user"
* 500 - unknown server error
Get all leaderboard entries for a specific leaderboard name. You may have multiple leaderboards in your game, indicated by "leaderboard name"
https://gamefuse.co/api/v2/games/1/leaderboard_entries?leaderboard_name={leaderboard name}
It will have the following Headers:
authentication_token: {found in sign_in or sign_up response, authentication token for user session}
It will have the following URL parameters:
leaderboard_name: {name of the leaderboard within the game}
This will return a response containing all the users attributes (custom data) with the following json:
{
"leaderboard_entries": [
{
"username": value,
"score": value,
"leaderboard_name": value,
"game_user_id": value,
"extra_attributes": value,
},
{
"username": value,
"score": value,
"leaderboard_name": value,
"game_user_id": value,
"extra_attributes": value
},
...
]
}
* 404 - No entries for this leaderboard name ___
* 500 - unknown server error
Get all leaderboard entries for a specific user.
https://gamefuse.co/api/v2/users/{user id}/leaderboard_entries?
It will have the following Headers:
authentication_token: {found in sign_in or sign_up response, authentication token for user session}
This will return a response containing all the users attributes (custom data) with the following json:
{
"leaderboard_entries": [
{
"username": value,
"score": value,
"leaderboard_name": value,
"game_user_id": value,
"extra_attributes": value
},
{
"username": value,
"score": value,
"leaderboard_name": value,
"game_user_id": value,
"extra_attributes": value
},
...
]
}
* 401 - "can only get entries for current user"
* 500 - unknown server hasError
You can implement this simple method in your app and we will handle all the emails and password reset on our end. Once you hit this function, our system will send an email to that user if they exist, branded like your app. It will have your app's name, image logo and color so it will look cohesive. The sender email is even masked with your apps name. The user will reset their password online and then will be instructed that they can login to your app.
void Start(){
GameFuseUser.Instance.SendPasswordResetEmail("example@gmail.com", ForgotPasswordEmailSent);
}
void ForgotPasswordEmailSent(string message, bool hasError) {
if (hasError)
{
Debug.Log("Error setting attribute: "+message);
}
else
{
Debug.Log(GameFuseUser.CurrentUser.GetAttributeValue("CURRENT_LEVEL")); // Prints "5"
}
}
* 404 - Game ID or Token incorrect
* 403 - Invalid Email Address
* 404 - No user found with email
* 500 - unknown server error
The user will then recieve an email looking like the following:
When the user clicks on the forgot password link they will see something like:
You can implement this simple method in your app and we will handle all the emails and password reset on our end. Once you hit this function, our system will send an email to that user if they exist, branded like your app. It will have your app's name, image logo and color so it will look cohesive. The sender email is even masked with your apps name. The user will reset their password online and then will be instructed that they can login to your app.
void UMyObject::ResetUserPassword()
{
FManagerCallback CompletionCallback;
CompletionCallback.BindDynamic(this, &UMyObject::OnMyLeaderboardsClearedCallback);
UGameFuseManager::SendPasswordResetEmail("example@gmail.com", CompletionCallback);
}
void UMyObject::OnResetUserPasswordCallback(bool bSuccess, const FString& Response)
{
if(bSuccess)
{
UE_LOG(LogTemp, Display, TEXT("Game Connected Successfully"));
UE_LOG(LogTemp, Display, TEXT("Result : %s"), *Response);
}else
{
UE_LOG(LogTemp, Error, TEXT("Error connecting game"));
UE_LOG(LogTemp, Error, TEXT("Result : %s"), *Response);
}
}
* 404 - Game ID or Token incorrect
* 403 - Invalid Email Address
* 404 - No user found with email
* 500 - unknown server error
The user will then recieve an email looking like the following:
When the user clicks on the forgot password link they will see something like:
You can implement this simple method in your app, and we will handle all the emails and password reset on our end. Once you hit this node, our system will send an email to that user if they exist, branded like your app. It will have your app's name, image logo, and color so it will look cohesive. The sender email is even masked with your app's name. The user will reset their password online and then will be instructed that they can log in to your app.
The user will then receive an email looking like the following:
When the user clicks on the forgot password link, they will see something like:
You can implement this simple method in your app and we will handle all the emails and password reset on our end. Once you hit this function, our system will send an email to that user if they exist, branded like your app. It will have your app's name, image logo and color so it will look cohesive. The sender email is even masked with your apps name. The user will reset their password online and then will be instructed that they can login to your app.
Start(){
let self = this;
GameFuse.sendPasswordResetEmail("example@gmail.com, function (message, hasError) {
if (hasError) {
alert("Something went wrong...");
}
else {
alert("A link to reset your password has been sent to your email!");
}
});
}
* 404 - Game ID or Token incorrect
* 403 - Invalid Email Address
* 404 - No user found with email
* 500 - unknown server error
The user will then recieve an email looking like the following:
When the user clicks on the forgot password link they will see something like:
You can implement this simple method in your app and we will handle all the emails and password reset on our end. Once you hit this function, our system will send an email to that user if they exist, branded like your app. It will have your app's name, image logo and color so it will look cohesive. The sender email is even masked with your apps name. The user will reset their password online and then will be instructed that they can login to your app.
https://gamefuse.co/api/v1/games/{game_id}/forget_password?email={email}&game_id={game_id}&game_token={game_token}
It will have the following URL parameters:
game_id: {found on your GameFuse.co dashboard}
game_token: {API token found on your GameFuse.co dashboard}
email: {email address of user to send forgot password form to}
This will return a response containing all the users attributes (custom data) with the following json:
{
"mailer_response": {detail of the emailer},
"message": {message confirming email sent or with info that user does not exist}
}
* 404 - Game ID or Token incorrect
* 403 - Invalid Email Address
* 404 - No user found with email
* 500 - unknown server error
The user will then recieve an email looking like the following:
When the user clicks on the forgot password link they will see something like:
Check each model below for a list of methods and attributes.
###GameFuse.cs
your current signed in user can be retrieved with:
GameFuseUser user = GameFuse.CurrentUser;
public bool IsSignedIn();
public int GetNumberOfLogins();
public DateTime GetLastLogin();
public string GetUsername();
public int GetScore();
public int GetCredits();
public void AddCredits(int credits, Action < string, bool > callback = null);
public void SetCredits(int credits, Action < string, bool > callback = null);
public void AddScore(int credits, Action < string, bool > callback = null);
public void SetScore(int score, Action < string, bool > callback = null);
public Dictionary < string,string > GetAttributes();
public Dictionary < string,string > .KeyCollection GetAttributesKeys();
public string GetAttributeValue(string key);
public void SetAttribute(string key, string value, Action < string, bool > callback = null);
public void SetAttributeLocal(string key, string val);
public void SyncLocalAttributes(Action callback = null);
public void SetAttributes(Dictionary newAttributes, Action callback = null);
public Dictionary GetDirtyAttributes();
public void RemoveAttribute(string key, Action < string, bool > callback = null);
public List < GameFuseStoreItem > GetPurchasedStoreItems();
public void PurchaseStoreItem(GameFuseStoreItem storeItem, Action < string, bool > callback = null);
public void PurchaseStoreItem(int storeItemId, Action < string, bool > callback = null);
public void RemoveStoreItem(int storeItemID, bool reimburseUser, Action < string, bool > callback = null);
public void RemoveStoreItem(GameFuseStoreItem storeItem, bool reimburseUser, Action < string, bool > callback = null);
public void AddLeaderboardEntry(string leaderboardName, int score, Dictionary extraAttributes = null, Action < string, bool > callback = null);
public void AddLeaderboardEntry(string leaderboardName, int score, Action < string, bool > callback = null);
public void GetLeaderboard(int limit, bool onePerUser, Action < string, bool > callback = null); //Get all leaderboard entries for current signed in user
###GameFuse.cs
public static void SetUpGame(string gameId, string token, Action < string, bool > callback = null);
public static string GetGameId();
public static string GetGameName();
public static string GetGameDescription();
public static List < GameFuseStoreItem > GetStoreItems() //Gets all store items (your library)
public static void SignIn(string email, string password, Action < string, bool > callback = null);
public static void SignUp(string email, string password, string password_confirmation, string username, Action < string, bool > callback = null);
public void GetLeaderboard(int limit, bool onePerUser, string LeaderboardName, Action < string, bool > callback = null); //Retrieves leaderboard for one specific Leaderboard Name
public static void SendPasswordResetEmail(string email, Action < string, bool > callback = null);
public static void FetchGameVariables(string gameId, string token, Action < string, bool > callback = null)
public static string GetGameVariable(string key)
###GameFuseStoreItem.cs
public string GetName();
public string GetCategory();
public string GetDescription();
public int GetCost();
public int GetId();
public string GetIconUrl();
###GameFuseLeaderboardEntry.cs
public string GetUsername();
public int GetScore();
public string GetLeaderboardName();
public Dictionary GetExtraAttributes();
public DateTime GetTimestamp();
Check each model below for a list of methods and attributes.
// GameFuse Static Functions
UGameFuseManager::SetUpGame(const FString& InGameId, const FString& InToken, bool bSeedStore, FManagerCallback CompletionCallback);
UGameFuseManager::GetGameId();
UGameFuseManager::GetGameName();
UGameFuseManager::GetGameDescription();
UGameFuseManager::GetGameToken();
UGameFuseManager::GetBaseURL();
UGameFuseManager::GetGameVariables();
UGameFuseManager::GetGameStoreItems();
UGameFuseManager::GetLeaderboard();
UGameFuseManager::(const FString& Email, FManagerCallback CompletionCallback);
UGameFuseManager::FetchGameVariables(FManagerCallback CompletionCallback);
UGameFuseManager::FetchLeaderboardEntries(UGameFuseUser* GameFuseUser, const int Limit, bool bOnePerUser, const FString& LeaderboardName, FManagerCallback CompletionCallback);
UGameFuseManager::FetchStoreItems(FManagerCallback CompletionCallback);
// User Functions
UGameFuseUser* GameFuseUser = GEtgaMeinstance()->getsubsysTEm < uGameFuseuser > ();
GameFuseUser->GetNumberOfLogins();
GameFuseUser->GetLastLogin();
GameFuseUser->GetUsername();
GameFuseUser->GetScore();
GameFuseUser->GetCredits();
GameFuseUser->GetAttributes();
GameFuseUser->GetAttributesKeys();
GameFuseUser->GetAttributeValue(const FString Key);
GameFuseUser->GetPurchasedStoreItems();
GameFuseUser->GetLeaderboards();
GameFuseUser->SignUp(const FString& Email, const FString& Password, const FString& PasswordConfirmation, const FString& Username, FUserCallback CompletionCallback);
GameFuseUser->SignIn(const FString& Email, const FString& Password, FUserCallback CompletionCallback);
GameFuseUser->IsSignedIn() const;
GameFuseUser->AddCredits(const int AddCredits, FUserCallback CompletionCallback);
GameFuseUser->SetCredits(const int SetCredits, FUserCallback CompletionCallback);
GameFuseUser->AddScore(const int AddScore, FUserCallback CompletionCallback);
GameFuseUser->SetScore(const int SetScore, FUserCallback CompletionCallback);
GameFuseUser->SetAttribute(const FString& SetKey,const FString& SetValue, FUserCallback CompletionCallback);
GameFuseUser->RemoveAttribute(const FString& SetKey, FUserCallback CompletionCallback);
GameFuseUser->PurchaseStoreItemWithId(const int StoreItemId, FUserCallback CompletionCallback);
GameFuseUser->PurchaseStoreItem(const UGameFuseStoreItem* StoreItem, FUserCallback CompletionCallback);
GameFuseUser->RemoveStoreItemWithId(const int StoreItemId, FUserCallback CompletionCallback);
GameFuseUser->RemoveStoreItem(const UGameFuseStoreItem* StoreItem, FUserCallback CompletionCallback);
GameFuseUser->void AddLeaderboardEntry(const FString& LeaderboardName,const int OurScore, FUserCallback CompletionCallback);
GameFuseUser->AddLeaderboardEntryWithAttributes(const FString& LeaderboardName, const int OurScore, TMap ExtraAttributes, FUserCallback
CompletionCallback);
GameFuseUser->ClearLeaderboardEntry(const FString& LeaderboardName, FUserCallback CompletionCallback);
GameFuseUser->FetchMyLeaderboardEntries(const int Limit, bool bOnePerUser, FUserCallback CompletionCallback);
GameFuseUser->FetchAttributes(bool bChainedFromLogin, FUserCallback CompletionCallback);
GameFuseUser->FetchPurchaseStoreItems(bool bChainedFromLogin, FUserCallback CompletionCallback);
// GameFuseStoreItem.h
TArray < UGameFuseStoreItem* > StoreItems = GameFuseUser->GetPurchasedStoreItems();
StoreItems->GetName();
StoreItems->GetCategory();
StoreItems->GetDescription();
StoreItems->GetCost();
StoreItems->GetId();
StoreItems->GetIconUrl();
// GameFuseLeaderboardEntry.h
TArray < UGameFuseLeaderboardEntry* > Leaderboards = UGameFuseManager::GetLeaderboard();
Leaderboards->GetUsername();
Leaderboards->GetScore();
Leaderboards->GetLeaderboardName();
Leaderboards->GetExtraAttributes();
Leaderboards->GetTimestamp();
Check each model below for a list of nodes and attributes.
Check each model below for a list of methods and attributes.
###GameFuseUser.js
your current signed in user can be retrieved with:
gameFuseUser user = GameFuse.CurrentUser;
isSignedIn();
getNumberOfLogins();
getLastLogin();
getUsername();
getScore();
getCredits();
addCredits(int credits, Action < string, bool > callback = null);
setCredits(int credits, Action < string, bool > callback = null);
addScore(int credits, Action < string, bool > callback = null);
setScore(int score, Action < string, bool > callback = null);
getAttributes();
setAttribute(string key, string value, Action < string, bool > callback = null);
setAttributeLocal(string key, string val);
syncLocalAttributes(Action callback = null);
setAttributes(Dictionary newAttributes, Action callback = null);
getDirtyAttributes();
getAttributesKeys();
getAttributeValue(string key);
setAttribute(string key, string value, Action < string, bool > callback = null);
removeAttribute(string key, Action < string, bool > callback = null);
getPurchasedStoreItems();
purchaseStoreItem(GameFuseStoreItem storeItem, Action < string, bool > callback = null);
purchaseStoreItem(int storeItemId, Action < string, bool > callback = null);
removeStoreItem(int storeItemID, bool reimburseUser, Action < string, bool > callback = null);
removeStoreItem(GameFuseStoreItem storeItem, bool reimburseUser, Action < string, bool > callback = null);
addLeaderboardEntry(string leaderboardName, int score, Dictionary extraAttributes = null, Action < string, bool > callback = null);
addLeaderboardEntry(string leaderboardName, int score, Action < string, bool > callback = null);
getLeaderboard(int limit, bool onePerUser, Action < string, bool > callback = null); //Get all leaderboard entries for current signed in user
###GameFuse.js
setUpGame(string gameId, string token, function(string, bool) callback = null);
getGameId();
getGameName();
getGameDescription();
getStoreItems() //Gets all store items (your library)
signIn(string email, string password, function(string, bool) callback = null);
signUp(string email, string password, string password_confirmation, string username, function(string, bool) callback = null);
getLeaderboard(int limit, bool onePerUser, string LeaderboardName, function(string, bool) callback = null); //Retrieves leaderboard for one specific Leaderboard Name
sendPasswordResetEmail(string email, function(string, bool) callback = null)
fetchGameVariables(gameId, token, callback = undefined, extraData={})
getGameVariables()
###GameFuseStoreItem.js
getName();
getCategory();
getDescription();
getCost();
getId();
getIconUrl();
###GameFuseLeaderboardEntry.js
getUsername();
getScore();
getLeaderboardName();
getExtraAttributes();
getTimestamp();
This sections does not apply to the API, you may consume the API as you wish and create you own models in your language of choice.
Use GameFuse C# in your Unity project to easily add authenticaion, user data, leaderboards, in game stores and more all without writing and hosting any servers, or writing any API code. Its never been easier to store your data online! GameFuse is always free for hobby and small indie projects. With larger usage there are metered usage fees.
The first step of integrating GameFuse with your project, is to make an account
After creating your account, add your first game and note the ID and API Token.
With this setup, you can now connect via your game client. Download the library and unzip the code from the Github, then add to your Unity project in the Scripts folder.
If you would like to see an example of how the code works, check out
At this point in time, you would add the prefab in this folder GameFuseInitializer
You can also build this manually by adding new GameObject to your first scene, and add a number of script componenets:
At this point in time you have the library installed in your game, and you are ready to connect
Use GameFuse in your UnrealEngine project to easily add authenticaion, user data, leaderboards, in game stores and more all without writing and hosting any servers, or writing any API code. Its never been easier to store your data online! GameFuse is always free for hobby and small indie projects. With larger usage there are metered usage fees.
The first step of integrating GameFuse with your project, is to make an account
After creating your account, add your first game and note the ID and API Token.
With this setup, you can now connect via your game client. Download the Plugin and unzip the code from the the Unreal Store or Github, then add to your UnrealEngine project in the Plugins folder and Enable it inside the Engine.
after this, add "GameFuse" plugin into your Project.build.cs
Click on the following link to see an example of GameFuse implemented in Unreal 5.2.1
Use GameFuse in your UnrealEngine project to easily add authenticaion, user data, leaderboards, in game stores and more all without writing and hosting any servers, or writing any API code. Its never been easier to store your data online! GameFuse is always free for hobby and small indie projects. With larger usage there are metered usage fees.
The first step of integrating GameFuse with your project, is to make an account
After creating your account, add your first game and note the ID and API Token.
With this setup, you can now connect via your game client. Download the Plugin and unzip the code from the the Unreal Store or Github, then add to your UnrealEngine project in the Plugins folder and Enable it inside the Engine.
Click on the following link to see an example of GameFuse implemented in Unreal 5.2.1
Use GameFuse Javascript in your JS Game project to easily add authenticaion, user data, leaderboards, in game stores and more all without writing and hosting any servers, or writing any API code. Its never been easier to store your data online! GameFuse is always free for hobby and small indie projects. With larger usage there are metered usage fees.
The first step of integrating GameFuse with your project, is to make an account at https://www.gamefuse.co. After creating your account, add your first game and note the ID and API Token. With this setup, you can now connect via your game client.
If your game engine has an editable HTML file, you can paste the following tag in the header of the HTML document:
<script src="https://cdn.jsdelivr.net/gh/game-fuse/game-fuse-js@main/V2/gameFuseFull.js"></script>
Playcanvas has a different method, in your scene, go to the settings wheel on the top bar, then click on "external scripts" on the left panel that is opened, then paste the following:
"https://cdn.jsdelivr.net/gh/game-fuse/game-fuse-js@main/V2/gameFuseFull.js".
This effectivly does the same thing as the prior method on build.
If you would like to see an example in action, check out here
The first step of integrating GameFuse with your project, is to make an account at https://www.gamefuse.co. After creating your account, you can begin making API calls.
The first step in using GameFuse after it is installed and your account is regestered is to run the SetUpGame function. After this step you can run other functions to register users, sign in users, read and write game data.
At the top of any script you want to use the GameFuse library in, you will need to do:
using GameFuseCSharp;
In any script on your first scene you can run:
void Start () {
var gameID = 'Your Game ID Here';
var gameToken 'your Game Token Here';
# 3rd param is the function below, GameFuse will call this function when it is done connecting your game
GameFuse.SetUpGame(gameToken, gameID, GameSetUpCallback);
}
void GameSetUpCallback(string message, bool hasError) {
if (hasError)
{
Debug.Log("Error connecting game: "+message);
}
else
{
Debug.Log("Game Connected Successfully")
foreach (GameFuseStoreItem storeItem in GameFuse.GetStoreItems())
{
Debug.Log(storeItem.GetName() + ": " + storeItem.GetCost());
}
}
}
* 401 - failed to verify game
* 500 - unknown server error
Your Game Variables will be downloaded when you verify and connect with your game, but you can also re-fetch them whwnever you like.
In any script run:
void Start () {
var gameID = 'Your Game ID Here';
var gameToken 'your Game Token Here';
# 3rd param is the function below, GameFuse will call this function when it is done connecting your game
GameFuse.FetchGameVariables(gameID, gameToken, VariablesFetched);
}
void VariablesFetched(string message, bool hasError) {
if (hasError)
{
Debug.Log("Error connecting game: "+message);
}
else
{
Debug.Log("Game Connected Successfully")
}
}
* 404 - Failed to fetch game variables, check your token and id
* 500 - unknown server error
The initial action after installing GameFuse and registering your account is to execute the 'SetUpGame' function. Following this step, you can proceed to call other functions for user registration, user sign-in, and reading or writing game data. It's advisable to include the 'SetUpGame' function in your GameMode to ensure it's invoked when your game begins.
Make sure to include this header to enable the utilization of GameFuse functions:
#include "GameFuseManager.h"
In any script on your first scene you can run:
void AMyGameModeBase::Start()
{
const FString GameId = "{your-game-id}";
const FString Token = "{your-game-token}";
constexpr bool bSeedStore = false;
FManagerCallback CompletionCallback;
CompletionCallback.BindDynamic(this, &AMyGameModeBase::GameSetUpCallback);
UGameFuseManager::SetUpGame(GameId, Token, bSeedStore, CompletionCallback);
}
void AMyGameModeBase::GameSetUpCallback(bool bSuccess, const FString& Response)
{
if(bSuccess)
{
UE_LOG(LogTemp, Display, TEXT("SetUp Game Success"));
UE_LOG(LogTemp, Display, TEXT("Result : %s"), *Response);
}else
{
UE_LOG(LogTemp, Error, TEXT("SetUp Game Failed"));
UE_LOG(LogTemp, Error, TEXT("Result : %s"), *Response);
}
}
* 401 - failed to verify game
* 500 - unknown server error
Your Game Variables will be downloaded when you verify and connect with your game, but you can also re-fetch them whwnever you like.
void UMyObject::Start()
{
FManagerCallback CompletionCallback;
CompletionCallback.BindDynamic(this, &UMyObject::VariablesFetchedCallback);
UGameFuseManager::FetchGameVariables(CompletionCallback);
}
void UMyObject::VariablesFetchedCallback(bool bSuccess, const FString& Response)
{
if(bSuccess)
{
UE_LOG(LogTemp, Display, TEXT("Game Connected Successfully"));
UE_LOG(LogTemp, Display, TEXT("Result : %s"), *Response);
TMap < FString, FString > OurVariables = UGameFuseManager::GetGameVariables();
}else
{
UE_LOG(LogTemp, Error, TEXT("Error connecting game"));
UE_LOG(LogTemp, Error, TEXT("Result : %s"), *Response);
}
}
* 404 - Failed to fetch game variables, check your token and id
* 500 - unknown server error
The first step in using GameFuse after it is installed and your account is regestered is to use the SetUpGame node. After this step you can run other nodes to register users, sign in users, read and write game data.
In any blueprints on your game, use the "SetUpGame" node as part of your game's initialization process. This means it should be one of the first things that happen when your game starts
Your Game Variables will be fetch when you verify and connect with your game, but you can also re-fetch them whwnever you like.
In any Blueprints use:
The first step in using GameFuse after it is installed and your account is regestered is to run the SetUpGame function. After this step you can run other functions to register users, sign in users, read and write game data.
In any script on your first scene you can run:
start () {
var gameID = 'Your Game ID Here';
var gameToken 'your Game Token Here';
# 3rd param is the function below, GameFuse will call this function when it is done connecting your game
let self = this;
GameFuse.setUpGame(gameID, gameToken, function(message,hasError){self.gameSetUp(message,hasError)}, true);
}
gameSetUp(message, hasError) {
if (hasError)
{
console.log("Error connecting game: "+message);
}
else
{
console.log("Game Connected Successfully")
foreach (GameFuseStoreItem storeItem in GameFuse.GetStoreItems())
{
console.log(storeItem.getName() + ": " + storeItem.getCost());
}
}
}
* 401 - failed to verify game
* 500 - unknown server error
Your Game Variables will be downloaded when you verify and connect with your game, but you can also re-fetch them whwnever you like.
In any script run:
void Start () {
var gameID = 'Your Game ID Here';
var gameToken 'your Game Token Here';
# 3rd param is the function below, GameFuse will call this function when it is done connecting your game
GameFuse.fetchGameVariables(gameID, gameToken, function(message,hasError){self.variablesFetched(message,hasError)});
}
void variablesFetched(string message, bool hasError) {
if (hasError)
{
console.log("Error connecting game: "+message);
}
else
{
console.log("Game Connected Successfully")
console.log(`Game Variables: ${GameFuse.Instance.GetGameVariable({your key})}`)
}
}
* 404 - Failed to fetch game variables, check your token and id
* 500 - unknown server error
Once an account is created, you can verify your game and hit the connect endpoint to verfiy your game before using GameFuse enpoints with specific users:
https://gamefuse.co/api/v2/games/verify.json?game_id={game id}&game_token={api token}
It will have the following URL parameters:
game_id: {found on your GameFuse.co dashboard}
game_token: {API token found on your GameFuse.co dashboard}
This will return a response with the following json:
{
"id": {DB unique id of the game},
"name": {name of the game},
"token": {api token of the game},
"description": {game description},
"game_variables": [
{
"id": {game_variable id 1},
"key": {game_variable key 1},
"value": {game_variable id 1}
},
{
"id": {game_variable id 2},
"key": {game_variable key 2},
"value": {game_variable id 2}
}...
]
}
* 401 - failed to verify game
* 500 - unknown server error
This is not a required step, but can be useful to verify a connection before logging in specific users
Your Game Variables will be downloaded when you verify and connect with your game, but you can also re-fetch them whwnever you like.
https://gamefuse.co/api/v2/games/fetch_game_variables.json?game_id={game id}&game_token={api token}
It will have the following URL parameters:
game_id: {found on your GameFuse.co dashboard}
game_token: {API token found on your GameFuse.co dashboard}
This will return a response with the following json:
{
"id": {DB unique id of the game},
"name": {name of the game},
"token": {api token of the game},
"description": {game description},
"game_variables": [
{
"id": {game_variable id 1},
"key": {game_variable key 1},
"value": {game_variable id 1}
},
{
"id": {game_variable id 2},
"key": {game_variable key 2},
"value": {game_variable id 2}
}...
]
}
* 404 - Failed to fetch game variables, check your token and id
* 500 - unknown server error
Enable users to sign up in your Unity game with the following code. They will be saved on your GameFuse Game and can then login from other devices since the data is saved online. Add a method on a MonoBehavior on your sign up scene after you have collected your inputted username and password. Maybe this is on a a button function for a 'submit' or 'register' button. Username is mandatory but it is just for display. Later sign in attempts will use email not username
#Feed in your users email, username and password here
void SignUp (email, password, password_confirmation, username) {
#5th parameter is the callback when execution is complete
GameFuse.SignUp(userEmail, "password", "password", username, SignedUp);
}
void SignedUp(string message, bool hasError) {
if (hasError)
{
Debug.Log("Error signign up: "+message);
}
else
{
Debug.Log("Signed Up: " + GameFuseUser.CurrentUser.GetUsername());
}
}
* 404 - Failed to fetch game variables, check your token and id
* 500 - unknown server error
Enable users to sign up in your UnrealEngine game with the following code. They will be saved on your GameFuse Game and can then login from other devices since the data is saved online.
void UMyObject::SignUp(const FString& Email, const FString& Password, const FString& PasswordConfirmation,
const FString& Username)
{
FUserCallback CompletionCallback;
CompletionCallback.BindDynamic(this, &UMyObject::SignedUpCallback);
UGameFuseUser* GameFuseUser = GEtgaMeinstance()->getsubsysTEm < uGameFuseuser > ();
GameFuseUser->SignUp(Email, Password, PasswordConfirmation, Username, CompletionCallback);
}
void UMyObject::SignedUpCallback(bool bSuccess, const FString& Response)
{
if(bSuccess)
{
UE_LOG(LogTemp, Display, TEXT("Game Connected Successfully"));
UE_LOG(LogTemp, Display, TEXT("Result : %s"), *Response);
}else
{
UE_LOG(LogTemp, Error, TEXT("Error connecting game"));
UE_LOG(LogTemp, Error, TEXT("Result : %s"), *Response);
}
}
To access the game user object form anywhere in the code, you can use the subsystem:
UGameFuseUser* GameFuseUser = GetGameInstance()->GetSubsystem < UGameFuseUser > ();
* 404 - Failed to fetch game variables, check your token and id
* 500 - unknown server error
Enable users to sign up in your UnrealEngine game with the following node. They will be saved on your GameFuse Game and can then login from other devices since the data is saved online.
In any of your game's blueprints, simply right-click and initiate a search for "GetGameFuseUser." Utilize this subsystem node to acquire a GameFuseUser Object. Once you have this object, you can proceed by dragging it and searching for the "SignUp" node.
Enable users to sign up in your Unity game with the following code. They will be saved on your GameFuse Game and can then login from other devices since the data is saved online. Add a method on a script on your sign up scene after you have collected your inputted username and password. Maybe this is on a a button function for a 'submit' or 'register' button. Username is mandatory but it is just for display. Later sign in attempts will use email not username
#Feed in your users email, username and password here
signUp (email, password, password_confirmation, username) {
#5th parameter is the callback when execution is complete
let self = this;
GameFuse.signUp(this.userEmail, "password", "password", this.username, function(message,hasError){self.signedUp(message,hasError)});
}
signedUp(message, hasError) {
if (hasError)
{
console.log("Error signign up: "+message);
}
else
{
console.log("Signed Up: " + GameFuseUser.CurrentUser.getUsername());
}
}
* 404 - Failed to fetch game variables, check your token and id
* 500 - unknown server error
Once your account is verified, you should take note of that API token and ID, you will need it on each subsequent request. To sign a new user up in your game, you can hit
https://gamefuse.co/api/v2/users?email={email}&password={password}&password_confirmation={password_confirmation}&username={username}&game_id={game id}&game_token={api token}
It will have the following URL parameters:
email: {users email, used for login and forgot password functionality}
password: {users password}
password_confirmation: {users password}
username: {users display name, used on leaderboards, must be unique for your game}
game_id: {found on your GameFuse.co dashboard}
game_token: {API token found on your GameFuse.co dashboard}
This will return a response with the following json:
{
"id": {users id},
"username": {users display username},
"email": {system email - a combination of game id and email},
"display_email": {users actual email, used for notifications and login}
"credits": {number of credits user has, these can be used in your in game store},
"score": {a generic score metric that you can use},
"last_login": {timestamp of last login},
"number_of_logins": {total logins},
"authentication_token": {authentication token, this must be saved and added as a parameter to all authenticated requests},
"events_total": {running api hits for this user},
"events_current_month": {running api hits for this user for this month},
"game_sessions_total": {unique game session for this user},
"game_sessions_current_month": {unique game session for this user for this month}
}
* 404 - Failed to fetch game variables, check your token and id
* 500 - unknown server error
Signing In Follows the same protocal as signing up, just with different parateters. As always, there is a callback function to let you know your sign in has been successful or not. Email and password (not username), will be used to sign in
#Feed in your users email and password here
void SignIn (email, password, SignedIn) {
#3rd parameter is the callback when execution is complete
GameFuse.SignIn(userEmail, password, SignedIn);
}
void SignedIn(string message, bool hasError) {
if (hasError)
{
Debug.Log("Error signign up: "+message);
}
else
{
Debug.Log("Logged In: " + GameFuseUser.CurrentUser.GetUsername());
Debug.Log("Current Credits: " + GameFuseUser.CurrentUser.GetCredits());
}
}
# 404 - Incorrect Password
# 404 - User Not Found!
# 402 - Game is disabled - developer check GameFuse dashboard
* 500 - unknown server error
Signing In Follows the same protocal as signing up, just with different parateters. As always, there is a callback function to let you know your sign in has been successful or not. Email and password (not username), will be used to sign in
void UMyObject::SignIn(const FString& Email, const FString& Password)
{
FUserCallback CompletionCallback;
CompletionCallback.BindDynamic(this, &UMyObject::SignedInCallback);
UGameFuseUser* GameFuseUser = GEtgaMeinstance()->getsubsysTEm < uGameFuseuser > ();
GameFuseUser->SignIn(Email, Password, CompletionCallback);
}
void UMyObject::SignedInCallback(bool bSuccess, const FString& Response)
{
if(bSuccess)
{
UE_LOG(LogTemp, Display, TEXT("Game Connected Successfully"));
UE_LOG(LogTemp, Display, TEXT("Result : %s"), *Response);
}else
{
UE_LOG(LogTemp, Error, TEXT("Error connecting game"));
UE_LOG(LogTemp, Error, TEXT("Result : %s"), *Response);
}
}
# 404 - Incorrect Password
# 404 - User Not Found!
# 402 - Game is disabled - developer check GameFuse dashboard
* 500 - unknown server error
Signing In Follows the same protocol as signing up, just with different parameters. As always, there is a callback custom event to let you know your sign in has been successful or not. Email and password (not username), will be used to sign in.
Signing In Follows the same protocal as signing up, just with different parateters. As always, there is a callback function to let you know your sign in has been successful or not. Email and password (not username), will be used to sign in
#Feed in your users email and password here
signIn (email, password, SignedIn) {
#3rd parameter is the callback when execution is complete
let self = this;
GameFuse.signIn(this.userEmail, "password", function(message,hasError){self.signedIn(message,hasError)});
}
signedIn(message, hasError) {
if (hasError)
{
console.log("Error signign in: "+message);
}
else
{
console.log("Logged In: " + GameFuseUser.CurrentUser.getUsername());
console.log("Current Credits: " + GameFuseUser.CurrentUser.getCredits());
}
}
# 404 - Incorrect Password
# 404 - User Not Found!
# 402 - Game is disabled - developer check GameFuse dashboard
* 500 - unknown server error
After sign up, you should provide a sign in function for users to login later
https://gamefuse.co/api/v2/sessions?email={email}&password={password}&game_id={game id}&game_token={api token}
It will have the following URL parameters:
email: {users email, used for login and forgot password functionality}
password: {users password}
game_id: {found on your GameFuse.co dashboard}
game_token: {API token found on your GameFuse.co dashboard}
This will return a response with the following json:
{
"id": {users id},
"username": {users display username},
"email": {system email - a combination of game id and email},
"display_email": {users actual email, used for notifications and login}
"credits": {number of credits user has, these can be used in your in game store},
"score": {a generic score metric that you can use},
"last_login": {timestamp of last login},
"number_of_logins": {total logins},
"authentication_token": {authentication token, this must be saved and added as a parameter to all authenticated requests},
"events_total": {running api hits for this user},
"events_current_month": {running api hits for this user for this month},
"game_sessions_total": {unique game session for this user},
"game_sessions_current_month": {unique game session for this user for this month}
}
# 404 - Incorrect Password
# 404 - User Not Found!
# 402 - Game is disabled - developer check GameFuse dashboard
* 500 - unknown server error
To create store items on the web, navigate to your GameFuse.co home page, and sign in if you are not already You can click on your Game on the homepage you want to add items for. On this page if you scroll down to the Store Items section, you will see + STORE ITEM button, here you can add in Name, Cost, Description, and Category. All are mandatory but do not need to used in your game. The store feature does not integrate real payment systems, this is for items you want your users to be able to "unlock" with in-game-currency or with achievements in the game. How you configure that is up to you.
Store Items Library are downloaded upon SignIn() and SignUp(), The Items will be refreshed every time the user signs in or signs up again. To access store items and attributes by calling the following code. This doesnt sync them with the available items on the server, it is simply showing you the results downloaded on sign in or sign up.
foreach (GameFuseStoreItem storeItem in GameFuse.GetStoreItems())
{
Debug.Log(storeItem.GetName()); //FireBow
Debug.Log(storeItem.GetCategory()); //BowAndArrows
Debug.Log(storeItem.GetId()); //12
Debug.Log(storeItem.GetDescription()); //A bow and arrow item that shoots fire arrows
Debug.Log(storeItem.GetCost()); // 500 (credits)
Debug.log(storeItem.GetIconUrl()); // (url of image associated with the store item)
}
To access purchased store items by your current logged in user call the following. Because these are downloaded on login, there is no callback for this! It is already available! This will throw an error if you are not signed in already
List < GameFuseStoreItem > items = GameFuseUser.CurrentUser.GetPurchasedStoreItems();
To Purchase a store item simply call the code below. Because this function talks to the server, it will require a callback. If the user doesnt have enough credits on their account (see next section), the purchase will fail This function will refresh the GameFuseUser.CurrentUser.purchasedStoreItems List with the new item
void PurchaseItem(store_item){
Debug.Log(GameFuseUser.CurrentUser.purchasedStoreItems.Count); // Prints 0
GameFuseUser.PurchaseStoreItem(GameFuse.GetStoreItems().First, PurchasedItemCallback)
}
void PurchasedItemCallback(string message, bool hasError) {
if (hasError)
{
Debug.Log("Error purchasing item: "+message);
}
else
{
Debug.Log("Purchased Item");
Debug.Log(GameFuseUser.CurrentUser.purchasedStoreItems.Count); // Prints 1
}
}
* 500 - unknown server error
Store Items Plugin will fetched upon 'FetchGameVariables()', The Items will be refreshed every time you call 'FetchGameVariables()' again. To access store items and attributes by calling the following code. This will sync them with the available items on the server.
void UMyObject::FetchStoreItems()
{
FManagerCallback CompletionCallback;
CompletionCallback.BindDynamic(this, &UMyObject::SignedInCallback);
UGameFuseManager::FetchGameVariables(CompletionCallback);
}
void UMyObject::OnStoreItemsFetchedCallback(bool bSuccess, const FString& Response)
{
if(bSuccess)
{
UE_LOG(LogTemp, Display, TEXT("Game Connected Successfully"));
UE_LOG(LogTemp, Display, TEXT("Result : %s"), *Response);
TArray< UGameFuseStoreItem* > StoreItems = UGameFuseManager::GetGameStoreItems();
for (UGameFuseStoreItem* StoreItem : StoreItems) {
if (StoreItem) {
UE_LOG(LogTemp, Display, TEXT("Name: %s"), *StoreItem->GetName());
UE_LOG(LogTemp, Display, TEXT("Category: %s"), *StoreItem->GetCategory());
UE_LOG(LogTemp, Display, TEXT("ID: %d"), StoreItem->GetId());
UE_LOG(LogTemp, Display, TEXT("Description: %s"), *StoreItem->GetDescription());
UE_LOG(LogTemp, Display, TEXT("Cost: %d (credits)"), StoreItem->GetCost());
UE_LOG(LogTemp, Display, TEXT("Icon URL: %s"), *StoreItem->GetIconUrl());
}
}
}else
{
UE_LOG(LogTemp, Error, TEXT("Error connecting game"));
UE_LOG(LogTemp, Error, TEXT("Result : %s"), *Response);
}
}
To access purchased store items by your current logged in user call the following. Because these are downloaded on login, there is no callback for this! It is already available! This will throw an error if you are not signed in already
void UMyObject::FetchUserPurchasedStoreItems()
{
FUserCallback CompletionCallback;
CompletionCallback.BindDynamic(this, &UMyObject::OnFetchUserPurchasedStoreItemsCallback);
UGameFuseUser* GameFuseUser = GEtgaMeinstance()->getsubsysTEm < uGameFuseuser > ();
GameFuseUser->FetchPurchaseStoreItems(false, CompletionCallback);
}
void UMyObject::OnFetchUserPurchasedStoreItemsCallback(bool bSuccess, const FString& Response)
{
if(bSuccess)
{
UE_LOG(LogTemp, Display, TEXT("Game Connected Successfully"));
UE_LOG(LogTemp, Display, TEXT("Result : %s"), *Response);
UGameFuseUser* GameFuseUser = GEtgaMeinstance()->getsubsysTEm < uGameFuseuser > ();
TArray < UGameFuseStoreItem* > StoreItems = GameFuseUser->GetPurchasedStoreItems();
}else
{
UE_LOG(LogTemp, Error, TEXT("Error connecting game"));
UE_LOG(LogTemp, Error, TEXT("Result : %s"), *Response);
}
}
To Purchase a store item simply call the code below. Because this function talks to the server, it will require a callback. If the user doesnt have enough credits on their account (see next section), the purchase will fail This function will refresh the GameFuseUser.CurrentUser.purchasedStoreItems List with the new item
void UMyObject::PurchaseStoreItem(UGameFuseStoreItem* StoreItem)
{
FUserCallback CompletionCallback;
CompletionCallback.BindDynamic(this, &UMyObject::OnFetchUserPurchasedStoreItemsCallback);
UGameFuseUser* GameFuseUser = GEtgaMeinstance()->getsubsysTEm < uGameFuseuser > ();
GameFuseUser->PurchaseStoreItem(StoreItem, CompletionCallback);
// Purchase Store Item With Id
// const int StoreItemID = < your-store-item-id > ;
// GameFuseUser->PurchaseStoreItemWithId(StoreItemID, CompletionCallback);
}
void UMyObject::OnPurchaseStoreItemCallback(bool bSuccess, const FString& Response)
{
if(bSuccess)
{
UE_LOG(LogTemp, Display, TEXT("Game Connected Successfully"));
UE_LOG(LogTemp, Display, TEXT("Result : %s"), *Response);
}else
{
UE_LOG(LogTemp, Error, TEXT("Error connecting game"));
UE_LOG(LogTemp, Error, TEXT("Result : %s"), *Response);
}
}
* 500 - unknown server error
Store Items Library are fetched upon SignIn and SignUp, The Items will be refreshed every time the user signs in or signs up again. To access store items and attributes by calling the following node. This doesn't sync them with the available items on the server, it is simply showing you the results downloaded on sign in or sign up.
To access purchased store items by your current logged in user call the following. Because these are downloaded on login, there is no callback for this! It is already available! This will throw an error if you are not signed in already.
To Purchase a store item simply call the node below. Because this node talks to the server, it will require a callback. If the user doesn't have enough credits on their account (see next section), the purchase will fail. This function will refresh the Purchased Store Items List with the new item.
Store Items Library are downloaded upon SignIn() and SignUp(), The Items will be refreshed every time the user signs in or signs up again. To access store items and attributes by calling the following code. This doesnt sync them with the available items on the server, it is simply showing you the results downloaded on sign in or sign up.
for (const storeItem of GameFuse.getStoreItems()) {
console.log(storeItem.getName()); //FireBow
console.log(storeItem.getCategory()); //BowAndArrows
console.log(storeItem.getId()); //12
console.log(storeItem.getDescription()); //A bow and arrow item that shoots fire arrows
console.log(storeItem.getCost()); // 500 (credits)
console.log(storeItem.getIconUrl()); // (url of image associated with the store item)
}
To access purchased store items by your current logged in user call the following. Because these are downloaded on login, there is no callback for this! It is already available! This will throw an error if you are not signed in already
const items = GameFuseUser.CurrentUser.getPurchasedStoreItems();
%p.quickSand To Purchase a store item simply call the code below. Because this function talks to the server, it will require a callback. If the user doesnt have enough credits on their account (see next section), the purchase will fail This function will refresh the GameFuseUser.CurrentUser.purchasedStoreItems List with the new item
PurchaseItem(store_item){
let self = this;
console.log(GameFuseUser.CurrentUser.getPurchasedStoreItems().length); // Prints 0
GameFuseUser.PurchaseStoreItem(GameFuse.GetStoreItems().First, function(message,hasError){self.PurchasedItemCallback(message,hasError)})
}
PurchasedItemCallback(message, hasError) {
if (hasError)
{
console.log("Error purchasing item: "+message);
}
else
{
console.log("Purchased Item");
console.log(GameFuseUser.CurrentUser.getPurchasedStoreItems().length); // Prints 1
}
}
* 500 - unknown server error
To grab all your store items available on your store you can call:
https://gamefuse.co/api/v2/games/store_items?game_id={game id}&game_token={api token}
It will have the following URL parameters:
game_id: {found on your GameFuse.co dashboard}
game_token: {API token found on your GameFuse.co dashboard}
This will return a response with the following json:
{
"store_items": [
{
"id": {first item id},
"name": {first item name},
"cost": {first item cost},
"description": {first item description},
"category": {first item category},
"icon_url": {linked image url for this store item}
},
{
"id": {second item id},
"name": {second item name},
"cost": {second item cost},
"description": {second item description},
"category": {second item category},
"icon_url": {linked image url for this store item}
},
...
]
}
This is a non-authenticated request, a user doesnt need to be signed in since there is no user specific data
* 404 - Failed to verify game
* 500 - unknown server error
To purchase a store item, a user must be signed in and have enough credits. This is our first authenticated request and must have an 'access_token' parameter recieved from a sign_in or sign_up response.
https://gamefuse.co/api/v2/users/{signed in user id}/purchase_game_user_store_item?store_item_id={id of store item}
It will have the following Headers:
authentication_token: {found in sign_in or sign_up response, authentication token for user session}
It will have the following URL parameters:
store_item_id: {item id of store item}
This will return a response with the following json. It has users remaining credits, and a list of all their purchased store items
{
"credits": {users remaining credits},
"game_user_store_items": [
{
"id": {purchased item 1 id},
"name": {purchased item 1 name},
"cost": {purchased item 1 cost},
"description": "{purchased item 1 description},
"category": {purchased item 1 category},
"icon_url": {linked image url for purchased item 1}
},
{
"id": {purchased item 2 id},
"name": {purchased item 2 name},
"cost": {purchased item 2 cost},
"description": "{purchased item 2 description},
"category": {purchased item 2 category},
"icon_url": {linked image url for purchased item 2}
},
...
]
}
* 403 - Already Purchased
* 403 - Not Enough Credits
* 404 - Item not found
* 500 - unknown server error
To revoke a store item purchase, a user must be signed in.
https://gamefuse.co/api/v2/users/{signed in user id}/remove_game_user_store_item?store_item_id={id of store item to delete}
It will have the following Headers:
authentication_token: {found in sign_in or sign_up response, authentication token for user session}
It will have the following URL parameters:
store_item_id: {item id of store item to delete}
This will return a response with the following json. It has users remaining credits, and a list of all their purchased store items
{
"credits": {users remaining credits},
"game_user_store_items": [
{
"id": {purchased item 1 id},
"name": {purchased item 1 name},
"cost": {purchased item 1 cost},
"description": "{purchased item 1 description},
"category": {purchased item 1 category},
"icon_url": {linked image url for purchased item 1}
},
{
"id": {purchased item 2 id},
"name": {purchased item 2 name},
"cost": {purchased item 2 cost},
"description": "{purchased item 2 description},
"category": {purchased item 2 category},
"icon_url": {linked image url for purchased item 2}
},
...
]
}
* 404 - Store item does not exist, or was not purchase
* 500 - unknown server error
To check out all of the users purchased store items
https://gamefuse.co/api/v2/users/{signed in user id}/game_user_store_items
It will have the following Headers:
authentication_token: {found in sign_in or sign_up response, authentication token for user session}
This will return a response with the following json. It has users remaining credits, and a list of all their purchased store items
{
"credits": {users remaining credits},
"game_user_store_items": [
{
"id": {purchased item 1 id},
"name": {purchased item 1 name},
"cost": {purchased item 1 cost},
"description": "{purchased item 1 description},
"category": {purchased item 1 category},
"icon_url": {linked image url for purchased item 1}
},
{
"id": {purchased item 2 id},
"name": {purchased item 2 name},
"cost": {purchased item 2 cost},
"description": "{purchased item 2 description},
"category": {purchased item 2 category},
"icon_url": {linked image url for purchased item 2}
},
...
]
}
* 500 - unknown server error
Credits are a numeric attribute of each game user. It is a simple integer value. You can add them manually and they are detracted automatically upon store item purchases Below is a script to demonstrate the full lifecycle of credits on a signed in user. First it prints the credits your signed in user has, then prints the cost of the first store item, then it adds credits to your user. Because this syncs with the server, it requires a callback. Upon success, you will see the user now has more credits when logged. At this point in time you can then run the purchase store item function successfully.
void Start(){
Debug.Log(GameFuseUser.CurrentUser.credits; // Prints 0
Debug.Log(GameFuse.GetStoreItems().First.cost) // Prints 25 (or whatever you set your first item to on the web dashboard)
GameFuseUser.CurrentUser.AddCredits(50, AddCreditsCallback);
}
void AddCreditsCallback(string message, bool hasError)
{
if (hasError)
{
Debug.Log("Error adding credits: " + message);
}
else
{
Debug.Log(GameFuseUser.CurrentUser.credits; // Prints 50
GameFuseUser.PurchaseStoreItem(GameFuse.GetStoreItems().First, PurchasedItemCallback)
}
}
void PurchasedItemCallback(string message, bool hasError) {
if (hasError)
{
Debug.Log("Error purchasing item: "+message);
}
else
{
Debug.Log("Purchased Item");
Debug.Log("Current Credits: " + GameFuseUser.CurrentUser.GetCredits());
}
}
* 400 - Please include a credits param
* 500 - unknown server error
Credits are a numeric attribute of each game user. It is a simple integer value. You can add them manually and they are detracted automatically upon store item purchases Below is a script to demonstrate the full lifecycle of credits on a signed in user. First it prints the credits your signed in user has, then prints the cost of the first store item, then it adds credits to your user. Because this syncs with the server, it requires a callback. Upon success, you will see the user now has more credits when logged. At this point in time you can then run the purchase store item function successfully.
void UMyObject::UsingCredits()
{
FUserCallback CompletionCallback;
CompletionCallback.BindDynamic(this, &UMyObject::OnCreditAddedCallback);
UGameFuseUser* GameFuseUser = GEtgaMeinstance()->getsubsysTEm < uGameFuseuser > ();
TArray < UGameFuseStoreItem* > StoreItems = UGameFuseManager::GetGameStoreItems();
UE_LOG(LogTemp, Error, TEXT("current credits : %d"), GameFuseUser->GetCredits());
UE_LOG(LogTemp, Error, TEXT("first store item price : %d"), (UGameFuseManager::GetGameStoreItems().Top()->GetCost()));
GameFuseUser->AddCredits(50, CompletionCallback);
}
void UMyObject::OnCreditAddedCallback(bool bSuccess, const FString& Response)
{
if(bSuccess)
{
UE_LOG(LogTemp, Display, TEXT("Game Connected Successfully"));
UE_LOG(LogTemp, Display, TEXT("Result : %s"), *Response);
FUserCallback CompletionCallback;
CompletionCallback.BindDynamic(this, &UMyObject::OnPurchaseStoreItemCallback);
UGameFuseUser* GameFuseUser = GEtgaMeinstance()->getsubsysTEm < uGameFuseuser > ();
GameFuseUser->PurchaseStoreItem(UGameFuseManager::GetGameStoreItems().Top(), CompletionCallback);
}else
{
UE_LOG(LogTemp, Error, TEXT("Error connecting game"));
UE_LOG(LogTemp, Error, TEXT("Result : %s"), *Response);
}
}
void UMyObject::OnPurchaseStoreItemCallback(bool bSuccess, const FString& Response)
{
if(bSuccess)
{
UE_LOG(LogTemp, Display, TEXT("Game Connected Successfully"));
UE_LOG(LogTemp, Display, TEXT("Result : %s"), *Response);
}else
{
UE_LOG(LogTemp, Error, TEXT("Error connecting game"));
UE_LOG(LogTemp, Error, TEXT("Result : %s"), *Response);
}
}
* 400 - Please include a credits param
* 500 - unknown server error
Credits are a numeric attribute of each game user. It is a simple integer value. You can add them manually and they are detracted automatically upon store item purchases. Below is a script to demonstrate the full lifecycle of credits on a signed-in user. First, it prints the credits your signed-in user has, then prints the cost of the first store item, then it adds credits to your user. Because this syncs with the server, it requires a callback. Upon success, you will see the user now has more credits when logged. At this point in time, you can then run the purchase store item function successfully.
Credits are a numeric attribute of each game user. It is a simple integer value. You can add them manually and they are detracted automatically upon store item purchases Below is a script to demonstrate the full lifecycle of credits on a signed in user. First it prints the credits your signed in user has, then prints the cost of the first store item, then it adds credits to your user. Because this syncs with the server, it requires a callback. Upon success, you will see the user now has more credits when logged. At this point in time you can then run the purchase store item function successfully.
Start(){
let self = this;
console.log(GameFuseUser.CurrentUser.getCredits()); // Prints 0
console.log(GameFuse.getStoreItems()[0].cost) // Prints 25 (or whatever you set your first item to on the web dashboard)
GameFuseUser.CurrentUser.AddCredits(50, function(message,hasError){self.AddCreditsCallback(message,hasError)});
}
AddCreditsCallback(message, hasError)
{
if (hasError)
{
console.log("Error adding credits: " + message);
}
else
{
let self = this;
console.log(GameFuseUser.CurrentUser.getCredits(); // Prints 50
GameFuseUser.PurchaseStoreItem(GameFuse.GetStoreItems()[0], function(message,hasError){self.PurchasedItemCallback(message,hasError)})
}
}
PurchasedItemCallback(message, hasError) {
if (hasError)
{
console.log("Error purchasing item: "+message);
}
else
{
console.log("Purchased Item");
console.log("Current Credits: " + GameFuseUser.CurrentUser.GetCredits());
}
}
* 400 - Please include a credits param
* 500 - unknown server error
Credits are a numeric attribute of each game user. It is a simple integer value. You can add them manually and they are detracted automatically upon store item purchases. You can manually add and remove them via an API call, in addition to purchasing store items with them.
To alter the amount of credits a users has relativly, use:
https://gamefuse.co/api/v2/users/{signed in user id}/add_credits?credits={credits to add}
It will have the following Headers:
authentication_token: {found in sign_in or sign_up response, authentication token for user session}
It will have the following URL parameters:
credits: {the amount of credits positive or negative you want to alter the users current credits by}
This will return a response with the following json. It has users remaining credits, and a list of all their purchased store items
{
"id": {users id},
"username": {users display username},
"email": {system email - a combination of game id and email},
"display_email": {users actual email, used for notifications and login}
"credits": {number of credits user has, these can be used in your in game store},
"score": {a generic score metric that you can use},
"last_login": {timestamp of last login},
"number_of_logins": {total logins},
"authentication_token": {authentication token, this must be saved and added as a parameter to all authenticated requests},
"events_total": {running api hits for this user},
"events_current_month": {running api hits for this user for this month},
"game_sessions_total": {unique game session for this user},
"game_sessions_current_month": {unique game session for this user for this month}
}
* 400 - Please include a credits param
* 500 - unknown server error
To set the amount of credits a users has absolutly, meaning the credits param will be the users new credits total, use:
https://gamefuse.co/api/v2/users/{signed in user id}/set_credits?credits={credits to add}
It will have the following Headers:
authentication_token: {found in sign_in or sign_up response, authentication token for user session}
It will have the following URL parameters:
credits: {the amount of credits a user will now have}
This will return a response with the following json:
{
"id": {users id},
"username": {users display username},
"email": {system email - a combination of game id and email},
"display_email": {users actual email, used for notifications and login}
"credits": {number of credits user has, these can be used in your in game store},
"score": {a generic score metric that you can use},
"last_login": {timestamp of last login},
"number_of_logins": {total logins},
"authentication_token": {authentication token, this must be saved and added as a parameter to all authenticated requests},
"events_total": {running api hits for this user},
"events_current_month": {running api hits for this user for this month},
"game_sessions_total": {unique game session for this user},
"game_sessions_current_month": {unique game session for this user for this month}
}
* 400 - Please include a credits param
* 500 - unknown server error
Custom user data or Key Value pairs are a simple way to save any kind of data for a particular user. Some examples might be {"world_2_unlocked":"true"}, {"player_color","red"}, {"favorite_food","Onion"} These are downloaded to your system upon login, and synced when one is updated. You can access with GameFuseUser.CurrentUser.attributes
All values and keys must be strings. If you want to use other data structures like arrays, you could stringify the array on save, and convert the saved string to an array on load:
void Start(){
Debug.Log(GameFuseUser.CurrentUser.attributes.Count); // Prints 0
Debug.Log(GameFuseUser.CurrentUser.GetAttributeValue("CURRENT_LEVEL") == null); // Prints true
GameFuseUser.CurrentUser.SetAttribute("CURRENT_LEVEL", "5", SetAttributeCallback);
}
void SetAttributeCallback(string message, bool hasError) {
if (hasError)
{
Debug.Log("Error setting attribute: "+message);
}
else
{
Debug.Log(GameFuseUser.CurrentUser.GetAttributeValue("CURRENT_LEVEL")); // Prints "5"
}
}
You can also batch update a custom dictionary of key value pairs like this, or set local attributes then sync them all at once later. Dirty Attributes can be checked at any time to see which keys are not synced with the database.
void Start(){
Debug.Log(GameFuseUser.CurrentUser.attributes.Count); // Prints 0
Dictionary < string, string > attributesToUpdate = new Dictionary < string, string >
{
{ "POINTS", "1000" },
{ "LEVEL", "5" },
{ "CHARACTER", "Ninja" }
};
GameFuseUser.CurrentUser.SetAttributes(attributesToUpdate, SetAttributesCallback);
}
void SetAttributesCallback(string message, bool hasError) {
if (hasError)
{
Debug.Log("Error setting attribute: "+message);
}
else
{
Debug.Log("Batch update complete");
Debug.Log(GameFuseUser.CurrentUser.GetAttributeValue("POINTS")); // Prints "1000"
Debug.Log(GameFuseUser.CurrentUser.GetAttributeValue("LEVEL")); // Prints "5"
GameFuseUser.CurrentUser.SetAttributeLocal("POINTS", "2000"); //will set locally but not sync with db
GameFuseUser.CurrentUser.SetAttributeLocal("LEVEL", "6"); //will set locally but not sync with db
Debug.Log("Dirty Vars"); //will print variables changed locally
foreach (var attribute in GameFuseUser.CurrentUser.GetDirtyAttributes()){
Debug.Log(attribute.Key+": "+attribute.Value);
}
GameFuseUser.CurrentUser.SyncLocalAttributes(AttributesSynced); //will update "SCORE" + "LEVEL"
}
}
void AttributesSynced(string message, bool hasError){
if (hasError)
{
Debug.Log("Error syncing attributes: "+message);
}
else
{
Debug.Log("Sync Success");
Debug.Log("Dirty Vars"); //will be empty now that sync is done
foreach (var attribute in GameFuseUser.CurrentUser.GetDirtyAttributes()){
Debug.Log(attribute.Key+": "+attribute.Value);
}
}
}
* 400 - each attribute a 'key' and 'value' parameter
* 400 - missing or invalid parameters
* 500 - unknown server error
Custom user data or Key Value pairs are a simple way to save any kind of data for a particular user. Some examples might be {"world_2_unlocked":"true"}, {"player_color","red"}, {"favorite_food","Onion"} These will fetched to your system after calling 'FetchAttributes()'.
All values and keys must be strings. If you want to use other data structures like arrays, you could stringify the array on save, and convert the saved string to an array on load:
void UMyObject::FetchAttributes()
{
FUserCallback CompletionCallback;
CompletionCallback.BindDynamic(this, &UMyObject::OnAttributesFetchedCallback);
UGameFuseUser* GameFuseUser = GEtgaMeinstance()->getsubsysTEm < uGameFuseuser > ();
GameFuseUser->FetchAttributes(false, CompletionCallback);
}
void UMyObject::OnAttributesFetchedCallback(bool bSuccess, const FString& Response)
{
if(bSuccess)
{
UE_LOG(LogTemp, Display, TEXT("Game Connected Successfully"));
UE_LOG(LogTemp, Display, TEXT("Result : %s"), *Response);
UGameFuseUser* GameFuseUser = GEtgaMeinstance()->getsubsysTEm < uGameFuseuser > ();
TMap Attributes = GameFuseUser->GetAttributes();
}else
{
UE_LOG(LogTemp, Error, TEXT("Error connecting game"));
UE_LOG(LogTemp, Error, TEXT("Result : %s"), *Response);
}
}
void UMyObject::AddAttributes()
{
FUserCallback CompletionCallback;
CompletionCallback.BindDynamic(this, &UMyObject::OnAttributesFetchedCallback);
UGameFuseUser* GameFuseUser = GEtgaMeinstance()->getsubsysTEm < uGameFuseuser > ();
GameFuseUser->SetAttribute("CURRENT_LEVEL", "5", CompletionCallback);
}
void UMyObject::OnAttributesAddedCallback(bool bSuccess, const FString& Response)
{
if(bSuccess)
{
UE_LOG(LogTemp, Display, TEXT("Game Connected Successfully"));
UE_LOG(LogTemp, Display, TEXT("Result : %s"), *Response);
}else
{
UE_LOG(LogTemp, Error, TEXT("Error connecting game"));
UE_LOG(LogTemp, Error, TEXT("Result : %s"), *Response);
}
}
* 400 - each attribute a 'key' and 'value' parameter
* 400 - missing or invalid parameters
* 500 - unknown server error
Custom user data or Key Value pairs are a simple way to save any kind of data for a particular user. Some examples might be {"world_2_unlocked":"true"}, {"player_color","red"}, {"favorite_food","Onion"}. These are downloaded to your system upon login, and synced when one is updated. You can access with Get Attributes node like this:
All values and keys must be strings. If you want to use other data structures like arrays, you could stringify the array on save, and convert the saved string to an array on load:
Custom user data or Key Value pairs are a simple way to save any kind of data for a particular user. Some examples might be {"world_2_unlocked":"true"}, {"player_color","red"}, {"favorite_food","Onion"} These are downloaded to your system upon login, and synced when one is updated. You can access with GameFuseUser.CurrentUser.attributes
All values and keys must be strings. If you want to use other data structures like arrays, you could stringify the array on save, and convert the saved string to an array on load.Start(){
let self = this;
console.log(GameFuseUser.CurrentUser.attributes.length); // Prints 0
console.log(GameFuseUser.CurrentUser.GetAttributeValue("CURRENT_LEVEL") == null); // Prints true
GameFuseUser.CurrentUser.SetAttribute("CURRENT_LEVEL", "5", function(message,hasError){self.SetAttributeCallback(message,hasError)});
}
SetAttributeCallback(message, hasError) {
if (hasError)
{
console.log("Error setting attribute: "+message);
}
else
{
console.log(GameFuseUser.CurrentUser.GetAttributeValue("CURRENT_LEVEL")); // Prints "5"
}
}
ou can also batch update a custom dictionary of key value pairs like this, or set local attributes then sync them all at once later. Dirty Attributes can be checked at any time to see which keys are not synced with the database.
Start(){
console.log(GameFuseUser.CurrentUser.attributes.Count); // Prints 0
attributesToUpdate = {{ "POINTS": "1000" },{ "LEVEL": "5" },{ "CHARACTER": "Ninja" }};
GameFuseUser.CurrentUser.setAttributes(attributesToUpdate, function(message,hasError){self.setAttributesCallback(message,hasError)});
}
setAttributesCallback(message, hasError) {
if (hasError)
{
console.log("Error setting attribute: "+message);
}
else
{
console.log("Batch update complete");
console.log(GameFuseUser.CurrentUser.getAttributeValue("POINTS")); // Prints "1000"
console.log(GameFuseUser.CurrentUser.getAttributeValue("LEVEL")); // Prints "5"
GameFuseUser.CurrentUser.setAttributeLocal("POINTS", "2000"); //will set locally but not sync with db
GameFuseUser.CurrentUser.setAttributeLocal("LEVEL", "6"); //will set locally but not sync with db
console.log("Dirty Vars"); //will print variables changed locally
console.log(GameFuseUser.CurrentUser.getDirtyAttributes());
GameFuseUser.CurrentUser.syncLocalAttributes(function(message,hasError){self.attributesSynced(message,hasError)}); //will update "SCORE" + "LEVEL"
}
}
attributesSynced(message, hasError){
if (hasError)
{
console.log("Error syncing attributes: "+message);
}
else
{
console.log("Sync Success");
console.log("Dirty Vars"); //will be empty now that sync is done
console.log(GameFuseUser.CurrentUser.getDirtyAttributes());
}
}
* 400 - each attribute a 'key' and 'value' parameter
* 400 - missing or invalid parameters
* 500 - unknown server error
User data can be set in a number of ways. Score can be set with a specific API call to set or relativly add to score. You can also set custom user data where you can assign any key to any value. Whether you use it for a players "current_level", "color", "XP" or anything else you can think of, it can be done with the custom data.
To alter the amount of scores a users has relativly, use:
https://gamefuse.co/api/v2/users/{signed in user id}/add_scores?&scores={scores to add}
It will have the following Headers:
authentication_token: {found in sign_in or sign_up response, authentication token for user session}
It will have the following URL parameters:
scores: {the amount of scores positive or negative you want to alter the users current scores by}
This will return a response with the following json. It has users remaining scores, and a list of all their purchased store items
{
"id": {users id},
"username": {users display username},
"email": {system email - a combination of game id and email},
"display_email": {users actual email, used for notifications and login}
"credits": {number of credits user has, these can be used in your in game store},
"score": {a generic score metric that you can use},
"last_login": {timestamp of last login},
"number_of_logins": {total logins},
"authentication_token": {authentication token, this must be saved and added as a parameter to all authenticated requests},
"events_total": {running api hits for this user},
"events_current_month": {running api hits for this user for this month},
"game_sessions_total": {unique game session for this user},
"game_sessions_current_month": {unique game session for this user for this month}
}
* 400 - Please include a score param
* 500 - unknown server error
To set the amount of scores a users has absolutly, meaning the scores param will be the users new scores total, use:
https://gamefuse.co/api/v2/users/{signed in user id}/set_scores?&scores={scores to add}
It will have the following Headers:
authentication_token: {found in sign_in or sign_up response, authentication token for user session}
It will have the following URL parameters:
scores: {the amount of scores a user will now have}
This will return a response with the following json:
{
"id": {users id},
"username": {users display username},
"email": {system email - a combination of game id and email},
"display_email": {users actual email, used for notifications and login}
"credits": {number of credits user has, these can be used in your in game store},
"score": {a generic score metric that you can use},
"last_login": {timestamp of last login},
"number_of_logins": {total logins},
"authentication_token": {authentication token, this must be saved and added as a parameter to all authenticated requests},
"events_total": {running api hits for this user},
"events_current_month": {running api hits for this user for this month},
"game_sessions_total": {unique game session for this user},
"game_sessions_current_month": {unique game session for this user for this month}
}
* 400 - Please include a score param
* 500 - unknown server error
Set any key to any value. It will be in a string format but can be converted in your programs language to any type.
https://gamefuse.co/api/v2/users/{signed in user id}/add_game_user_attribute?&key={key to add}&value={value to add}&attributes={json of attributes defined below}
It will have the following Headers:
authentication_token: {found in sign_in or sign_up response, authentication token for user session}
It will have the following URL parameters:
key: {the key of the datum you are trying to save}
value: {the value of the datum you are trying to save}
attributes: {json of the format [{"key": key1, "value": value1}, {"key": key2, "value":value2}...] for batch updating }
This will return a response containing all the users attributes (custom data) with the following json:
{
"game_user_attributes": [
{
"id": {id of first attribute},
"key": {key of first attribute},
"value": {value of first attribute}
},
{
"id": {id of second attribute},
"key": {key of second attribute},
"value": {value of second attribute}
},
...
]
}
* 400 - each attribute a 'key' and 'value' parameter
* 400 - missing or invalid parameters
* 500 - unknown server error
remove any key and its value
https://gamefuse.co/api/v2/users/{signed in user id}/remove_game_user_attributes?&key={key to add}
It will have the following Headers:
authentication_token: {found in sign_in or sign_up response, authentication token for user session}
It will have the following URL parameters:
key: {the key of the datum you are trying to remove}
This will return a response containing all the users attributes (custom data) with the following json:
{
"game_user_attributes": [
{
"id": {id of first attribute},
"key": {key of first attribute},
"value": {value of first attribute}
},
{
"id": {id of second attribute},
"key": {key of second attribute},
"value": {value of second attribute}
},
...
]
}
* 400 - User does not have item with specified key
* 500 - unknown server error
Get a list of all the signed in users custom attributes
https://gamefuse.co/api/v2/users/{signed in user id}/game_user_attributes?
It will have the following Headers:
authentication_token: {found in sign_in or sign_up response, authentication token for user session}
This will return a response containing all the users attributes (custom data) with the following json:
{
"game_user_attributes": [
{
"id": {id of first attribute},
"key": {key of first attribute},
"value": {value of first attribute}
},
{
"id": {id of second attribute},
"key": {key of second attribute},
"value": {value of second attribute}
},
...
]
}
* 500 - unknown server error
Leaderboards can be easily created within GameFuse From the Unity game client, a Leaderboard Entry can be added with a leaderboard_name, score, and extra_attributes (metadata) for the current signed in user Leaderboards can be downloaded for a specific leaderboard_name, which would gather all the high scores in order for all users in the game or Leaderboards can be downloaded for a specific user, so that you can download the current users leaderboard data for all leaderboard_names. The below example shows submitting 2 leaderboard entries, then retrieving them for the game, and for the current user
void Start(){
var extraAttributes = new Dictionary < string, string > ();
extraAttributes.Add("deaths", "15");
extraAttributes.Add("Jewels", "12");
GameFuseUser.CurrentUser.AddLeaderboardEntry("Game1Leaderboard",10, extraAttributes, LeaderboardEntryAdded);
}
void LeaderboardEntryAdded(string message, bool hasError)
{
if (hasError)
{
print("Error adding leaderboard entry: " + message);
}
else
{
print("Set Leaderboard Entry 2");
var extraAttributes = new Dictionary < string, string > ();
extraAttributes.Add("deaths", "25");
extraAttributes.Add("Jewels", "15");
GameFuseUser.CurrentUser.AddLeaderboardEntry("Game1Leaderboard", 7, extraAttributes, LeaderboardEntryAdded2);
}
}
void LeaderboardEntryAdded2(string message, bool hasError)
{
if (hasError)
{
print("Error adding leaderboard entry 2: " + message);
}
else
{
print("Set Leaderboard Entry 2");
GameFuseUser.CurrentUser.GetLeaderboard(5, true, LeaderboardEntriesRetrieved);
}
}
void LeaderboardEntriesRetrieved(string message, bool hasError)
{
if (hasError)
{
print("Error loading leaderboard entries: " + message);
}
else
{
print("Got leaderboard entries for specific user!");
foreach( GameFuseLeaderboardEntry entry in GameFuse.Instance.leaderboardEntries)
{
print(entry.GetUsername() + ": " + entry.GetScore().ToString() + ": " + entry.GetLeaderboardName() );
foreach (KeyValuePair < string,string > kvPair in entry.GetExtraAttributes())
{
print(kvPair.Key + ": " + kvPair.Value);
}
}
GameFuse.Instance.GetLeaderboard(5, true, "Game1Leaderboard", LeaderboardEntriesRetrievedAll);
}
}
void LeaderboardEntriesRetrievedAll(string message, bool hasError)
{
if (hasError)
{
print("Error loading leaderboard entries: " + message);
}
else
{
print("Got leaderboard entries for whole game!");
foreach (GameFuseLeaderboardEntry entry in GameFuse.Instance.leaderboardEntries)
{
print(entry.GetUsername() + ": " + entry.GetScore().ToString() + ": " + entry.GetLeaderboardName());
foreach (KeyValuePair < string, string > kvPair in entry.GetExtraAttributes())
{
print(kvPair.Key + ": " + kvPair.Value);
}
}
}
}
You can also clear all leaderboard entries for a particular leaderboard_name for the current user like this:
void Start(){
var extraAttributes = new Dictionary < string, string > ();
extraAttributes.Add("deaths", "15");
extraAttributes.Add("Jewels", "12");
GameFuseUser.CurrentUser.AddLeaderboardEntry("Game2Leaderboard",10, extraAttributes, LeaderboardEntryAdded);
}
void LeaderboardEntryAdded(string message, bool hasError)
{
if (hasError)
{
print("Error adding leaderboard entry: " + message);
}
else
{
print("Clear Leaderboard Entry 2");
GameFuseUser.CurrentUser.ClearLeaderboardEntries("Game2Leaderboard", LeaderboardEntryCleared);
}
}
void LeaderboardEntryCleared(string message, bool hasError)
{
if (hasError)
{
print("Error adding leaderboard entry: " + message);
}
else
{
print("User will no longer have leaderboard entries for 'Game2Leaderboard'");
}
}
# GameFuseUser.CurrentUser.AddLeaderboardEntry
* 401 - "can only add entries for current user"
* 400 - "invalid extra attributes"
* 500 - unknown server error
# GameFuseUser.CurrentUser.GetLeaderboard
* 401 - "can only get entries for current user"
* 500 - unknown server error
# GameFuse.Instance.GetLeaderboard
* 404 - No entries for this leaderboard name ___
* 500 - unknown server error
# GameFuseUser.CurrentUser.ClearLeaderboardEntries
* 401 - "can only clear entries for current user"
* 500 - unknown server error
Leaderboards can be easily created within GameFuse From the Unreal Engine game client, a Leaderboard Entry can be added with a leaderboard_name, score, and extra_attributes (metadata) for the current signed in user Leaderboards can be downloaded for a specific leaderboard_name, which would gather all the high scores in order for all users in the game or Leaderboards can be downloaded for a specific user, so that you can download the current users leaderboard data for all leaderboard_names. The below example shows submitting 2 leaderboard entries, then retrieving them for the game, and for the current user
void UMyObject::AddLeaderboard()
{
FUserCallback CompletionCallback;
CompletionCallback.BindDynamic(this, &UMyObject::OnAttributesFetchedCallback);
UGameFuseUser* GameFuseUser = GEtgaMeinstance()->getsubsysTEm < uGameFuseuser > ();
TMap < FString, FString > ExtraAttributes;
ExtraAttributes.Add("deaths","15");
ExtraAttributes.Add("Jewels","12");
GameFuseUser->AddLeaderboardEntryWithAttributes("leaderboard_name", GameFuseUser->GetScore(), ExtraAttributes, CompletionCallback);
// Adding Leaderboard without extra attributes
//GameFuseUser->AddLeaderboardEntry("leaderboard_name", GameFuseUser->GetScore(), CompletionCallback);
}
void UMyObject::OnLeaderboardAddedCallback(bool bSuccess, const FString& Response)
{
if(bSuccess)
{
UE_LOG(LogTemp, Display, TEXT("Game Connected Successfully"));
UE_LOG(LogTemp, Display, TEXT("Result : %s"), *Response);
}else
{
UE_LOG(LogTemp, Error, TEXT("Error connecting game"));
UE_LOG(LogTemp, Error, TEXT("Result : %s"), *Response);
}
}
void UMyObject::GetMyLeaderboards()
{
FUserCallback CompletionCallback;
CompletionCallback.BindDynamic(this, &UMyObject::OnMyLeaderboardsFetchedCallback);
UGameFuseUser* GameFuseUser = GEtgaMeinstance()->getsubsysTEm < uGameFuseuser > ();
GameFuseUser->FetchMyLeaderboardEntries(12, false, CompletionCallback);
}
void UMyObject::OnMyLeaderboardsFetchedCallback(bool bSuccess, const FString& Response)
{
if(bSuccess)
{
UE_LOG(LogTemp, Display, TEXT("Game Connected Successfully"));
UE_LOG(LogTemp, Display, TEXT("Result : %s"), *Response);
UGameFuseUser* GameFuseUser = GEtgaMeinstance()->getsubsysTEm < uGameFuseuser > ();
TArray < UGameFuseLeaderboardEntry* > MyLeaderboards = GameFuseUser->GetLeaderboards();
}else
{
UE_LOG(LogTemp, Error, TEXT("Error connecting game"));
UE_LOG(LogTemp, Error, TEXT("Result : %s"), *Response);
}
}
void UMyObject::GetLeaderboards()
{
FManagerCallback CompletionCallback;
CompletionCallback.BindDynamic(this, &UMyObject::OnLeaderboardsFetchedCallback);
UGameFuseUser* GameFuseUser = GEtgaMeinstance()->getsubsysTEm < uGameFuseuser > ();
UGameFuseManager::FetchLeaderboardEntries(GameFuseUser, 15, false, "leaderboard_name", CompletionCallback);
}
void UMyObject::OnLeaderboardsFetchedCallback(bool bSuccess, const FString& Response)
{
if(bSuccess)
{
UE_LOG(LogTemp, Display, TEXT("Game Connected Successfully"));
UE_LOG(LogTemp, Display, TEXT("Result : %s"), *Response);
TArray < UGameFuseLeaderboardEntry* > Leaderboards = UGameFuseManager::GetLeaderboard();
}else
{
UE_LOG(LogTemp, Error, TEXT("Error connecting game"));
UE_LOG(LogTemp, Error, TEXT("Result : %s"), *Response);
}
}
You can also clear all leaderboard entries for a particular leaderboard_name for the current user like this:
void UMyObject::ClearMyLeaderboards()
{
FUserCallback CompletionCallback;
CompletionCallback.BindDynamic(this, &UMyObject::OnMyLeaderboardsClearedCallback);
UGameFuseUser* GameFuseUser = GEtgaMeinstance()->getsubsysTEm < uGameFuseuser > ();
GameFuseUser->ClearLeaderboardEntry("leaderboard_name", CompletionCallback);
}
void UMyObject::OnMyLeaderboardsClearedCallback(bool bSuccess, const FString& Response)
{
if(bSuccess)
{
UE_LOG(LogTemp, Display, TEXT("Game Connected Successfully"));
UE_LOG(LogTemp, Display, TEXT("Result : %s"), *Response);
}else
{
UE_LOG(LogTemp, Error, TEXT("Error connecting game"));
UE_LOG(LogTemp, Error, TEXT("Result : %s"), *Response);
}
}
# GameFuseUser->AddLeaderboardEntryWithAttributes
* 401 - "can only add entries for current user"
* 400 - "invalid extra attributes"
* 500 - unknown server error
# GameFuseUser->GetLeaderboards
* 401 - "can only get entries for current user"
* 500 - unknown server error
# UGameFuseManager::GetLeaderboard
* 404 - No entries for this leaderboard name ___
* 500 - unknown server error
# GameFuseUser->ClearLeaderboardEntry
* 401 - "can only clear entries for current user"
* 500 - unknown server error
Leaderboards can be easily created within GameFuse. From the Unreal Engine game client, you can use the "Add Leaderboard Entry" node to add a score to a leaderboard with a specified name. Alternatively, you can utilize the "Add Leaderboard Entry With Attributes" node to add a score, along with extra attributes (metadata), to a leaderboard with a specific name.
Leaderboards can be fetched in two ways: for a specific "Your Leaderboard Name," which gathers all the high scores for all users in the game, or for a specific user. In the latter case, you can download the current user's leaderboard data for all instances of "Your Leaderboard Name."
You can also clear all leaderboard entries for a particular "Your Leaderboard Name" for the current user like this:
Leaderboards can be easily created within GameFuse From any JS game client, a Leaderboard Entry can be added with a leaderboard_name, score, and extra_attributes (metadata) for the current signed in user Leaderboards can be downloaded for a specific leaderboard_name, which would gather all the high scores in order for all users in the game or Leaderboards can be downloaded for a specific user, so that you can download the current users leaderboard data for all leaderboard_names The below example shows submitting 2 leaderboard entries, then retrieving them for the game, and for the current user
Start(){
let self = this
var extraAttributes = {};
extraAttributes["deaths"] = "15";
extraAttributes["Jewels"] = "12";
GameFuseUser.CurrentUser.AddLeaderboardEntry("Game1Leaderboard",10, extraAttributes, function(message,hasError){self.LeaderboardEntryAdded(message,hasError)});
}
LeaderboardEntryAdded(message, hasError)
{
let self = this;
if (hasError)
{
print("Error adding leaderboard entry: " + message);
}
else
{
print("Set Leaderboard Entry 2");
var extraAttributes = {};
extraAttributes.["deaths"] = "25";
extraAttributes.["Jewels"] = "15";
GameFuseUser.CurrentUser.AddLeaderboardEntry("Game1Leaderboard", 7, extraAttributes, function(message,hasError){self.LeaderboardEntryAdded2(message,hasError)});
}
}
LeaderboardEntryAdded2(message, hasError)
{
let self = this;
if (hasError)
{
print("Error adding leaderboard entry 2: " + message);
}
else
{
print("Set Leaderboard Entry 2");
GameFuseUser.CurrentUser.GetLeaderboard(5, true, function(message,hasError){self.LeaderboardEntriesRetrieved(message,hasError)});
}
}
LeaderboardEntriesRetrieved(message, hasError)
{
if (hasError)
{
print("Error loading leaderboard entries: " + message);
}
else
{
let self = this;
print("Got leaderboard entries for specific user!");
for (const entry of GameFuse.Instance.leaderboardEntries) {
console.log(entry.getUsername() + ": " + entry.getScore().toString() + ": " + entry.getLeaderboardName());
const extraAttributes = entry.getExtraAttributes();
for (const key in extraAttributes) {
console.log(key + ": " + extraAttributes[key]);
}
}
GameFuse.Instance.GetLeaderboard(5, true, "Game1Leaderboard", function(message,hasError){self.LeaderboardEntriesRetrievedAll(message,hasError)});
}
}
LeaderboardEntriesRetrievedAll(message, hasError)
{
if (hasError)
{
print("Error loading leaderboard entries: " + message);
}
else
{
let self = this;
print("Got leaderboard entries for whole game!");
for (const entry of GameFuse.Instance.leaderboardEntries) {
console.log(entry.getUsername() + ": " + entry.getScore().toString() + ": " + entry.getLeaderboardName());
const extraAttributes = entry.getExtraAttributes();
for (const key in extraAttributes) {
console.log(key + ": " + extraAttributes[key]);
}
}
}
}
You can also clear all leaderboard entries for a particular leaderboard_name for the current user like this:
Start(){
let self = this;
var extraAttributes = {};
extraAttributes["deaths"] = "15";
extraAttributes["Jewels"] = "12";
GameFuseUser.CurrentUser.AddLeaderboardEntry("Game2Leaderboard",10, extraAttributes, function(message,hasError){self.LeaderboardEntryAdded(message,hasError)});
}
LeaderboardEntryAdded(message, hasError)
{
let self = this;
if (hasError)
{
print("Error adding leaderboard entry: " + message);
}
else
{
print("Clear Leaderboard Entry 2");
GameFuseUser.CurrentUser.ClearLeaderboardEntries("Game2Leaderboard", function(message,hasError){self.LeaderboardEntryCleared(message,hasError)});
}
}
LeaderboardEntryCleared(message, hasError)
{
if (hasError)
{
print("Error adding leaderboard entry: " + message);
}
else
{
print("User will no longer have leaderboard entries for 'Game2Leaderboard'");
}
}
# GameFuseUser.CurrentUser.AddLeaderboardEntry
* 401 - "can only add entries for current user"
* 400 - "invalid extra attributes"
* 500 - unknown server error
# GameFuseUser.CurrentUser.GetLeaderboard
* 401 - "can only get entries for current user"
* 500 - unknown server error
# GameFuse.Instance.GetLeaderboard
* 404 - No entries for this leaderboard name ___
* 500 - unknown server error
# GameFuseUser.CurrentUser.ClearLeaderboardEntries
* 401 - "can only clear entries for current user"
* 500 - unknown server error
TLeaderboards can be easily created within GameFuse From your JS game client, a Leaderboard Entry can be added with a leaderboard_name, score, and extra_attributes (metadata) for the current signed in user Leaderboards can be downloaded for a specific leaderboard_name, which would gather all the high scores in order for all users in the game or Leaderboards can be downloaded for a specific user, so that you can download the current users leaderboard data for all leaderboard_names
Add a leaderboard entry to a specific leaderboard within your game designated by 'leaderboard_name', these can be pulled later and compared to other users.
https://gamefuse.co/api/v2/users/{user id}/add_leaderboard_entry?score={score for the leaderboard}&leaderboard_name={leaderboard name}&extra_attributes={hash of extra data to save to the leaderboard entry}
It will have the following URL parameters:
score: {score for the leaderboard}
leaderboard_name: {leaderboard name within game}
extra_attributes: {hash of custom data}
This will return a response containing all the users attributes (custom data) with the following json:
{
"id": {users id},
"username": {users display username},
"email": {system email - a combination of game id and email},
"display_email": {users actual email, used for notifications and login}
"credits": {number of credits user has, these can be used in your in game store},
"score": {a generic score metric that you can use},
"last_login": {timestamp of last login},
"number_of_logins": {total logins},
"authentication_token": {authentication token, this must be saved and added as a parameter to all authenticated requests},
"events_total": {running api hits for this user},
"events_current_month": {running api hits for this user for this month},
"game_sessions_total": {unique game session for this user},
"game_sessions_current_month": {unique game session for this user for this month}
}
* 401 - "can only add entries for current user"
* 400 - "invalid extra attributes"
* 500 - unknown server error
Clear all leaderboard entries for a specific user.
https://gamefuse.co/api/v2/users/{user id}/clear_my_leaderboard_entries?
It will have the following Headers:
authentication_token: {found in sign_in or sign_up response, authentication token for user session}
This will return a response containing all the users attributes (custom data) with the following json:
{
"id": {users id},
"username": {users display username},
"email": {system email - a combination of game id and email},
"display_email": {users actual email, used for notifications and login}
"credits": {number of credits user has, these can be used in your in game store},
"score": {a generic score metric that you can use},
"last_login": {timestamp of last login},
"number_of_logins": {total logins},
"authentication_token": {authentication token, this must be saved and added as a parameter to all authenticated requests},
"events_total": {running api hits for this user},
"events_current_month": {running api hits for this user for this month},
"game_sessions_total": {unique game session for this user},
"game_sessions_current_month": {unique game session for this user for this month}
}
* 401 - "can only clear entries for current user"
* 500 - unknown server error
Get all leaderboard entries for a specific leaderboard name. You may have multiple leaderboards in your game, indicated by "leaderboard name"
https://gamefuse.co/api/v2/games/1/leaderboard_entries?leaderboard_name={leaderboard name}
It will have the following Headers:
authentication_token: {found in sign_in or sign_up response, authentication token for user session}
It will have the following URL parameters:
leaderboard_name: {name of the leaderboard within the game}
This will return a response containing all the users attributes (custom data) with the following json:
{
"leaderboard_entries": [
{
"username": value,
"score": value,
"leaderboard_name": value,
"game_user_id": value,
"extra_attributes": value,
},
{
"username": value,
"score": value,
"leaderboard_name": value,
"game_user_id": value,
"extra_attributes": value
},
...
]
}
* 404 - No entries for this leaderboard name ___
* 500 - unknown server error
Get all leaderboard entries for a specific user.
https://gamefuse.co/api/v2/users/{user id}/leaderboard_entries?
It will have the following Headers:
authentication_token: {found in sign_in or sign_up response, authentication token for user session}
This will return a response containing all the users attributes (custom data) with the following json:
{
"leaderboard_entries": [
{
"username": value,
"score": value,
"leaderboard_name": value,
"game_user_id": value,
"extra_attributes": value
},
{
"username": value,
"score": value,
"leaderboard_name": value,
"game_user_id": value,
"extra_attributes": value
},
...
]
}
* 401 - "can only get entries for current user"
* 500 - unknown server hasError
You can implement this simple method in your app and we will handle all the emails and password reset on our end. Once you hit this function, our system will send an email to that user if they exist, branded like your app. It will have your app's name, image logo and color so it will look cohesive. The sender email is even masked with your apps name. The user will reset their password online and then will be instructed that they can login to your app.
void Start(){
GameFuseUser.Instance.SendPasswordResetEmail("example@gmail.com", ForgotPasswordEmailSent);
}
void ForgotPasswordEmailSent(string message, bool hasError) {
if (hasError)
{
Debug.Log("Error setting attribute: "+message);
}
else
{
Debug.Log(GameFuseUser.CurrentUser.GetAttributeValue("CURRENT_LEVEL")); // Prints "5"
}
}
* 404 - Game ID or Token incorrect
* 403 - Invalid Email Address
* 404 - No user found with email
* 500 - unknown server error
The user will then recieve an email looking like the following:
When the user clicks on the forgot password link they will see something like:
You can implement this simple method in your app and we will handle all the emails and password reset on our end. Once you hit this function, our system will send an email to that user if they exist, branded like your app. It will have your app's name, image logo and color so it will look cohesive. The sender email is even masked with your apps name. The user will reset their password online and then will be instructed that they can login to your app.
void UMyObject::ResetUserPassword()
{
FManagerCallback CompletionCallback;
CompletionCallback.BindDynamic(this, &UMyObject::OnMyLeaderboardsClearedCallback);
UGameFuseManager::SendPasswordResetEmail("example@gmail.com", CompletionCallback);
}
void UMyObject::OnResetUserPasswordCallback(bool bSuccess, const FString& Response)
{
if(bSuccess)
{
UE_LOG(LogTemp, Display, TEXT("Game Connected Successfully"));
UE_LOG(LogTemp, Display, TEXT("Result : %s"), *Response);
}else
{
UE_LOG(LogTemp, Error, TEXT("Error connecting game"));
UE_LOG(LogTemp, Error, TEXT("Result : %s"), *Response);
}
}
* 404 - Game ID or Token incorrect
* 403 - Invalid Email Address
* 404 - No user found with email
* 500 - unknown server error
The user will then recieve an email looking like the following:
When the user clicks on the forgot password link they will see something like:
You can implement this simple method in your app, and we will handle all the emails and password reset on our end. Once you hit this node, our system will send an email to that user if they exist, branded like your app. It will have your app's name, image logo, and color so it will look cohesive. The sender email is even masked with your app's name. The user will reset their password online and then will be instructed that they can log in to your app.
The user will then receive an email looking like the following:
When the user clicks on the forgot password link, they will see something like:
You can implement this simple method in your app and we will handle all the emails and password reset on our end. Once you hit this function, our system will send an email to that user if they exist, branded like your app. It will have your app's name, image logo and color so it will look cohesive. The sender email is even masked with your apps name. The user will reset their password online and then will be instructed that they can login to your app.
Start(){
let self = this;
GameFuse.sendPasswordResetEmail("example@gmail.com, function (message, hasError) {
if (hasError) {
alert("Something went wrong...");
}
else {
alert("A link to reset your password has been sent to your email!");
}
});
}
* 404 - Game ID or Token incorrect
* 403 - Invalid Email Address
* 404 - No user found with email
* 500 - unknown server error
The user will then recieve an email looking like the following:
When the user clicks on the forgot password link they will see something like:
You can implement this simple method in your app and we will handle all the emails and password reset on our end. Once you hit this function, our system will send an email to that user if they exist, branded like your app. It will have your app's name, image logo and color so it will look cohesive. The sender email is even masked with your apps name. The user will reset their password online and then will be instructed that they can login to your app.
https://gamefuse.co/api/v1/games/{game_id}/forget_password?email={email}&game_id={game_id}&game_token={game_token}
It will have the following URL parameters:
game_id: {found on your GameFuse.co dashboard}
game_token: {API token found on your GameFuse.co dashboard}
email: {email address of user to send forgot password form to}
This will return a response containing all the users attributes (custom data) with the following json:
{
"mailer_response": {detail of the emailer},
"message": {message confirming email sent or with info that user does not exist}
}
* 404 - Game ID or Token incorrect
* 403 - Invalid Email Address
* 404 - No user found with email
* 500 - unknown server error
The user will then recieve an email looking like the following:
When the user clicks on the forgot password link they will see something like:
Check each model below for a list of methods and attributes.
###GameFuse.cs
your current signed in user can be retrieved with:
GameFuseUser user = GameFuse.CurrentUser;
public bool IsSignedIn();
public int GetNumberOfLogins();
public DateTime GetLastLogin();
public string GetUsername();
public int GetScore();
public int GetCredits();
public void AddCredits(int credits, Action < string, bool > callback = null);
public void SetCredits(int credits, Action < string, bool > callback = null);
public void AddScore(int credits, Action < string, bool > callback = null);
public void SetScore(int score, Action < string, bool > callback = null);
public Dictionary < string,string > GetAttributes();
public Dictionary < string,string > .KeyCollection GetAttributesKeys();
public string GetAttributeValue(string key);
public void SetAttribute(string key, string value, Action < string, bool > callback = null);
public void SetAttributeLocal(string key, string val);
public void SyncLocalAttributes(Action callback = null);
public void SetAttributes(Dictionary newAttributes, Action callback = null);
public Dictionary GetDirtyAttributes();
public void RemoveAttribute(string key, Action < string, bool > callback = null);
public List < GameFuseStoreItem > GetPurchasedStoreItems();
public void PurchaseStoreItem(GameFuseStoreItem storeItem, Action < string, bool > callback = null);
public void PurchaseStoreItem(int storeItemId, Action < string, bool > callback = null);
public void RemoveStoreItem(int storeItemID, bool reimburseUser, Action < string, bool > callback = null);
public void RemoveStoreItem(GameFuseStoreItem storeItem, bool reimburseUser, Action < string, bool > callback = null);
public void AddLeaderboardEntry(string leaderboardName, int score, Dictionary extraAttributes = null, Action < string, bool > callback = null);
public void AddLeaderboardEntry(string leaderboardName, int score, Action < string, bool > callback = null);
public void GetLeaderboard(int limit, bool onePerUser, Action < string, bool > callback = null); //Get all leaderboard entries for current signed in user
###GameFuse.cs
public static void SetUpGame(string gameId, string token, Action < string, bool > callback = null);
public static string GetGameId();
public static string GetGameName();
public static string GetGameDescription();
public static List < GameFuseStoreItem > GetStoreItems() //Gets all store items (your library)
public static void SignIn(string email, string password, Action < string, bool > callback = null);
public static void SignUp(string email, string password, string password_confirmation, string username, Action < string, bool > callback = null);
public void GetLeaderboard(int limit, bool onePerUser, string LeaderboardName, Action < string, bool > callback = null); //Retrieves leaderboard for one specific Leaderboard Name
public static void SendPasswordResetEmail(string email, Action < string, bool > callback = null);
public static void FetchGameVariables(string gameId, string token, Action < string, bool > callback = null)
public static string GetGameVariable(string key)
###GameFuseStoreItem.cs
public string GetName();
public string GetCategory();
public string GetDescription();
public int GetCost();
public int GetId();
public string GetIconUrl();
###GameFuseLeaderboardEntry.cs
public string GetUsername();
public int GetScore();
public string GetLeaderboardName();
public Dictionary GetExtraAttributes();
public DateTime GetTimestamp();
Check each model below for a list of methods and attributes.
// GameFuse Static Functions
UGameFuseManager::SetUpGame(const FString& InGameId, const FString& InToken, bool bSeedStore, FManagerCallback CompletionCallback);
UGameFuseManager::GetGameId();
UGameFuseManager::GetGameName();
UGameFuseManager::GetGameDescription();
UGameFuseManager::GetGameToken();
UGameFuseManager::GetBaseURL();
UGameFuseManager::GetGameVariables();
UGameFuseManager::GetGameStoreItems();
UGameFuseManager::GetLeaderboard();
UGameFuseManager::(const FString& Email, FManagerCallback CompletionCallback);
UGameFuseManager::FetchGameVariables(FManagerCallback CompletionCallback);
UGameFuseManager::FetchLeaderboardEntries(UGameFuseUser* GameFuseUser, const int Limit, bool bOnePerUser, const FString& LeaderboardName, FManagerCallback CompletionCallback);
UGameFuseManager::FetchStoreItems(FManagerCallback CompletionCallback);
// User Functions
UGameFuseUser* GameFuseUser = GEtgaMeinstance()->getsubsysTEm < uGameFuseuser > ();
GameFuseUser->GetNumberOfLogins();
GameFuseUser->GetLastLogin();
GameFuseUser->GetUsername();
GameFuseUser->GetScore();
GameFuseUser->GetCredits();
GameFuseUser->GetAttributes();
GameFuseUser->GetAttributesKeys();
GameFuseUser->GetAttributeValue(const FString Key);
GameFuseUser->GetPurchasedStoreItems();
GameFuseUser->GetLeaderboards();
GameFuseUser->SignUp(const FString& Email, const FString& Password, const FString& PasswordConfirmation, const FString& Username, FUserCallback CompletionCallback);
GameFuseUser->SignIn(const FString& Email, const FString& Password, FUserCallback CompletionCallback);
GameFuseUser->IsSignedIn() const;
GameFuseUser->AddCredits(const int AddCredits, FUserCallback CompletionCallback);
GameFuseUser->SetCredits(const int SetCredits, FUserCallback CompletionCallback);
GameFuseUser->AddScore(const int AddScore, FUserCallback CompletionCallback);
GameFuseUser->SetScore(const int SetScore, FUserCallback CompletionCallback);
GameFuseUser->SetAttribute(const FString& SetKey,const FString& SetValue, FUserCallback CompletionCallback);
GameFuseUser->RemoveAttribute(const FString& SetKey, FUserCallback CompletionCallback);
GameFuseUser->PurchaseStoreItemWithId(const int StoreItemId, FUserCallback CompletionCallback);
GameFuseUser->PurchaseStoreItem(const UGameFuseStoreItem* StoreItem, FUserCallback CompletionCallback);
GameFuseUser->RemoveStoreItemWithId(const int StoreItemId, FUserCallback CompletionCallback);
GameFuseUser->RemoveStoreItem(const UGameFuseStoreItem* StoreItem, FUserCallback CompletionCallback);
GameFuseUser->void AddLeaderboardEntry(const FString& LeaderboardName,const int OurScore, FUserCallback CompletionCallback);
GameFuseUser->AddLeaderboardEntryWithAttributes(const FString& LeaderboardName, const int OurScore, TMap ExtraAttributes, FUserCallback
CompletionCallback);
GameFuseUser->ClearLeaderboardEntry(const FString& LeaderboardName, FUserCallback CompletionCallback);
GameFuseUser->FetchMyLeaderboardEntries(const int Limit, bool bOnePerUser, FUserCallback CompletionCallback);
GameFuseUser->FetchAttributes(bool bChainedFromLogin, FUserCallback CompletionCallback);
GameFuseUser->FetchPurchaseStoreItems(bool bChainedFromLogin, FUserCallback CompletionCallback);
// GameFuseStoreItem.h
TArray < UGameFuseStoreItem* > StoreItems = GameFuseUser->GetPurchasedStoreItems();
StoreItems->GetName();
StoreItems->GetCategory();
StoreItems->GetDescription();
StoreItems->GetCost();
StoreItems->GetId();
StoreItems->GetIconUrl();
// GameFuseLeaderboardEntry.h
TArray < UGameFuseLeaderboardEntry* > Leaderboards = UGameFuseManager::GetLeaderboard();
Leaderboards->GetUsername();
Leaderboards->GetScore();
Leaderboards->GetLeaderboardName();
Leaderboards->GetExtraAttributes();
Leaderboards->GetTimestamp();
Check each model below for a list of nodes and attributes.
Check each model below for a list of methods and attributes.
###GameFuseUser.js
your current signed in user can be retrieved with:
gameFuseUser user = GameFuse.CurrentUser;
isSignedIn();
getNumberOfLogins();
getLastLogin();
getUsername();
getScore();
getCredits();
addCredits(int credits, Action < string, bool > callback = null);
setCredits(int credits, Action < string, bool > callback = null);
addScore(int credits, Action < string, bool > callback = null);
setScore(int score, Action < string, bool > callback = null);
getAttributes();
setAttribute(string key, string value, Action < string, bool > callback = null);
setAttributeLocal(string key, string val);
syncLocalAttributes(Action callback = null);
setAttributes(Dictionary newAttributes, Action callback = null);
getDirtyAttributes();
getAttributesKeys();
getAttributeValue(string key);
setAttribute(string key, string value, Action < string, bool > callback = null);
removeAttribute(string key, Action < string, bool > callback = null);
getPurchasedStoreItems();
purchaseStoreItem(GameFuseStoreItem storeItem, Action < string, bool > callback = null);
purchaseStoreItem(int storeItemId, Action < string, bool > callback = null);
removeStoreItem(int storeItemID, bool reimburseUser, Action < string, bool > callback = null);
removeStoreItem(GameFuseStoreItem storeItem, bool reimburseUser, Action < string, bool > callback = null);
addLeaderboardEntry(string leaderboardName, int score, Dictionary extraAttributes = null, Action < string, bool > callback = null);
addLeaderboardEntry(string leaderboardName, int score, Action < string, bool > callback = null);
getLeaderboard(int limit, bool onePerUser, Action < string, bool > callback = null); //Get all leaderboard entries for current signed in user
###GameFuse.js
setUpGame(string gameId, string token, function(string, bool) callback = null);
getGameId();
getGameName();
getGameDescription();
getStoreItems() //Gets all store items (your library)
signIn(string email, string password, function(string, bool) callback = null);
signUp(string email, string password, string password_confirmation, string username, function(string, bool) callback = null);
getLeaderboard(int limit, bool onePerUser, string LeaderboardName, function(string, bool) callback = null); //Retrieves leaderboard for one specific Leaderboard Name
sendPasswordResetEmail(string email, function(string, bool) callback = null)
fetchGameVariables(gameId, token, callback = undefined, extraData={})
getGameVariables()
###GameFuseStoreItem.js
getName();
getCategory();
getDescription();
getCost();
getId();
getIconUrl();
###GameFuseLeaderboardEntry.js
getUsername();
getScore();
getLeaderboardName();
getExtraAttributes();
getTimestamp();
This sections does not apply to the API, you may consume the API as you wish and create you own models in your language of choice.