question

monti avatar image
monti asked

Hi, i need to create a group (guild system) in construct 3, using playfab cloud script API, someone have a code or template? because i try with this code but in playstream say "failed", and what i need to do for "unlock" api?

handlers.CreateSharedGroup = function(args, context){ try{ server.CreateSharedGroup({SharedGroupId: "test"}); } catch(err){ var message = "Could not create group" return {messageValue: message}; } var message = "Hello " + currentPlayerId + "!"; return {messageValue: message}; }

2 comments
10 |1200

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

Seth Du avatar image Seth Du ♦ commented ·

May I know the detailed error message? I don't see any obvious error in your code, but possibly it is caused by Group ID. As you have hard-coded "test" as Group ID, you may try to replace this ID with a randomly generated number or string.

0 Likes 0 ·
monti avatar image monti Seth Du ♦ commented ·

Exactly! The problem is that, now that I solved it, it doesn't create the group entity anyway, how do I use the string "ExecuteCloudScript" to call groups api?

in that case can you write me the command / string so I can implement it?

0 Likes 0 ·
Seth Du avatar image
Seth Du answered

Sorry for the late response. According to the error message, the cause is the ID of shared group. Please understand that you cannot use duplicate ID and if you hard-code Shared Group ID, this function can only run once. The subsequent execution will return error due to the same reason -- shared group ID already exists (though PlayFab only returns InvalidSharedGroupId).

To solve this issue, you may implement a function that generates a random string/number or GUID for the group. Otherwise, you can create this ID according to certain patten. The point is you cannot use an existing ID.

10 |1200

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

monti avatar image
monti answered

this is the detailed error message

{

    "EventName": "player_executed_cloudscript",
    "Source": "CloudScript",
    "FunctionName": "SharedGroupId",
    "CloudScriptExecutionResult": {
        "FunctionName": "SharedGroupId",
        "Revision": 84,
        "FunctionResult": {
            "messageValue": "Could not create group"
        },
        "FunctionResultTooLarge": null,
        "Logs": [
            {
                "Level": "Error",
                "Message": "PlayFab API request error",
                "Data": {
                    "api": "/Server/CreateSharedGroup",
                    "request": {
                        "SharedGroupId": "987123"
                    },
                    "result": null,
                    "apiError": {
                        "code": 400,
                        "status": "BadRequest",
                        "retryAfterSeconds": null,
                        "error": "InvalidSharedGroupId",
                        "errorCode": 1088,
                        "errorMessage": "InvalidSharedGroupId",
                        "errorHash": null,
                        "errorDetails": null
                    }
                }
            }
        ],
        "LogsTooLarge": null,
        "ExecutionTimeSeconds": 0.0287511,
        "ProcessorTimeSeconds": 0.0052859,
        "MemoryConsumedBytes": 267552,
        "APIRequestsIssued": 1,
        "HttpRequestsIssued": 0,
        "Error": null
    },
    "EventNamespace": "com.playfab",
    "EntityType": "player",
    "TitleId": "D1D36",
    "EntityId": "9DE53A278E3C8BBA",
    "EventId": "a5ae9f6ab1ed4c94bcdf2b7c72f0341e",
    "SourceType": "BackEnd",
    "Timestamp": "2021-10-01T10:12:31.9173885Z",
    "History": null,
    "CustomTags": null,
    "Reserved": null,
    "PlayFabEnvironment": {
        "Vertical": "master",
        "Cloud": "main",
        "Application": "logicserver",
        "Commit": "7c2bed3"
    }
}
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.