LogEventRequest reports Error but ScriptData has been updated
A
Adam Marsh
started a topic
over 3 years ago
Good Evening,
Have just started to use your Service for a Turn Based Mutliplayer Game, and while I'm slowly getting my head around Matches and Challenges could use some extra help with what I've found.
Before the AcceptChallengeRequest is fired I need to upload a scriptdata variable called seedToken do once AcceptChallengeRequest is fired each side can generate the level using this seedToken.
public void ChallengePlayer(List<string> PlayerIDs)
{
new CreateChallengeRequest().SetChallengeShortCode("ZombieTurn")
.SetUsersToChallenge(PlayerIDs)
.SetEndTime(System.DateTime.Today.AddDays(1))
.Send((response) =>
{
if (response.HasErrors)
{
Debug.Log(response.Errors);
}
else
{
Debug.Log("Challenge Sent!");
Debug.Log(response.ChallengeInstanceId);
new LogEventRequest().SetEventAttribute("challengeInstanceId", response.ChallengeInstanceId)
.SetEventAttribute("seedToken", "TESTING")
.SetEventKey("takeTurn")
.Send((SeedResponse) =>
{
if (SeedResponse.HasErrors)
{
Debug.Log(SeedResponse.Errors);
}
else
{
Debug.Log("Unable to send seed to GameSparks!");
}
});
}
});
}
My server side code attached to LogEventRequesr is:
var ChallengeID = Spark.getData().challengeInstanceId;
var seedToken =Spark.getData().seedToken;
var thisChallenge = Spark.getChallenge(Spark.getData().challengeInstanceId);
thisChallenge.setScriptData("seedToken", Spark.getData().seedToken);
The issue is that the response I receive back in unity is:
I don't understand why Unity is reporting an Error when on the ChallengeAccepted I can see my seedToken in ScriptData.
Any help would be great.
Thanks.
Best Answer
C
Customer Support
said
over 3 years ago
Hi Adam
LogEventRequest is used to call a custom event,In your case calling the takeTurn event. So the takeTurn event need to have the cloud code logic in it. You will also need to give takeTurn the attributes you want passed you can set these up in the edit event section. In cloud code you can read in the attributes using var seedToken = Spark.getData().seedToken; Once you do the logic you want you can return the attributes if you changed the values using Spark.setScriptData("seedToken", seedToken);
To test in Test Harness go to LogEvent and run the takeTurn event.
To get the challenge ID use Spark.data.challengeId, If you remove () after data you will get the challengeId and seedToken The test harness is very handy for testing sever side code and will help you know if the error is in cloud code or in unity.
Thanks Katie
A
Adam Marsh
said
over 3 years ago
Thanks for the response Katie.
I've updated my CloudCode and that is referencing objects correctly now.
LogEventRequest is used to call a custom event,In your case calling the takeTurn event. So the takeTurn event need to have the cloud code logic in it. You will also need to give takeTurn the attributes you want passed you can set these up in the edit event section. In cloud code you can read in the attributes using var seedToken = Spark.getData().seedToken; Once you do the logic you want you can return the attributes if you changed the values using Spark.setScriptData("seedToken", seedToken);
To test in Test Harness go to LogEvent and run the takeTurn event.
Adam Marsh
Good Evening,
Have just started to use your Service for a Turn Based Mutliplayer Game, and while I'm slowly getting my head around Matches and Challenges could use some extra help with what I've found.
Before the AcceptChallengeRequest is fired I need to upload a scriptdata variable called seedToken do once AcceptChallengeRequest is fired each side can generate the level using this seedToken.
I've used the follow Support ticket https://support.gamesparks.net/support/discussions/topics/1000050081 and set up a LogEventRequest on the back of a CreateChallengeRequest response to send the seedToken, my code looks like this:
My server side code attached to LogEventRequesr is:
The issue is that the response I receive back in unity is:
I don't understand why Unity is reporting an Error when on the ChallengeAccepted I can see my seedToken in ScriptData.
Any help would be great.
Thanks.
LogEventRequest is used to call a custom event,In your case calling the takeTurn event.
So the takeTurn event need to have the cloud code logic in it. You will also need to give takeTurn the attributes you want passed you can set these up in the edit event section.
In cloud code you can read in the attributes using
var seedToken = Spark.getData().seedToken;
Once you do the logic you want you can return the attributes if you changed the values using
Spark.setScriptData("seedToken", seedToken);
To test in Test Harness go to LogEvent and run the takeTurn event.
Thanks
Katie
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstCustomer Support
To get the challenge ID use Spark.data.challengeId, If you remove () after data you will get the challengeId and seedToken
The test harness is very handy for testing sever side code and will help you know if the error is in cloud code or in unity.
Thanks
Katie
Adam Marsh
Thanks for the response Katie.
I've updated my CloudCode and that is referencing objects correctly now.
But I still get a error response:
I get this when sending the following through the Test Harness:
Thanks for your help.
Customer Support
LogEventRequest is used to call a custom event,In your case calling the takeTurn event.
So the takeTurn event need to have the cloud code logic in it. You will also need to give takeTurn the attributes you want passed you can set these up in the edit event section.
In cloud code you can read in the attributes using
var seedToken = Spark.getData().seedToken;
Once you do the logic you want you can return the attributes if you changed the values using
Spark.setScriptData("seedToken", seedToken);
To test in Test Harness go to LogEvent and run the takeTurn event.
Thanks
Katie
-
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 2338 topics