Sign In Register

How can we help you today?

Start a new topic
Answered

GSEnumerable Accessing PlayerDetails from ChallengeAcceptedMessage in Unity using C#

 

	public void ChallengeAccepted(ChallengeAcceptedMessage message){
		Debug.Log ("CHALLENGE ACCEPTED!!! ");

		GSEnumerable<> accepted = message.Challenge.Accepted;
		GSEnumerable<var> accepted = message.Challenge.Accepted;
		GSEnumerable<PlayerDetails> accepted = message.Challenge.Accepted;
	
		GetData (message.Challenge.Challenger.Id, message.Challenge.ChallengeId, "accepted");

	}

 The documentation says,


 Use GSEnumerable<var> for C#, but unity will not let me use <var> as a data type.

GSEnumerable<var> accepted = challenge.Accepted; 
string challengeId = challenge.ChallengeId; 
string challengeMessage = challenge.ChallengeMessage; 
string challengeName = challenge.ChallengeName; 
GSEnumerable<var> challenged = challenge.Challenged; 
var challenger = challenge.Challenger; 
long? currency1Wager = challenge.Currency1Wager; 
long? currency2Wager = challenge.Currency2Wager; 
long? currency3Wager = challenge.Currency3Wager; 
long? currency4Wager = challenge.Currency4Wager; 
long? currency5Wager = challenge.Currency5Wager; 
long? currency6Wager = challenge.Currency6Wager; 
GSEnumerable<var> declined = challenge.Declined; 
DateTime? endDate = challenge.EndDate; 
DateTime? expiryDate = challenge.ExpiryDate; 
long? maxTurns = challenge.MaxTurns; 
string nextPlayer = challenge.NextPlayer; 
GSEnumerable<GSData> scriptData = challenge.ScriptData; 
string shortCode = challenge.ShortCode; 
DateTime? startDate = challenge.StartDate; 
string state = challenge.State; 
GSEnumerable<var> turnCount = challenge.TurnCount; 

 Then,


 Send the accepted GSEnumerable through a foreach loop and access the precious playerDetails.

GSData externalIds = playerDetail.ExternalIds; 
string id = playerDetail.Id; 
string name = playerDetail.Name; 

  


Anyone know how to access these precious playerDetails in Unity3d using C#?


Best Answer
Hi Ian,

You can access your playerDetails by using the following syntax:

  GSEnumerable<ChallengeAcceptedMessage._Challenge._PlayerDetail> players = message.Challenge.Accepted;

to retrieve the list of accepted players, then iterating thorough the playerr's you can retrieve specific playerDetail data items.

Let us know how this works out for you.

Regards,
Vinnie

 


Answer
Hi Ian,

You can access your playerDetails by using the following syntax:

  GSEnumerable<ChallengeAcceptedMessage._Challenge._PlayerDetail> players = message.Challenge.Accepted;

to retrieve the list of accepted players, then iterating thorough the playerr's you can retrieve specific playerDetail data items.

Let us know how this works out for you.

Regards,
Vinnie

 


1 person likes this

Yes! Thank you, thats the key. It would have taken forever to find this on my own.

How can I get the players data? I tried this and it doesnt work

  

foreach (var entry in players ) {
       string myText = "ID: " + entry.id;
}

  



Login to post a comment