Sign In Register

How can we help you today?

Start a new topic
Answered

Letting your friends know your online

I hve been working on a friend's system that I have nearly completed, currently I have a send message event I have created that I call when a player logs in, is there a way to do this in the authentication response as cloud code?

Best Answer
If you know the teamID during auth though, you could look into the SparkTeam API, and use team-chat instead of sending a custom message.
Either that or get the team-members IDs and send your own message as usual.
https://docs.gamesparks.com/api-documentation/cloud-code-api/player/sparkteam.html

Sean

 


 Hey Chase,

Yes, you can do this by going to the cloud-code tab of your game's portal and navigating to responses -> Authentication Response

blob1477298455047.png


Any code you put here will run when the player authenticates, and you can get auth-details and auth errors using Spark.getData() as you would with info coming into a request.

Something i would advise in your execution if your player's friends list gets very large is to look into bulk jobs [here].
What you dont want to happen upon login is to have the auth-response slowed down while you send off these messages to friends, so bulk jobs or schedulers will take the load off the server when you preform authentication.
However, you really only have to worry about this when there are 100's of friends and tens of thousands of concurrent users.

Let me know if that makes sense?
Sean

Hey Sean I understand that you can do that in the authentication response just unsure of what to put in there, I have tried a few things and cant figure out how to get the list of players in a friend's team to send a message to. I will definitely look into Bulk jobs when I get a chance
Will this grab the friends list still if it is a custom team with social enabled?
No, this will only give you access to the friends which have also connected to your game through the social platform you are using.
You would need to invite them, and then once they are connected and are friends with you on the same platform, you can get them back in that list.

https://docs.gamesparks.com/documentation/key-concepts/social-capabilities.html#connecting

Does that help?
Sean

 

Answer
If you know the teamID during auth though, you could look into the SparkTeam API, and use team-chat instead of sending a custom message.
Either that or get the team-members IDs and send your own message as usual.
https://docs.gamesparks.com/api-documentation/cloud-code-api/player/sparkteam.html

Sean

 

Team chat seems to be the eay to go I think. Thanks heaps for your help.
you're welcome.

Sean

 

Login to post a comment