> For the complete documentation index, see [llms.txt](/llms.txt)

# Usage Limits

Handles allowances such as 'three times a day': one reset schedule, a separate counter per thing being counted, and a maximum supplied by the caller.




**About this demo**

The demo signs in automatically with an anonymous account. The account is shared across every demo in the showroom, so items and currency you get in one demo carry over to the others. Loading takes a moment. If the frame is too small, open the demo in a new tab.

## Overview

The page shows four usage counters and two reset schedules (daily and weekly). Counters 1 to 3 follow the same daily schedule but are counted separately, while Counter 4 follows the weekly one. The maximum is supplied by the press rather than stored on the counter, so Counter 1 carries two ceilings at once: three free uses, and up to five with an ad view.

## How to try it

1. **Reset schedules** shows the daily schedule, **Resets every day at 00:00 UTC**, and the weekly one, **Resets every Monday at 00:00 UTC**. Each counter's **Next reset in** counts down to its next reset.
1. Press **Use free** under **Counter 1 (daily reset)** three times; **Usage** reads **3 used. Free uses stop at 3, ad-backed uses at 5.**, and **Watch an ad to use** replaces **Use free**.
1. Press **Watch an ad to use**; an **Advertisement** panel opens (no real ad plays). Wait 5 seconds and press **I finished watching**: a view point is granted and then spent on one use. At five uses **Nothing left** appears and no more uses are possible.
1. Pressing **Use free** under **Counter 2 (daily reset)** leaves Counter 1's count unchanged. Counter 2 closes at 4 uses, Counter 3 at 6, and the weekly **Counter 4 (weekly reset)** at 1; once closed, **No free uses left** appears.
1. Press **Reset every allowance** under **Counter 1 (daily reset)** to put all four counters back to 0, instead of waiting for midnight UTC (or Monday, for Counter 4).

Counts are kept on the account shared by all showroom demos. If a counter is already closed, **Reset every allowance** lets you start over at any time.

## GS2 services used

- [GS2-Limit](/microservices/limit/): GS2-Limit models define the daily (00:00 UTC) and weekly (Monday 00:00 UTC) reset schedules and count four counters per player. The maximum is passed with each count-up request.
- [GS2-Exchange](/microservices/exchange/): GS2-Exchange rates define the transactions for a free use, an ad-backed use that also spends a view point, and resetting every counter, executed server-side atomically.
- [GS2-AdReward](/microservices/ad_reward/): **Watch an ad to use** spends one GS2-AdReward view point per ad-backed use. The point is granted when the view is confirmed, the same way as in the ads demo.

## Use it in GS2 Studio

In GS2 Studio's Simple mode, open **Add features** and press **Add** on **Usage Limits** to bring this feature into your own project. To point at the package directly, choose **Add from GitHub** and enter the package below.

```text
https://github.com/gs2io/gs2-studio-package/tree/main/foundation-economy-limit/packages/foundation-economy-limit
```

- Owner: `gs2io`
- Repository: `gs2-studio-package`
- Subdirectory: `foundation-economy-limit/packages/foundation-economy-limit`

## Source code

- Demo project: <https://github.com/gs2io/gs2-studio-package/tree/main/foundation-economy-limit/live-demo>
- Feature package: <https://github.com/gs2io/gs2-studio-package/tree/main/foundation-economy-limit>



