playMaker

Author Topic: Send a list in a custom event  (Read 1141 times)

Phuzz

  • Full Member
  • ***
  • Posts: 101
    • Bzilla Games
Send a list in a custom event
« on: November 28, 2017, 07:08:06 AM »
Hello,

I am creating a set of custom actions for the GameSparks platform, I have finished most of their API, but stumbled upon a feature I would like to add to a specific action "LogEventRequest" to make it more dynamic for ease of use.

The sample code from GameSparks Requests API goes like this, Example of a single attribute:

new LogEventRequest()
        .SetEventKey(eventKey)
        .SetEventAttribute("XP", 48)
        .Send((response) => {
        });

Now the "SetEventAttribute" could be more than one attribute so you will have to add multiple "SetEventAttribute" requests to the code, example of 3 attributes:

new LogEventRequest()
        .SetEventKey(eventKey)
        .SetEventAttribute("XP", 48)
        .SetEventAttribute("Gold", 120)
        .SetEventAttribute("Health", 55)

        .Send((response) => {
        });

 I would like to make the action similar to the "Analytics Send Custom Event", where you enter the amount of attributes you want, shows you a list, so you define type and value for each. I have taken a look at custom Event action for unity analytics and so far achieved this.

Code: [Select]
            if (keys.Length == 0)
            {
            }
            else
            {

                Dictionary<string, object> _data = new Dictionary<string, object>();

                for (int i = 0; i < keys.Length; i++)
                {

                    values[i].UpdateValue();

                    _data.Add(keys[i].Value, values[i].GetValue());
                }

                new LogEventRequest()
                    .SetEventKey(eventName.Value)
                    // Here goes the Attributes here with .SetEventAttribute
                    .Send((response) => {


How can I have the Dictionary stated in the code inserted where it belongs?

Thank you
Bzilla Games "Education with a Tickle!"
Qbucket Games "Voxel Games"