question

jacob avatar image
jacob asked

Unreal 4 Blueprints - Setting stats via Execute Cloud Script node

Hello,

I have been following this tutorial: "http://shootertutorial.com/2016/01/30/adding-playfab-online-leaderboards/" and have found it very useful. Only some parts of it seem outdated but I am not sure how outdated. My current problem is I am attempting to use Cloud Script for writing stats to a player when they get a high score in a game.

What I can do:

I have downloaded the example project and in both mine and it, I can login a user without issues and call the generic "helloWorld" function via the ExecuteCloudScript node. The response I get back from the "helloWorld" function is the proper message, extracted from the messageValue.

Concern:

1. In the tutorial I am referencing, it suggest using a GetCloudURL, but I don't think this function exists anymore, so is it irrelevant now and unconnected to my issues?

2. I was told in the tutorial that all I need is the Client PlayFab plugin for UE4 blueprints, but do I need to do anything in the PlayFab dev site? I created a CloudScript that handles the UpdateUserStatistics, so I do not need to allow Clients to post statistics, correct?

Where my problems are:

1. I have been looking through a lot of this section and have found out some cool things, such as using Cloud Scripts for individual players, but I am not entirely sure how this works. When I attempt to pass in the arguments to my function which takes in a float and a string (highscore value, gametype), there should technically be two arguments (e.g. "55, chess") but it only accepts one and in number form (e.g. "55"). Perhaps my Cloud Script code is outdated? I took it directly from the tutorial and tweaked the variables, as I need a float and string structure.

2. I have made sure my CloudScript uses the same variable names as the ones I am setting the JSON Object's Number and String Fields. I have also made sure that my CloudScript function's name is properly being delivered into the function name param when I Make the ClientExecuteCloudScriptRequest. Even though the ExecuteCloudScript node returns false on "Has Error" and trigger's its On Success event, my error code is: 1065353216. The ExecuteCloudScript node has no function name upon the success event and the messageValue is empty, which tells me my Cloud Script is failing to set the player's stats. Any thoughts on this?

3. It is my understanding from the tutorial that to make leader boards work, all one has to do is generate some stats by calling UpdateUserStatistics, which I do in my CloudScript which is executed via bp node, and then they can call the GetLeaderboard node using that string field on the stats, and that will get all players with those stats and automatically organize them? If so, then that is pretty cool. Will it auto generate a leaderboard on the PlayFab dev sit with that name then, or do I need to generate that as well?


Any help is appreciated. Thanks,

Jacob

CloudScript
cloudscript.png (21.4 KiB)
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

Well, that's not a sample we created or support, but we did get a chance to discuss the implementation of the ShooterTutorial back when it was created, and we greatly appreciate the effort that went into it.

Now, for your concerns 1 and 2, yes, a few things have changed: First off, the way to call Cloud Script is via a single call to ExecuteCloudScript these days - there's no need to query for a URL. Second, it's UpdatePlayerStatistics, as we've made some improvements. But yes, we would always recommend posting stats via Cloud Script, rather than letting the client do it directly, as otherwise a hacked client could write whatever it wants (the same applies to user data). To develop in Unreal Blueprints, we would recommend using our SDK, but no, there isn't anything else you need to download.

For the issues you're seeing:

1. Parameters: The ExecuteCloudScript call takes a FunctionParameter input, which is where you provide everything you want to be an argument in the handler (as a JSON object). I can't really make out what your Blueprint shows for that call, but long story short, it must be a properly formatted JSON object to be translated into the appropriate parameters in the args for the call.

2. We actually don't have an error code 1065353216. But given that that's an extremely round number in hexadecimal (0x3F800000 - also not an error code in our system), that seems pretty suspicious. Could you try just calling the Cloud Script from Postman, or a similar tool, to check the results?

3. We do automatically generate leaderboards for you and your development team on our site, but that's only meant for use by developers. For your users, you can use the leaderboard query API calls to get the details on players for in-game experiences or websites.

2 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.

jacob avatar image jacob commented ·

Thanks for your response Brendan.

My concerns are alleviated. By using the "Run Cloudscript" function on PlayFab's wonderful developer sit I was able to debug where my issue lied, and have now run into my actual problem.

Problem:

I am trying to call UpdatePlayerStatistics with a StatisticName and Value that is pull from the args which is from the JSON Object I am passing into the CloudScript function. Using anything besides hard coded values, such as the example provided works, but I need these values to come from the arguments.

Working, (but hard coded values):

server.UpdatePlayerStatistics({ PlayFabId: currentPlayerId, Statistics: [{ "StatisticName": "xp", "Value": 10 }] });

What I desire (dynamic values):

score = args.hiscore;

gametypename = args.gametype;

server.UpdatePlayerStatistics({ PlayFabId: currentPlayerId, Statistics: [{ "StatisticName": gametypename, "Value": score}] });
How would I accomplish this without getting API errors?Thanks,Jacob
0 Likes 0 ·
jacob avatar image jacob jacob commented ·

I figured out this problem as well. I was using the wrong parameter name for my argument (highscore, instead of hiscore).

0 Likes 0 ·

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.