question

Tahir avatar image
Tahir asked

[UNITY] Help with returning/parsing results of ExecuteCloudScriptResult

Hello, I'm a bit new to PlayFab and I am having some difficulty with ExecuteCloudScriptResult.

I'm trying to return a list of values. Preferably a dictionary and be able to access that in unity. Ideally

I've had success using the clientAPI but now I'm looking to cloudscript to help with cheating.

CloudScript:

var UpdateReadOnlyDataResponse = UpdateReadOnlyData(var1, var2);

return { response: UpdateReadOnlyDataResponse };
function UpdateReadOnlyData(gear, hbar)
{
    var UpdateUserReadOnlyDataRequest = {
        "PlayFabId": currentPlayerId,
        "Data": {}
    };
	
	 UpdateUserReadOnlyDataRequest.Data["gear"] = gear;
	 UpdateUserReadOnlyDataRequest.Data["hotbar"] = hbar;


    var UpdateUserReadOnlyDataResponse = server.UpdateUserReadOnlyData(UpdateUserReadOnlyDataRequest);


    return UpdateUserReadOnlyDataResponse.Data;
}

Ideally I'd like to return UpdateUserReadOnlyDataResponse.Data and be able to parse it properly, accessing each key.

In Unity:

Debug.Log (result.CustomData);
Debug.Log (result.FunctionResult);

CustomData returns null.

FunctionResult returns "{ }".

My CloudScript functions seem to be working fine, I'm just having problems returning and using the data in unity.

unity3dCloudScript
1 comment
10 |1200

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

Tahir avatar image Tahir commented ·

I could use some help with this, I have a live game that is currently under attack by an hacker with way too much time on his hands, he's effectively ran my playerbase away.

0 Likes 0 ·

1 Answer

·
Andy avatar image
Andy answered

I'd recommend parsing the server API call response within your cloudscript and then explicitly returning the values you're interested in, instead of trying to just pass through the response. There could also be problems on your response handling code in Unity, of course.

Have a look at the tutorial here: https://api.playfab.com/docs/tutorials/landing-automation/writing-custom-cloud-script

1 comment
10 |1200

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

Andy avatar image Andy ♦♦ commented ·

Additionally, it's worth pointing out 2 things:

  1. UpdateUserReadOnlyData doesn't return much of anything (just the version of the data)
  2. The way you've architected this is still not secure. At minimum, you need to be doing some form of validation or checking of the data being passed in from the client. Bounds checking, call frequency verification. Are there other stats or values delivered in more secure ways that you can use to help in verification?
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.