question

el-inside avatar image
el-inside asked

cloudscript execution

Hello, sorry for my basic questions...

Can somebody tell me what's wrong with my execution?

When i run the cloudscript on the portal for a player it sets the keys correct, but my execution code does not work.

    private static void StartCloudSetPlayerDataDefault()
    {
        var pfid = new GetAccountInfoRequest();
        PlayFabClientAPI.GetAccountInfo(pfid, OnpfidResult, OnpfidError);
    }

    private static void OnpfidError(PlayFabError obj)
    {
        Debug.Log("get pfid failed");
    }

    private static void OnpfidResult(GetAccountInfoResult obj)
    {
        Debug.Log(obj.AccountInfo.PlayFabId);
        PlayFabClientAPI.ExecuteCloudScript(new ExecuteCloudScriptRequest()
        {
            FunctionName = "SetPlayerDataDefault", // Arbitrary function name (must exist in your uploaded cloud.js file)
            FunctionParameter = new { name = obj.AccountInfo.PlayFabId }, // The parameter provided to your function
            GeneratePlayStreamEvent = true, // Optional - Shows this event in PlayStream
        }, OnSetPlayerDataResult, OnSetPlayerDataError);
    }

Here is my Cloudscript:

handlers.setPlayerDataDefault = function (args, context) {
    var request = {
        PlayFabId: currentPlayerId, 
        Data: {
                "hp": "333",
                "level": "1",
            }
    };
    var playerStatResult = server.UpdateUserReadOnlyData(request);
};
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

·
el-inside avatar image
el-inside answered

i got my mystake, closing the request without any data :D

(newExecuteCloudScriptRequest()
10 |1200

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

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.