question

devinci2021 avatar image
devinci2021 asked

How to update players title data from cloud script,

I want to have a cloud function that add CardsID (json object) to a player's titledata called "Cards"

I'm trying to figure out how can I add json to an existing json from cloud script

I'm sending the CardsID as json from unity and call the cloud script

and call this functions


Thanks for helping me

,

CloudScriptPlayer DatadataTitle 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

·
Gosen Gao avatar image
Gosen Gao answered

If you want to update the field “CardsID” under Player Data “Cards” with Cloud Script, you can refer to the code below.

handlers.CTs1 = function (args, context)
{
    let getUserInternalDataResult = server.GetUserInternalData({
        PlayFabId: currentPlayerId,
        Keys: ["Cards"]
    });
    let cardsData = JSON.parse(getUserInternalDataResult.Data["Cards"].Value);
    cardsData.CardsID = args.cardsID;
    server.UpdateUserInternalData({
        PlayFabId: currentPlayerId,
        Data: {"Cards":JSON.stringify(cardsData)}
    });
};
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.

Error rendering WebPanel (widgets/consolidation-widget.ftl): org.hibernate.hql.internal.ast.QuerySyntaxException: AvailableConsolidation is not mapped [from AvailableConsolidation up where up.node = :node]