Question by
Zewde · Jan 22, 2016 at 03:01 PM ·
multiplayergoogle playrealtime
Google Play Realtime MP - Punish player who leaves room.
Does anyone here know how to punish a player (remove from PlayerPrefs "Coins") who leaves a gaming room ? I tried various codes under OnPeersDisconnected and OnLeftRoom but they don't seem to work approprietly.
Note: there are only 2 players in the room.
Here is what I tried:
...
public bool CoinsRemovalForExiting = true;
public void OnLeftRoom() { points = 0; PointsText.enabled = false; health = 0; EnableAnimationBool(TimeOuterAnimator, "showTimeOuter", true);
if (CoinsRemovalForExiting == true)
{
PlayerPrefs.SetInt("Coins", PlayerPrefs.GetInt("Coins") - 200);
}
}
public void OnPeersDisconnected(string[] participantIds) { CoinsRemovalForExiting = false;
EnableAnimationBool(TimeOutAnimator, "showTimeOut", true);
health = 0;
PlayGamesPlatform.Instance.RealTime.LeaveRoom();
points = 0;
PointsText.enabled = false;
}
Comment