Sign In Register

How can we help you today?

Start a new topic
Answered

How to end challenge when player disconnects.

A little help is needed here.

I have to end the challenge when one of two players disconnects. 

I'm trying to catch this event in GS_PLAYER_DISCONNECT script, but it seems that this script gets called for both players. And i'm not sure  which player trigger disconnection. 

I need to know this, since other player should win the challenge.


Thanks in advance.


Best Answer

Hi,


Can you clarify this a little ? GS_PLAYER_DISCONNECT should only run if a single player disconnects. This script has player context so you should be able to use "var playerID = Spark.getPlayer().getPlayerId();" to identify the player and then find the challenge they were in and set the other player as the winner or remove the disconnected player from the challenge.


Thanks,

Liam


Answer

Hi,


Can you clarify this a little ? GS_PLAYER_DISCONNECT should only run if a single player disconnects. This script has player context so you should be able to use "var playerID = Spark.getPlayer().getPlayerId();" to identify the player and then find the challenge they were in and set the other player as the winner or remove the disconnected player from the challenge.


Thanks,

Liam


1 person likes this

How do you find the challenge they were in using their player id?

Login to post a comment