Donations #

Players can request donations for Refill Tickets in Merge Chef 3D by Kyoso Interactive.
Players can request donations for Refill Tickets in Merge Chef 3D by Kyoso Interactive.

Donations are a way for players to share in-game items, such as currencies, consumables, or collectables. Each user has their own storage object that represents the donations they have, which may be active or expired.

You can customize the donation rules to meet your social and gameplay requirements, such as restricting the number of times a user can send contributions to another user, how many donations can be active at any time, or whether donations can only be made between users who are part of a team, are friends, or have completed some other kind of gameplay together.

See the customization properties for Donations here.

Listing available donations #

You can list available donations.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
foreach (var donationKvp in economySystem.Donations)
{
    var id = donationKvp.Key;
    var donation = donationKvp.Value;
    
    Debug.Log($"Donation {id} - {donation.Name}. Rewards: ");

    foreach (var currency in donation.Reward.Currencies)
    {
        Debug.Log($"{currency.Key}: {currency.Value}");
    }
    
    foreach (var consumable in donation.Reward.Consumables)
    {
        Debug.Log($"{consumable.Key}: {consumable.Value}");
    }
    
    foreach (var collectable in donation.Reward.Collectables)
    {
        Debug.Log(collectable);
    }
}

You can also list donations in several other ways.

By donation ids:

1
var donationsKvp = await economySystem.GetDonationsAsync(new [] { "<donationId1>", "<donationId2>" });

By team (using the Team System).

1
2
var team = teamSystem.Team;
var donationsKvp = await economySystem.GetDonationsAsync(team);

Or by friends list.

1
2
var friendsList = await nakamaSystem.Client.ListFriendsAsync(nakamaSystem.Session);
var donationsKvp = await economySystem.GetDonationsAsync(friendsList);

Requesting a donation #

You can request a donation for a user.

1
await economySystem.RequestDonationAsync("<donationId1>");

Donating to a user #

You can make a donation to a particular user.

1
await economySystem.DonateAsync("<donationId>", "<targetUserId>");

Claiming rewards for donations #

You can claim rewards for completed donations.

1
await economySystem.ClaimDonationsAsync(new[] {"<donationId1>", "<donationId2>"});