My game will have only one currency ( coins), I dont find in the API how to store this coins and get this.
Also, I want to know if I need store a local backup of my currency? For example, Im playing and I need use a Power and I buy it bit I dont want to wait for the server to know if I can use it or not.
Im using Unity.
Thanks.
Best Answer
L
Luis Vieira
said
over 7 years ago
Hi Eduardo,
Gamesparks store the currencies in 6 vars of name Currency #.
For example,
For ask How many coins (currency 1) I have, I do this:
new AccountDetailsRequest().Send((response) =>
{
Debug.Log("I have "+(response.Currency1 != null ? (int)response.Currency1 : 0) +" coins");
});
And for Add or Spend currency I create a custom event:
new LogEventRequest().SetEventKey("coinsAdd")
.SetEventAttribute("amount", value)
.Send((response) =>
{
});
var canSpend = Spark.getPlayer().debit1(Spark.getData().amount);
I dont know if its secure but it work for me.
E
Eduardo Casillas
said
over 7 years ago
That's it! Thanks a lot! :)
E
Eduardo Casillas
said
over 7 years ago
In fact... I've just found that, according to GameSparks "Customer Service", this method is not only secure but the recommended way: https://support.gamesparks.net/support/discussions/topics/1000038536
Luis Vieira
Hi,
My game will have only one currency ( coins), I dont find in the API how to store this coins and get this.
Also, I want to know if I need store a local backup of my currency? For example, Im playing and I need use a Power and I buy it bit I dont want to wait for the server to know if I can use it or not.
Im using Unity.
Thanks.
Hi Eduardo,
Gamesparks store the currencies in 6 vars of name Currency #.
For example,
For ask How many coins (currency 1) I have, I do this:
And for Add or Spend currency I create a custom event:
In CloudCode:
For AddCoins:
For SpendCoins:
I dont know if its secure but it work for me.
2 people have this question
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstLuis Vieira
I found a solution, I create a event to add or spend the currency and return the currency1
Eduardo Casillas
Hi Luis!
Can you please elaborate your solution? I've been searching how to manage virtual currencies for a long time but I couldn't find anything in the docs.
Luis Vieira
Hi Eduardo,
Gamesparks store the currencies in 6 vars of name Currency #.
For example,
For ask How many coins (currency 1) I have, I do this:
And for Add or Spend currency I create a custom event:
In CloudCode:
For AddCoins:
For SpendCoins:
I dont know if its secure but it work for me.
Eduardo Casillas
That's it! Thanks a lot! :)
Eduardo Casillas
In fact... I've just found that, according to GameSparks "Customer Service", this method is not only secure but the recommended way: https://support.gamesparks.net/support/discussions/topics/1000038536
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2487 topics