Sign In Register

How can we help you today?

Start a new topic

Registration Request and getPlayer

I'm trying to initiate some player privateData on account creation. I realized that the registration always happens after the cloud code is executed, this way getPlayer always returns null. Is there any ways around this?


I'm quite new to the whole CloudScript system too, but I noticed that most tutorials released by GameSparks set scriptData to 'share' the data with the response script. I use it for registering with an email address.


 You can use this to set the data. In this case I use Spark.getData().scriptData.email to get the value provided in the register request.

Spark.setScriptData("email", Spark.getData().scriptData.email);

 

In the response you can now use this to use/store the value.

 

Spark.getData().scriptData.email;


Hope that helped :)

I think your misunderstanding the question.

I want to do  

Spark.getPlayer().setPrivateData("item","some item info");

   inside my registration request but I cant because the request runs after the code code runs. getPlayer always returns null.

Hi Steven,


getPlayer() will always return null in the RegistrationRequest as the player has not been created at this point. Moving the code to the RegistrationResponse will fix this.


Regards,

Liam

RegistrationResponse doesn't automatically run after a RegistrationRequest. I tried putting in a simple 

Spark.setScriptData("a", "a");

 in there but I don't get anything back.

RegistrationResponse does automatically run after a RegistrationRequest. That's  the way the system works. Try using the code I send above. I'm using the exact same code and it works perfectly fine.

Login to post a comment