Sign In Register

How can we help you today?

Start a new topic
Answered

What is SetEventAttribute in LogEventRequest?

Hi community, I'm new in GameSparks.

Now I'm really confused with LogEventReQuest because in your tutorial "using cloud code" we can define some event with Attribute.
But now, GameSparks update to portal 2 and its removed.
So my question, how can i use it in client (unity) and using cloud code do some calculate with this Attribute and response to client. Or how can i define it and useable?
Here is Client:
new LogEventRequest ().SetEventKey ("first event").SetEventAttribute ("number", "0.1f").SetEventAttribute ("number1", "1.1f").Send ((response) => {

   if (response.HasErrors){

    Debug.LogWarning(response.Errors.JSON);

   }

   else {

    Debug.LogWarning(response.ScriptData.JSON);

   }

  });

and i want this in cloud code:
var number = Spark.getdata().number; //maybe this

var number1 = Spark.getdata().number1; // maybe this too

Thank you


Best Answer

Oh, Hi Liam, I'm here to sorry you.

I didnt see the Event Area because at first setting, i was off that feature, and i couldn't find it. Now i see it already.

Thank you


Hi,


For this to work you would need to make sure that you have the attributes defined in your event on the portal. In your case you would need to have the shortCodes configured as "number" and "number1" in the event called "firstEvent". You'd then need to supply the correct type from Unity (number,string, json). Once set up correctly you will be able to retrieve them in Cloud Code with the example you used at the bottom. You can find the updated version of this guide here.


Regards,

Liam

Thanks Liam for quick reply


But could you show me how to define the event with attribute in portal 2? Now its removed, or i can't find where is it or simple how to do it? Could you guide me step by step? Or Am I missing something about this?

Here is from your Portal 2 Overview:
LogEventRequests and LogChallengeEventRequests:

Toggle All has been removed and that function is now carried by the main Request toggling all the secondary requests.

Answer

Oh, Hi Liam, I'm here to sorry you.

I didnt see the Event Area because at first setting, i was off that feature, and i couldn't find it. Now i see it already.

Thank you


1 person likes this

Hi,


No problem, I'm glad to hear you found a solution for this. If you need anything else just let us know.


Regards,

Liam

GSRequestData jsonDataToSend = new GSRequestData();         

jsonDataToSend.AddString("param1", "xxx");      

jsonDataToSend.AddString("param2", "yy");

logEventRequest = new LogEventRequest().SetEventKey("eventname").SetEventAttribute("attributeNname", jsonDataToSend);

Login to post a comment