Edit aditional data along with edit user score by ID?

0 votes
Hi All

I save aditional data along with saving score. Now I want to edit that editional data along with editing user score by ID. Can you please write code snippet needed for this in unity? I tried metaheader but it did not work. What should I do?

Thanks
asked Jul 26, 2016 in Unity by gokhan (20 points)

1 Answer

0 votes

Hi Gokhan,

 

Please find below code snippet and let me know if you need any help from my side:

String scoreId = "<Enter_score_id>";
double gameScore = 3500;
String dbName = "<Your_DataBase_Name>"; 
String collectionName = "<Your_Collection_Name>"; 
Dictionary<string, object> jsonDoc = new Dictionary<string, object> ();
jsonDoc.Add("name","John");
jsonDoc.Add("age",20);
App42API.SetDbName(dbName);  
scoreBoardService.AddJSONObject(collectionName, jsonDoc);
App42API.Initialize("API_KEY","SECRET_KEY");
ScoreBoardService scoreBoardService = App42API.BuildScoreBoardService(); 
scoreBoardService.EditScoreValueById(scoreId, gameScore, new UnityCallBack()); 
public class UnityCallBack : App42CallBack
{
	public void OnSuccess(object response)
	{
		Game game = (Game) response;     
		App42Log.Console("gameName is " + game.GetName()); 
		for(int i = 0;i<game.GetScoreList().Count;i++)
		{
			App42Log.Console("userName is : " + game.GetScoreList()[i].GetUserName());
			App42Log.Console("score is : " + game.GetScoreList()[i].GetValue());
			App42Log.Console("scoreId is : " + game.GetScoreList()[i].GetScoreId());
			App42Log.Console("owner is "+ game.GetScoreList()[i].GetJsonDocList()[0].GetOwner());
			App42Log.Console("Doc id is "+ game.GetScoreList()[i].GetJsonDocList()[0].GetDocId());
			App42Log.Console("updated at "+ game.GetScoreList()[i].GetJsonDocList()[0].GetUpdatedAt());
			App42Log.Console("created at "+ game.GetScoreList()[i].GetJsonDocList()[0].GetCreatedAt());
			App42Log.Console("json doc  is : "+ game.GetScoreList()[i].GetJsonDocList()[0].GetJsonDoc());	
		}
	}

	public void OnException(Exception e)
	{
		App42Log.Console("Exception : " + e);
	}
}

 

Regards,

Himanshu Sharma

answered Jul 28, 2016 by hs00105 (2,005 points)
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...