Sign In Register

How can we help you today?

Start a new topic
Answered

Is it possible that player leaves issued challenge?

Hello,


One of main features of Our game is that users choose type of challenge, join it, and wait in some kind of lobby till challenge is in started state ( room is full ).

Everything works nice except when player wants to leave a lobby ( e.g. he want to switch to other type of challenge ). We need to remove player from that challenge and withdrawChallengeRequest is not working for us. 


if withdrawChallengeRequest is called by challenge issuer whole challenge is dropped, and when it is called by other player nothing happens.


My idea was to drop user from challenge on custom event, but i'm unsure how to do that, and is that possible since I only found "Spark.systemCollection("challengeInstance").find" method, no drop, remove etc.


Thank You,

Milutin


Best Answer

Hi Milutin,


You can use removePlayer(playerId) to remove a player from a challenge.


Thanks,


Oisin


Answer

Hi Milutin,


You can use removePlayer(playerId) to remove a player from a challenge.


Thanks,


Oisin


1 person likes this

Thank You!


I'm not sure how I overlooked that function. Could You please give me some more details about it?

What happens if I remove challenger? Can I remove player anytime or only in some states?


Thank You once again!


Milutin

edit:

I tested in test harness and removePlayer works good except in one case. I learned that I can remove all players from challenge an it will remain in issued state. However, when I add player in empty challenge and want to remove it again, removePlayer returns true ( can You explain return value please ) but player remains in accepted list of challenge. 

Is this normal behavior and i'm missing some point or is this bug?


TY,


Milutin

Hello,


I made workaround that works nice. When I want to remove player form ISSUED challenge I check if he is last in accepted array, and if that is true I send witrawChallengeRequest as challenger.


BR,

Milutin

Hi,

    I tested my function (Spark.getChallenge(idChallenge).removePlayer(idPlayer) in Test harness et it works fine. The playerId is removed from both list (challenged and accepted), but when I tried to call the same function in Unity, the idPlayer is remove from only one list (challenged)

Login to post a comment