Sign In Register

How can we help you today?

Start a new topic

UE4 - Adding State-List to GS ListChallengeRequest

We got a recent ticket about this, so we decided to put the answer up here as a small tutorial.


I'll go through them here, but the blueprints get messy, so I'll break them down into pieces instead of just showing you the whole lot.

You will need to setup some challenges and issue them to the player you are authenticating with in UE4 in order for this to work. If you call ListChallengeRequest by a player who is not involved in any challenges you will always get null back in the script-data, so you should set this up first.


To begin with i have setup the 'GS ListChallengeRequest' Node as below, and attached the response JSON string to print out to the screen. This is just for debugging, so i know exactly what i am receiving and if its correct or not. Note that ive set the 'State' field to 'null' so it ignores whatever is in there.



The first step is to create a new 'GameSparks Request Array' variable and set the variable type to 'GameSparks Request Array Reference'.



Now drag that variable into your blueprint and select 'Set'...

Before we do anything we need to instantiate that variable with the 'Create GameSparksRequestArray' Node.
(In my example i have this request setup to trigger when i click on a button, so you will see the OnClick event handler in the image too)



Next you need to create a 'Get String Array' Node.
You can find this under Variables -> GameSparks -> Request Params (when you drag off the output and unclick you can search for it in the option-list that appears, that's the easiest way to find it)
While you do this you can hook up the output of the Setter to this node, and hook the same output to the input of the 'GS ListChallengeRequest' marked 'States'.



The next step is to insert the two attributes into that array.
Note after I've set array reference i insert the first element, then the second, and then call the 'GS ListMessageRequest'. This is because i want to make sure that those elements are in the array before we send it.



Now you should be good to go.
So long as you have some challenges this player is in, you should get the JSON string printed out to the console....



In the output log you will also see the form you send to the game, and this should look identical to the one you'd use to test this in the test-harness. So if you have further problems you can always use the test-harness and compare these two forms.




1 Comment

If you cant find the 'Create GameSparksRequestArray' ....

UE4 is very search-sensitive with those fields so you'll have to put the 'Create' in first or you wont find it, i had similar problems looking for what i needed myself while i was doing the previous answer for you.

If you are still having problems finding it, you can search the palette...



 

Login to post a comment