Sign In Register

How can we help you today?

Start a new topic

LogEvent Request return is null ScriptData

I have current Event


When I try to get value from attribute dBuff by using this code:

 

private void GetLogEventRequestDataBaff() { 

            new LogEventRequest().SetEventKey(ConstantsGame.GameSparksKeyDataBaff).Send(LogEventRequestDataBaffCallback, LogEventErrorCallBack); 

        }

 private void LogEventRequestDataBaffCallback(LogEventResponse logEventResponse) { 

            if (!logEventResponse.HasErrors) { 

                if (!_isDataBaff) { 

                    _isDataBaff = true; 

                    var result = logEventResponse.ScriptData.GetString(ConstantsGame.GameSparksAttributeDataBaff); 

                    if (!string.IsNullOrEmpty(result)) 

                        DataBaff = result; 

                } 

                GetLogEventRequestDataBag(); 

            } else { 

                DebugLogger.LogError("Error LogEventRequest GameSparksKeyDataBaff = " + logEventResponse.Errors.JSON); 

            } 

        }

 

Request is returns ScriptData = null. 

 


What am I doing wrong? 


Hey Teselkin,


Apologies for the late response, do you still need help with this issue, are you setting any script data in your event via cloud code??


Best Regards,

- Tony

Hi, I have the same issue.


I was following the tutorial on Save/Load player data.


On portal, everything works fine. I send LogEventRequest and it returns me a data structure with "ScriptData" field:

{
 "@class": ".LogEventResponse",
 "scriptData": {
  "player_Data": {
   "_id": {
    "$oid": "57f891776677888b21f50f9e"
   },
   "playerID": "57f860c1fd85de04d3d3e99b",
   "playerGold": 100
  }
 }
}


But when I implement it in my Unity project, response.ScriptData == null.


Sending request:

LogEventRequest logEventRequest = new LogEventRequest();
logEventRequest.SetEventKey("LOAD_PLAYER");
logEventRequest.Send(onResponseFunction);

 Parsing response:  

public void onLoadPlayerDataResponse(LogEventResponse response)
	{
		if (!response.HasErrors) {
			Debug.Log("Success at loading player data"); //!!!!! I DO get this message
			// Now parse!
			GSData data = response.ScriptData.GetGSData("player_Data"); //!!! NullPointerException here: debugger shows ScriptData as (null)
			this.gold = (long)data.GetNumber ("playerGold");
			print ("Player gold = " + this.gold);
		}
		else
		{
			Debug.Log("Error at loading player data");
		}
	}

  

Can you please help me to figure it out?

Hi Alesky,


I believe using "response.BaseData.GetGSData("scriptData")" should give you access to the scriptData for your response here. Try that and let us know if you have any other questions.


Thanks,

Liam

Oh my god, I'm just so stupid: my Load button did SavePlayer method call instead of LoadPlayer... I checked my code again after your reply, and found this shameful bug. Now it works just fine, thank you.

Login to post a comment