question

Ozan Yilmaz avatar image
Ozan Yilmaz asked

Cannot Add Read Only and Internal Data via Cloudscript?

Hello everyone,

I am trying to add default data for every new players. I created a rule (player_added_title) and set its cloudscript function "NewUserAdded". It looks like the function is called but it gives me error.

- I want to add some private both read only and internal data to every new players. What is wrong in the code?

- Also, where can I see the error this code is throwing?

Here is the code:

handlers.NewUserAdded = function (args, context) {
    var addReadonlyDataRequest = {
        "PlayfabId": id,
        "Data": { 
            "NextRace" : "Now", 
            "NextBuyPart" : "Now",
            "NextBuyCar" : "Now"
        },
        "Permission": "Private"
    };
    server.UpdateUserReadOnlyData(addReadonlyDataRequest);
    
    var addInternalDataRequest = {
        "PlayfabId": id,
        "Data": { "IsFirstRace" : "0" },
        "Permission": "Private"
    };
    server.UpdateUserInternalData(addInternalDataRequest);
}
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

·
Ozan Yilmaz avatar image
Ozan Yilmaz answered

My bad. I used "id" instead of "currentPlayerId". Syntax error

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.