> For the complete documentation index, see [llms.txt](https://docs.allout.game/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.allout.game/all-out-docs/docs-zh/bian-xian/in-game-ads.md).

# 游戏内广告

### 激励式

激励式广告是可选广告，玩家可以观看以在你的游戏中获得某些奖励。例如，你可以设置一个奖品转盘，玩家通过观看广告来旋转转盘，从而有机会在你的游戏中赢得额外金币或道具。

{% hint style="warning" %}
广告收入目前不计入收益分成分配，尽管如果你的游戏已获得显著热度，也可以进行定制安排。更多信息请联系我们！
{% endhint %}

#### API 参考

```go
Ads :: struct {
    prompt_rewarded_ad :: proc(
        player: Player,
        reward_id: string,
        title: string,
        description: string,
        texture: Texture_Asset
    );

    is_ad_showing :: proc() -> bool;
}
```

为每个奖励使用一个稳定的 `reward_id` 。只从 `ao_ads_reward_handler`授予奖励，它会在平台报告激励式广告已完成后运行：

```go
show_coin_ad :: proc(player: Player) {
    if Ads.is_ad_showing() return;

    icon := get_asset(Texture_Asset, "ui/coin.png");
    Ads.prompt_rewarded_ad(
        player,
        "coins_100",
        "获得 100 枚金币",
        "观看广告以获得 100 枚金币。",
        icon
    );
}

ao_ads_reward_handler :: proc(player: Player, reward_id: string) -> bool {
    if reward_id != "coins_100" return false;

    Economy.deposit_currency(player, "Coins", 100);
    return true;
}
```

在使用此示例之前，请先注册该货币；参见 [Economy](/all-out-docs/docs-zh/shu-ju-yu-chi-jiu-hua/economy.md). 返回 `true` 仅在奖励已发放后。若为未知 ID 或无法完成发放，则返回 `false` 。

### 插屏

插屏广告会在回合之间或游戏低活跃时段展示，以产生收入，但不会直接奖励玩家。

例如，你可以在《谋杀之谜》的每一轮结束后显示插屏广告，因为玩家本来就要等待下一轮开始。
