I am trying to set the script data that is retrieved when you do an AccountDetailsRequest.
However, the only way I can see so far is to create my own event and assign the player data from the cloud code. Is there any way to do that directly from the SDK (Unity) without creating an additional event ?
Best Answer
C
Customer Support
said
about 7 years ago
Hi Stephane,
You would have to set the scriptData somewhere first before it can be retrieved in the AccountDetailsRequest. If you're storing some basic stats that every player will have you can set these in the AuthenticationResponse/RegistrationResponse Cloud Code with something like the following.
//check if this is a new player
var newPlayer = Spark.getData().newPlayer
//if its a new player
if(Spark.getData().newPlayer === true){
Spark.getPlayer().setScriptData("defaultValues", {
"Lives": 0,
"Health": 0,
"Gold": 0,
});
}
//if this is a returning player
else
{
Spark.setScriptData("New Player ?", newPlayer);
}
Doing this would make sure each new player would have these stats set to 0 by default when they sign up. Then you would need to have an event set up so your game could update these values from Unity when needed. If you have anymore questions just let me know.
What data is it you are looking to set to scriptData when performing the AccountDetailsRequest ? If you can give me a bit more info on what you're looking to achieve here we can find a solution for you.
Thanks,
Liam
S
Stephane Lallee
said
about 7 years ago
Hi Liam,
Well it was just storing some basic info about the player appearance and stats. I created an event and set up there the custom data to be retrieved by the AccountDetailsRequest. I guess I could also set it from the request itself by modifying the cloud code executed there, but I am fine with the event solution.
Customer Support
said
about 7 years ago
Answer
Hi Stephane,
You would have to set the scriptData somewhere first before it can be retrieved in the AccountDetailsRequest. If you're storing some basic stats that every player will have you can set these in the AuthenticationResponse/RegistrationResponse Cloud Code with something like the following.
//check if this is a new player
var newPlayer = Spark.getData().newPlayer
//if its a new player
if(Spark.getData().newPlayer === true){
Spark.getPlayer().setScriptData("defaultValues", {
"Lives": 0,
"Health": 0,
"Gold": 0,
});
}
//if this is a returning player
else
{
Spark.setScriptData("New Player ?", newPlayer);
}
Doing this would make sure each new player would have these stats set to 0 by default when they sign up. Then you would need to have an event set up so your game could update these values from Unity when needed. If you have anymore questions just let me know.
Thanks,
Liam
Y
Yogesh Wadhwa
said
about 4 years ago
Hi,
I set bind the above code to registerRequest event, but it's not updating scriptdata of player.
Customer Support
said
about 4 years ago
Hi Yogesh,
This won't work in the Request as there is no player context at this point. It will work if you put it in your RegistrationResponse.
Regards,
Liam
Y
Yogesh Wadhwa
said
about 4 years ago
Hi Liam,
I have also tried to bind in register response event..still no success
Stephane Lallee
Hi !
I am trying to set the script data that is retrieved when you do an AccountDetailsRequest.
However, the only way I can see so far is to create my own event and assign the player data from the cloud code. Is there any way to do that directly from the SDK (Unity) without creating an additional event ?
Hi Stephane,
You would have to set the scriptData somewhere first before it can be retrieved in the AccountDetailsRequest. If you're storing some basic stats that every player will have you can set these in the AuthenticationResponse/RegistrationResponse Cloud Code with something like the following.
Doing this would make sure each new player would have these stats set to 0 by default when they sign up. Then you would need to have an event set up so your game could update these values from Unity when needed. If you have anymore questions just let me know.
Thanks,
Liam
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstCustomer Support
Hi Stephane,
What data is it you are looking to set to scriptData when performing the AccountDetailsRequest ? If you can give me a bit more info on what you're looking to achieve here we can find a solution for you.
Thanks,
Liam
Stephane Lallee
Hi Liam,
Well it was just storing some basic info about the player appearance and stats. I created an event and set up there the custom data to be retrieved by the AccountDetailsRequest. I guess I could also set it from the request itself by modifying the cloud code executed there, but I am fine with the event solution.
Customer Support
Hi Stephane,
You would have to set the scriptData somewhere first before it can be retrieved in the AccountDetailsRequest. If you're storing some basic stats that every player will have you can set these in the AuthenticationResponse/RegistrationResponse Cloud Code with something like the following.
Doing this would make sure each new player would have these stats set to 0 by default when they sign up. Then you would need to have an event set up so your game could update these values from Unity when needed. If you have anymore questions just let me know.
Thanks,
Liam
Yogesh Wadhwa
Hi,
I set bind the above code to registerRequest event, but it's not updating scriptdata of player.
Customer Support
Hi Yogesh,
This won't work in the Request as there is no player context at this point. It will work if you put it in your RegistrationResponse.
Regards,
Liam
Yogesh Wadhwa
-
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