question

Permata Digital avatar image
Permata Digital asked

Get, Add and Set Tittle Data via CloudScript

Hello, I want too Get the tittle data and add it with the new data from unit. After that, I want to set the new value to the tittle data. How can I achieve it?
As I can't click the Cloud Script button in the tutorial, and I can't find any tutorial for cloud script.

CloudScriptTitle Data
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

·
Seth Du avatar image
Seth Du answered

It will be better to create a title and implement Cloud Script by yourself. Add return sentences in your functions and set “GeneratePlayStreamEvent” as true in the request if you are using Client API ExecuteCloudScript, so that you may see the detailed execution result in the PlayStream Event monitor. I am not sure which documentation you are reading but you may write a function like this:

handlers.titledataTest = function (context) {
    // set the key
    var setTitleDataRequest = {
        "Key": "key1",
        "Value": "666"
    };
    var setTitleDataResponse = server.SetTitleData(setTitleDataRequest);

    // get the key
    var getTitleDataRequest ={ "Keys": ["key1"] };
    var getTitleDataResponse = server.GetTitleData(getTitleDataRequest);
    if (!getTitleDataResponse.Data.hasOwnProperty("key1")) {
        log.error("key not found. Exiting...");
        return JSON.stringify([]);
    }
    else {
        return getTitleDataResponse.Data.key1
    }
}

If you are new to PlayFab service, we highly recommend you to make use of RESTful API testing tools like Postman to learn PlayFab. For more information, please refer to: https://docs.microsoft.com/en-us/gaming/playfab/sdks/postman/.

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.

Cullis avatar image Cullis commented ·

Thank you this helped me so much!!!

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.