I am creating a tournament system for an asynchronous turn based game and players will be able to sign up for a tournament that will start a specific date and time.
My goal is to create challenges between all the participants in the tournament. I know this would be possible if the players initiate the creation of the challenges when they are logged by selecting start tournament or something like that.
However, what I want to do is have all the challenges automatically created on the server when the tournament begins. So the question is, how to create challenges between players on the server when the players are not logged in?
Best Answer
C
Customer Support
said
almost 6 years ago
Hi Jaayden,
You could use SparkRequests to do this. This would allow you create a challenge on behalf of a player regardless of whether they were online at the time or now. You can read about how to do this with a CreateChallengeRequest here. Once you have sent this as a certain player you could also accept the challenge of behalf of another player in the same script so the challenge would be ready for the players when they next came online. Using an AcceptChallengeRequest on behalf of the challenged player add them to the challenge.
You'll notice on both linked pages that when the SparkRequest is sent we use var response = request.Send();
To send as another player you can use var response = request.SendAs(playerID); Here playerID would be the id of the player you wish to send request as. You can also use "ExecuteAs(playerID);" to send the request and execute the Cloud Code script for that event in the context of the given player. Does that sound like it would work for you ?
Regards,
Liam
1 Comment
Customer Support
said
almost 6 years ago
Answer
Hi Jaayden,
You could use SparkRequests to do this. This would allow you create a challenge on behalf of a player regardless of whether they were online at the time or now. You can read about how to do this with a CreateChallengeRequest here. Once you have sent this as a certain player you could also accept the challenge of behalf of another player in the same script so the challenge would be ready for the players when they next came online. Using an AcceptChallengeRequest on behalf of the challenged player add them to the challenge.
You'll notice on both linked pages that when the SparkRequest is sent we use var response = request.Send();
To send as another player you can use var response = request.SendAs(playerID); Here playerID would be the id of the player you wish to send request as. You can also use "ExecuteAs(playerID);" to send the request and execute the Cloud Code script for that event in the context of the given player. Does that sound like it would work for you ?
Jaayden Halko
I am creating a tournament system for an asynchronous turn based game and players will be able to sign up for a tournament that will start a specific date and time.
My goal is to create challenges between all the participants in the tournament. I know this would be possible if the players initiate the creation of the challenges when they are logged by selecting start tournament or something like that.
However, what I want to do is have all the challenges automatically created on the server when the tournament begins. So the question is, how to create challenges between players on the server when the players are not logged in?
Hi Jaayden,
You could use SparkRequests to do this. This would allow you create a challenge on behalf of a player regardless of whether they were online at the time or now. You can read about how to do this with a CreateChallengeRequest here. Once you have sent this as a certain player you could also accept the challenge of behalf of another player in the same script so the challenge would be ready for the players when they next came online. Using an AcceptChallengeRequest on behalf of the challenged player add them to the challenge.
You'll notice on both linked pages that when the SparkRequest is sent we use var response = request.Send();
To send as another player you can use var response = request.SendAs(playerID); Here playerID would be the id of the player you wish to send request as. You can also use "ExecuteAs(playerID);" to send the request and execute the Cloud Code script for that event in the context of the given player. Does that sound like it would work for you ?
Regards,
Liam
Customer Support
Hi Jaayden,
You could use SparkRequests to do this. This would allow you create a challenge on behalf of a player regardless of whether they were online at the time or now. You can read about how to do this with a CreateChallengeRequest here. Once you have sent this as a certain player you could also accept the challenge of behalf of another player in the same script so the challenge would be ready for the players when they next came online. Using an AcceptChallengeRequest on behalf of the challenged player add them to the challenge.
You'll notice on both linked pages that when the SparkRequest is sent we use var response = request.Send();
To send as another player you can use var response = request.SendAs(playerID); Here playerID would be the id of the player you wish to send request as. You can also use "ExecuteAs(playerID);" to send the request and execute the Cloud Code script for that event in the context of the given player. Does that sound like it would work for you ?
Regards,
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