Sign In Register

How can we help you today?

Start a new topic

Limit number of challenge requests

Hi


I'm new to Gamespark and I am working on a turn-based multiplayer game. I was able to login my users, list their facebook friends and challenge these friends.


Now I am trying to write some cloudcode to prevent the players to challenge the same player more than once. I'm not sure how to achieve this, and I hope you can give me a hint.


I tried to get the players challenges in the "CreateChallengeRequest" Cloudcode to throw an error if the player has already a (issued, running or received) challenge against the challenged player. Unfortunately I can't get it work.


Thanks for your support!


I was able to solve this by using "ListChallengeRequest" in the "CreateChallengeRequest" request.

Hi Marius,


SparkChallenge would be of use to you here, with that you can load a particular challenge instance in Cloud Code and then use getChallengedPlayerIds() to return an array of the players that have been challenged in that particular challenge, you can then use this to make sure you don't invite certain users multiple times. You can read more about it here.


Thanks,

Liam

Login to post a comment