question

Max Guernsey, III avatar image
Max Guernsey, III asked

What is the best way to create a segment-sensitive drop table?

I'm wondering what the best way to create the impression of a segment-sensitive drop table. For instance, I would like to have my consolation prize drop table feed users better items for the first seventy-two hours.

The best method I can currently imagine is to have a dictionary in the title data mapping segments to drop table names and a default drop table for any given roles.

Is there something better?

Player Inventory
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

·
Sarah Zhang avatar image
Sarah Zhang answered

As the documentation Drop tables says, you need to use the API method GetRandomResultTables or EvaluateRandomResultTable on the server-side to get the result of the table, then you need to grant the result items on the server-side too. The API methods about Drop tables can’t be calledby clients directly. Since the entire granting process requires the server‘s or Cloud Scripts participation, you can add the condition judgment in the server-side to grant different items to players in the different segments. Combine your last previous question, the code of CloudScript function would be something like this. After players call the API ExecuteCloudScript to execute this function “EvaluateTable”, server-side would judge their segments and evaluate the corresponding drop tables and grant the item. You can refer to the documentation Writing custom CloudScript to write the custom CloudScript function.

handlers.EvaluateTable = function (args, context) {

    var playerSegmentsResult = server.GetPlayerSegments({
        PlayFabId: currentPlayerId
    });
    var playerSegments = playerSegmentsResult.Segments;

    var segmentsNamelist = [];
    playerSegments.forEach(function (currentValue) {
        segmentsNamelist.push(currentValue.Name);
    });
    //Use your Segement's name.
    if (segmentsNamelist.includes("72 Hours Active Players")) {
        //Use your Drop Table's name. 
        return EvaluateTable("BetterItemTable", currentPlayerId);
    } else {
        //Use your Drop Table's name. 
        return EvaluateTable("NormalItemTable", currentPlayerId);
    }

}

function EvaluateTable(tableId, currentPlayerId) {


    var evaluateTableResult = server.EvaluateRandomResultTable({
        TableId: tableId
    });
    var itemId = evaluateTableResult.ResultItemId;

    //Use your Item's name. 
    if (itemId == "EmptyItem") {
        return "Granted nothing."
    } else {
        var request = {
            PlayFabId: currentPlayerId,
            ItemIds: [itemId]
        }
        var GrantResult = server.GrantItemsToUser(request);
        return "Granted " + itemId;
    }

}
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.

Max Guernsey, III avatar image Max Guernsey, III commented ·

For the next person: the short version of this answer is:

Use different drop tables and make some kind of decision about which one to use in your own code.

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.