Sign In Register

How can we help you today?

Start a new topic
Answered

Remove player from player collection

I've seen the post about not being able to completely delete a player from the database, but is there any way to just remove a player from the player collection? I'll have test data in there from debugging that I would like to remove.


Best Answer

Hi Guys,


No it's not possible to delete a player via cloud code, the main reason for this is to protect the player collection as someone could mistakenly delete the whole collection which as you could imagine on a live game could have disastrous consequences. The system player collection can only be accessed using SparkPlayer calls in cloud code. You could however create your own player collection that you can use in whatever way you'd like. We have a quick guide on how to create this located here. The advantage of having a collection like this is that you can access it like a normal mongo collection, adding or removing any data you wish, or completely removing players if you wanted to. You can also hide a player from your Leaderboards if you so wish, this can be done in Players Tab in Manage in the Portal, you can also hide/show a player on Leaderboards in cloud code which you can read about here.


If you're simply looking to remove test data (including test users) the best way to do it would be to have a Multi Stage setup in place for your game. You can read more about this here. With this in place you can simply copy a Snapshot into the next stage of your game when ready. When you do this the copied Snapshot will contain your games Configuration but the collection data(including the player one) will have been cleared so you wont have to worry about removing each individual test user, test Leaderboard entry etc... If you have any other questions just let me know.


Thanks,

Liam


I would like to delete player from cloud code. Is that not possible?

Answer

Hi Guys,


No it's not possible to delete a player via cloud code, the main reason for this is to protect the player collection as someone could mistakenly delete the whole collection which as you could imagine on a live game could have disastrous consequences. The system player collection can only be accessed using SparkPlayer calls in cloud code. You could however create your own player collection that you can use in whatever way you'd like. We have a quick guide on how to create this located here. The advantage of having a collection like this is that you can access it like a normal mongo collection, adding or removing any data you wish, or completely removing players if you wanted to. You can also hide a player from your Leaderboards if you so wish, this can be done in Players Tab in Manage in the Portal, you can also hide/show a player on Leaderboards in cloud code which you can read about here.


If you're simply looking to remove test data (including test users) the best way to do it would be to have a Multi Stage setup in place for your game. You can read more about this here. With this in place you can simply copy a Snapshot into the next stage of your game when ready. When you do this the copied Snapshot will contain your games Configuration but the collection data(including the player one) will have been cleared so you wont have to worry about removing each individual test user, test Leaderboard entry etc... If you have any other questions just let me know.


Thanks,

Liam

Login to post a comment