Sign In Register

How can we help you today?

Start a new topic
Answered

ChallengeIssuedMessage reference message and setScriptData

Hey.


I'm trying to access the message that is being sent to the player once a challenge instance has been issued, by the ChallengeIssuedMessage cloud code. I thought there would be some easy way to access the message that is being sent so I could set it's ScriptData in cloud code.


In Unity, I discovered that the data I needed should have been in message.Challenge.challenger.ScriptData.getGSData("player_Data");

When I tried this code, I received a null reference, the ScriptData was null. I checked the player in the NOSQL and verified that there was ScriptData. I also verified the spelling and debugged message.Challenge.challenger.ScriptData it equalled null.

Do I need to set the ScriptData on the challenge when I initiate it? this does not happen automatically (pulled from playerID?)


Currently I use message.Challenge.challenger.Id to look up the GSData I need then use that to populate my fields.


I know that I can set up a custom message and probably access the message and set scriptData from there but I was wondering mostly what is accessible from ChallengeIssuedMessage cloud code. (User Message and Global Message.) IE player, challenge, message.


Thanks,

Ian


Best Answer

Hi Ian,


If you add some cloud code to your ChallengeIssuedMessage (Configurator->Cloud Code->Global Messages), you can add data to the message itself using


Spark.setScriptData(data);


Hope this helps.


Regards,

Vinnie


Hi Ian,


You can add scriptData to a challenge at any point, adding info from a message to scriptData will be fine as the challengeId is there so you will be able to reference it when setting the data on the challengeInstance. Can you let me know what you'd like to access in the ChallengeIssuedMessage and I'll help you get it up and running.


Thanks,

Liam

Hi Liam, I wanted to set the message data in cloud code. Possibly some GSData that can be accessed by the receiver of the message.

Answer

Hi Ian,


If you add some cloud code to your ChallengeIssuedMessage (Configurator->Cloud Code->Global Messages), you can add data to the message itself using


Spark.setScriptData(data);


Hope this helps.


Regards,

Vinnie

Login to post a comment