question

DaveTs avatar image
DaveTs asked

[Unreal Engine Blueprints] Cloud function parameter

I'm trying to make a cloudscript call and I'm wandering how to pass parameters. I've created a Jscon objetc, and tried to add string fields, even trygin to encode string to json but nothing happens, no parameter is taken.

Thank's in advance.

CloudScript
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

The FunctionParameter of the request object you pass into the call to ExecuteCloudScript is of type UPlayFabJsonObject. You can see an example of how to use that class in the ExampleProject, here: https://github.com/PlayFab/UnrealBlueprintSDK/blob/ecf6f3d1bb2ce4c64d8480b2f1ebf8c95b388e0e/PlayFabClientSDK/ExampleProject/Plugins/PlayFab/Source/PlayFab/Private/PlayFabJsonObject.cpp.

19 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

DaveTs avatar image DaveTs commented ·

Hi Brendan and thank you for your reply. I've already know I have to create a Json Object, but i don't know how to format it. If i try to decode json I get an error because it can't decode, if I set an array value, nothing is passed to the function. Everytime on the log, the FunctionParameter is empty.

Cheers.

0 Likes 0 ·
brendan avatar image brendan DaveTs commented ·

What you should do is use SetRootObject on the parameter. Can you have a look at this guide (https://github.com/PlayFab/GettingStartedGuides/blob/master/SdkQuickStart/UnrealBpGettingStarted.md)? It walks you through all the basics for how to use our API calls in Blueprints.

0 Likes 0 ·
DaveTs avatar image DaveTs commented ·

Hi @Brendan, I know how to use api calls in BP, the thing is I don't know how to create the json query parameter. I've already created a Json Object in order to plug it into the request, but the json is empty.

0 Likes 0 ·
brendan avatar image brendan DaveTs commented ·

Sorry you're having issues with this. The SetRootObject call takes a shared pointer to an Unreal FJsonObject. Can you help me to understand what you mean by the JSON being "empty" when you use that call to set it up?

0 Likes 0 ·
DaveTs avatar image DaveTs commented ·

The thing (as I understand) is I've to use Construct Json Object in order to have a Json Object to use with the function call, but after create it (I asume It'll be empty) I just try to fill it with the data I need (in this case just an ID, a string). I've tried to use set string field, but since the field doesn't exist it does nothing, and i'm using to use Decode function to give format to Json object, but always fail. Can you tellme how to fill the json object and then what's the correct way to do it?

Thank you.

0 Likes 0 ·
brendan avatar image brendan DaveTs commented ·

Sorry if this seems pedantic, but can you please provide the specifics for how you're instantiating the JSON Object in question, and how you're using SetRootObject to set it as the JSON data for the PlayFab call? We're relatively light on Blueprints-specific expertise, so the more details you can provide, the more likely it is that we'll be able to guide you to the best solution.

0 Likes 0 ·
DaveTs avatar image DaveTs commented ·

Don't worry @Brendan the point is to solve the issue hahaha it's fine. Well, I'll let you know why i'm doing this. The thing is I want to use SharedGroup to create a "party" before joining the match, since the clients aren't yet connected to the server I haven't find the way to achieve this, then i can't add members to the group.

So I though it was a good idea to do this by using a CloudScritp which ads the clients to the shared group, but they have to provide the lobby Id by param, and there is where I'm currently stuck, I don't know how to pass params to the CloudScript call.

I hope you understand the scenario.

Cheers.

0 Likes 0 ·
brendan avatar image brendan DaveTs commented ·

Understood, and there are a few ways you could get players into a server session together, depending on the specifics of your game model. Cloud Script would be the way to set up the info in the Shared Group Data, though I would not recommend adding players to the SGD directly, since that would allow the client to modify the data (letting a hacked client change it to anything). Clients will still be able to read from the SGD, regardless.

With that said, the way to put a standard Unreal JSON Object (FJsonObject) into the UPlayFabJsonObject would be using SetRootObject. If that's not working for you, can you please provide the specifics on how you're currently using that call, so that we can help work out the issue?

0 Likes 0 ·
DaveTs avatar image DaveTs commented ·

Hi @Brendan the thing is I can't find that SetRoot function.

Anyways if you can tell me another way to retrieve players matched with a lobby, but only for the server (asynchronously coz players won't connect till they are ready). The point of adding players IDs to the SGD is to let the players know when the other are ready by setting a field pointing to the each I'd with a booñ value.

Cheers.

,

Hi @Brendan I'm using BP and I can't find SetRoootObject function. Anyways, if you can tell me another way to retrieve the players matched with a lobby (used on the server) but asynchronously since the clients won't connect till everyone is ready. The only point of adding data to see SG is to use it to set players state ready.

Cheers

0 Likes 0 ·
DaveTs avatar image DaveTs DaveTs commented ·

Double post sorry

0 Likes 0 ·
brendan avatar image brendan DaveTs commented ·

What you're attempting to create is a party join system, so my first question would be, how are players discovering each other to make the party? If you already have some info passing between players, the simplest thing to do would be to have one player join the server, and have the others join the same one (send the info from that player on the Lobby ID). Alternately, if all they know are each others' PlayFab IDs, you could have one player join, and use the Server Tag system to set a tag with that player's PlayFab ID, so that the others can find it. Really though, what it comes down to is what the actual gameplay experience should be, and what info you have to start. Knowing that would help to define the best solution for you.

0 Likes 0 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.