ChallengeIssuedMessage reference message and setScriptData
I
Ian Robinson
started a topic
over 6 years ago
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
C
Customer Support
said
over 6 years ago
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
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
I
Ian Robinson
said
over 6 years ago
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.
Customer Support
said
over 6 years ago
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
Ian Robinson
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
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
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstCustomer Support
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
Ian Robinson
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.
Customer Support
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
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2487 topics