Sign In Register

How can we help you today?

Start a new topic

Saving & Loading specific values from customPlayerData

Can anyone explain(with examples) how to Save / Update SPECIFIC value inside runtime customPlayerData??


I have created runtime customPlayerData collection  to hold my player stats under NoSQL editor tab:



I have created EVENT "SAVE_POWERUPS", which has 4 numeric values( holding different/specific power-up values:  "powerupStopCars", "powerupShield", "powerupTimeScale", "powerupExtraFuel" ). Default minimum value is set to 2. Default Calculation is set to Maximum, which suppose to Update powerup value if its bigger than the last updated value?? Not sure.


Now i have done the same EVENT Setup for "LOAD_POWERUPS":

 

Inside Unity i have made a kind of universal C# Script to Save numeric Values( which kind of works, but for saving only 1 event attribute name at a time )

  public void SaveIntToCloud( string eventName, string attributeName, int value )
    {
        new GameSparks.Api.Requests.LogEventRequest().SetEventKey(eventName).SetEventAttribute(attributeName, value ).Send((response) => 
        {
            if (!response.HasErrors)
            {
                Debug.Log("Player Saved To GameSparks...");
            }
            else
            {
                Debug.Log("Error Saving Player Data...");
            }
        });
    }

 Now i can Save stuff like this:

 

GameSparkManager.instance.SaveIntToCloud("SAVE_POWERUPS", "powerupShield", powerUpTime_Shield);

 And LOAD stuff like this: 

 public void LoadPowerupShieldFromCloud()
    {
        new GameSparks.Api.Requests.LogEventRequest().SetEventKey("LOAD_POWERUPS").Send((response) =>
        {
            if (!response.HasErrors)
            {
                GSData data = response.ScriptData.GetGSData("customPlayerData");

                PowerupManager.Instance.powerUpTime_Shield = (int)data.GetInt("powerupShield");

            }
            else
            {
                Debug.Log("Error Loading powerup SHIELD...");
            }
        });
    }

 

Assuming that the above scripts are correct....WHAT I AM suppose to write in Cloud Code for Saving Specific value Only! in "SAVE_POWERUPS" Event and also same for retrieving specific value only from "LOAD_POWERUPS" Event? I have never used javascript nor cloud code and i do not understand how it works. I have seen the only 1 tutorial on cloud saving and it is quite confusing and i think there is probably another/better ways of achieving the same thing. 

So what are the different ways of saving values, updating specific values( one value at a time ) and loading/retrieving specific values from those runtime collections? And How?


NB! Most of the answers here assume that one should know how to do this and that, but lets assume you are explaining to a 10 year old ;)


Thanks Rando,


We are in the process of overhauling our documentation and hope to have expanded tutorials for all this in the coming months.
Someone from the team will get back to your question soon.


Oisin

Rando,


You can read this thread https://support.gamesparks.net/support/discussions/topics/1000073951

It will give you a good idea of what to do. It is surely not clear enough for a 10 year old but it's a good start.

Well, thank you Christian, but the link you provided is to my own thread. Maiby you meant to link to some other thread?

Sorry, Christian. It didnt show the link because i wasnt logged in. Thanks.

Hey Rando,

Did you get this problem sorted out with Christian's suggestion?

Sean

 

Login to post a comment