Is there a reason you are using challenges to do this ? You could easily do this with a custom event and some SparkPlayer calls in Cloud Code. Do you want to give the receiving player the option of accepting or refusing the currency ? If so using challenges may be the best way to do this. Reason being if player A creates a challenge with a wager, the wager amount is held in the players reservedCurrency until the challenge completes (or the player accepts in your case). If you don't need this then doing it manually in Cloud Code should suffice. if you have any further questions just let me know.
Thanks,
Liam
M
Mauro Ronchi
said
about 6 years ago
Hi,
exactly this, I want to give the receiving player the option of accepting or refusing the currency.
what I miss is how exactly the wager system works:
- can players wager different amount/type of currency?
- can a player accept a challenge if he doesn't have enough currency? (maybe with a flag set from cloud code or config?)
- can the wager be modified after a challenge is created and players have accepted? if so, what happens to the currency already spent?
- the amount won is always <wager>*<number of participants> or can it be set to a different value? (for example, if I want to "tax" games)
I couldn't fid any answer in the docs, except a tutorial on how to bet virtual goods
M
Mauro Ronchi
said
about 6 years ago
Hi,
can someone explain how the wager in a challenge works specifically and what kinds of use cases are supported with it? particularly the points above...
Customer Support
said
about 6 years ago
Hi Mauro,
Apologies I must have missed your reply. Players can wager different currencies. They must have enough to match the current wager set in the challenge. A player can join a challenge even if they don't have enough currency but they wont take part in it when it starts. The wager can't be modified after the challenge has been created. The amount won can't be changed but you could always use the ChallengeWonMessage Cloud Code to change how the wagered amount is handled manually at the end of a challenge if you wish. If you have any further questions just let us know.
Thanks,
Liam
M
Mauro Ronchi
said
about 6 years ago
ok then: can I win a challenge without starting it? the use case would be accepting a currency transfer as described in my first post (e.g. I have 100c, my friend sends me 1000c, I accept and win the challenge, I should have 1100c)
Customer Support
said
about 6 years ago
Answer
Hi Mauro
A challenge must have started and be running in order to be won.
You could set the wager to 0 and save the money transfer value in the challenges script data.
If the player accepts they win.
In the user message, ChallengeWonMessage cloud code credit the user the money
var money = Spark.getData().challenge.scriptData("moneyTransfer")
Spark.getPlayer().credit1(money);
In the user message ChallengeLostMessage cloud code take away the money from the user.
var money = Spark.getData().challenge.scriptData("moneyTransfer")
Spark.getPlayer().debit1(money);
Would this work for you?
Regards
Katie
M
Mauro Ronchi
said
about 6 years ago
that should work. I was hoping I could use wagers to automate this and have a more atomic transaction. (i'm already doing everything with cloud code, so I already setup events for this)
(except the debit part, that should happen when player1 sends the challenge, so i will do this when I create it)
Customer Support
said
about 6 years ago
Hi Mauro,
Glad to hear you can make it work. If you have any further questions just let us know.
Mauro Ronchi
Hi,
I am implementing a "send currency" system through challenges:
if a player doesn't have enough currency to accept the challenge, what is the best approach to follow?
Hi Mauro
A challenge must have started and be running in order to be won.
You could set the wager to 0 and save the money transfer value in the challenges script data.
If the player accepts they win.
In the user message, ChallengeWonMessage cloud code credit the user the money
var money = Spark.getData().challenge.scriptData("moneyTransfer")
Spark.getPlayer().credit1(money);
In the user message ChallengeLostMessage cloud code take away the money from the user.
var money = Spark.getData().challenge.scriptData("moneyTransfer")
Spark.getPlayer().debit1(money);
Would this work for you?
Regards
Katie
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstCustomer Support
Hi Mauro,
Is there a reason you are using challenges to do this ? You could easily do this with a custom event and some SparkPlayer calls in Cloud Code. Do you want to give the receiving player the option of accepting or refusing the currency ? If so using challenges may be the best way to do this. Reason being if player A creates a challenge with a wager, the wager amount is held in the players reservedCurrency until the challenge completes (or the player accepts in your case). If you don't need this then doing it manually in Cloud Code should suffice. if you have any further questions just let me know.
Thanks,
Liam
Mauro Ronchi
Hi,
exactly this, I want to give the receiving player the option of accepting or refusing the currency.
what I miss is how exactly the wager system works:
- can players wager different amount/type of currency?
- can a player accept a challenge if he doesn't have enough currency? (maybe with a flag set from cloud code or config?)
- can the wager be modified after a challenge is created and players have accepted? if so, what happens to the currency already spent?
- the amount won is always <wager>*<number of participants> or can it be set to a different value? (for example, if I want to "tax" games)
I couldn't fid any answer in the docs, except a tutorial on how to bet virtual goods
Mauro Ronchi
Hi,
can someone explain how the wager in a challenge works specifically and what kinds of use cases are supported with it? particularly the points above...
Customer Support
Hi Mauro,
Apologies I must have missed your reply. Players can wager different currencies. They must have enough to match the current wager set in the challenge. A player can join a challenge even if they don't have enough currency but they wont take part in it when it starts. The wager can't be modified after the challenge has been created. The amount won can't be changed but you could always use the ChallengeWonMessage Cloud Code to change how the wagered amount is handled manually at the end of a challenge if you wish. If you have any further questions just let us know.
Thanks,
Liam
Mauro Ronchi
ok then: can I win a challenge without starting it? the use case would be accepting a currency transfer as described in my first post (e.g. I have 100c, my friend sends me 1000c, I accept and win the challenge, I should have 1100c)
Customer Support
Hi Mauro
A challenge must have started and be running in order to be won.
You could set the wager to 0 and save the money transfer value in the challenges script data.
If the player accepts they win.
In the user message, ChallengeWonMessage cloud code credit the user the money
var money = Spark.getData().challenge.scriptData("moneyTransfer")
Spark.getPlayer().credit1(money);
In the user message ChallengeLostMessage cloud code take away the money from the user.
var money = Spark.getData().challenge.scriptData("moneyTransfer")
Spark.getPlayer().debit1(money);
Would this work for you?
Regards
Katie
Mauro Ronchi
that should work. I was hoping I could use wagers to automate this and have a more atomic transaction. (i'm already doing everything with cloud code, so I already setup events for this)
(except the debit part, that should happen when player1 sends the challenge, so i will do this when I create it)
Customer Support
Hi Mauro,
Glad to hear you can make it work. If you have any further questions just let us know.
Thanks,
Liam
-
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