Sign In Register

How can we help you today?

Start a new topic
Answered

Is there any way to access the player collection in cloud code?

I can't get it via Spark.runtimeCollection or Spark.metaCollection. What I want to generate guest player's display name using the format guest[some number], like guest4321. The number is generated from the number of players in player collection. Any reason why player collection access is not allowed from cloud code? This seem to complicate things :(


Best Answer

Hi Sam


I would probably write a script in AuthenticationResponse that checked to see if I needed to update the displayName, and if I did, send a ChangeUserDetails request from within the script.


Would this work for you?


Gabriel


2 people have this question

Answer

Hi Sam


I would probably write a script in AuthenticationResponse that checked to see if I needed to update the displayName, and if I did, send a ChangeUserDetails request from within the script.


Would this work for you?


Gabriel

Thank you for your response Gabriel. I've done this already and it's working fine. The real problem for me is getting the next guest number. Assuming the player collection is accessible from cloud code, I'll just get the number of players in collection and assign it as the new guest number. Now since I can't do that, I need a way to generate guest number, and I think I'll do it with SparkCache and or SparkRedis. I have a few questions if you don't mind:

1. What's the difference in storing data between SparkCache and SparkRedis? Which solution would you recommend? All I need is a simple storage for a single number

2. What do I need to do if I want to get a list of players that matches certain criteria?

Hi Sam


Another customer used a counter in a mongo collection to get an incrementing number, does this work for you ?


https://support.gamesparks.net/discussions/topics/1000052630


Gabriel

That could work, thanks Gabriel

Login to post a comment