# Events

Since 3.0 version all events are fully (almost) compatible.\
To use them in your script, simply do this trick:

1. Get the name of event from the [API](https://ci.roinujnosde.me/job/SimpleClans/Javadoc/net/sacredlabyrinth/phaed/simpleclans/events/package-summary.html). Let's say `DisbandClanEvent`.
2. Then, separate it and write on lower case like so: `disband clan` (don't add `event` word!)
3. That's it! Now you can use it in your script.

```yaml
my_first_script:
    type: world
    events:
        on disband clan:
            - narrate "<context.clan> was disbanded!"
```

This trick works with **each event in the API.** Let me show one more examples:

* [HomeRegroupEvent](https://ci.roinujnosde.me/job/SimpleClans/Javadoc/net/sacredlabyrinth/phaed/simpleclans/events/HomeRegroupEvent.html) -> `on home regroup`
* [PlayerHomeClearEvent](https://ci.roinujnosde.me/job/SimpleClans/Javadoc/net/sacredlabyrinth/phaed/simpleclans/events/PlayerHomeClearEvent.html) -> `on player home clear`
* [PreCreateClanEvent](https://ci.roinujnosde.me/job/SimpleClans/Javadoc/net/sacredlabyrinth/phaed/simpleclans/events/PreCreateClanEvent.html) -> `on pre create clan`
* etc.

:warning: One exception here is [ChatEvent](https://ci.roinujnosde.me/job/SimpleClans/Javadoc/net/sacredlabyrinth/phaed/simpleclans/events/ChatEvent.html). The right format is `on clan player chats` (to not confuse with [denizen one](https://meta.denizenscript.com/Docs/Search/chats#player%20chats))

### Event contexts

It's actually almost the same trick as it was with the events:

1. Look for the event's method from the [API](https://ci.roinujnosde.me/job/SimpleClans/Javadoc/net/sacredlabyrinth/phaed/simpleclans/events/package-summary.html). Let's take [ClanBalanceUpdateEvent#getBalance](https://ci.roinujnosde.me/job/SimpleClans/Javadoc/net/sacredlabyrinth/phaed/simpleclans/events/ClanBalanceUpdateEvent.html#getBalance\(\)).
2. Just remove `get` and you're ready!

```yaml
my_first_script:
    type: world
    events:
        on clan balance update:
            - narrate "Clan balance updated! It has <context.balance> money now."
```

:warning: And from now I should disappoint you a bit: it's **not** fully compatible with some contexts. \
Look at the following table:

<table><thead><tr><th>Context</th><th>Value from API</th><th>SCDenizenBridge return</th></tr></thead><tbody><tr><td><pre><code><strong>&#x3C;context.component>
</strong></code></pre></td><td><pre><code><strong>SCComponent
</strong></code></pre></td><td><pre><code><strong>ItemTag (Component's item)
</strong></code></pre></td></tr><tr><td><pre><code><strong>&#x3C;context.rank>
</strong></code></pre></td><td><pre><code><strong>Rank
</strong></code></pre></td><td><pre><code><strong>ElementTag (Rank Name)
</strong></code></pre></td></tr><tr><td><pre><code><strong>&#x3C;context.request>
</strong></code></pre></td><td><pre><code><strong>Request
</strong></code></pre></td><td><pre><code>ElementTag (Request type name)
</code></pre></td></tr><tr><td><pre><code>&#x3C;context.reason>
</code></pre></td><td><pre><code>WarEndEvent.Reason
</code></pre></td><td><pre><code><strong>ElementTag (Reason name)
</strong></code></pre></td></tr><tr><td><pre><code>&#x3C;context.updater>
</code></pre></td><td><pre><code>BankOperator
</code></pre></td><td><pre><code>ElementTag (Operator Name)
</code></pre></td></tr><tr><td><pre><code>&#x3C;context.cause>
</code></pre></td><td><pre><code>ClanBalanceUpdateEvent.Cause
</code></pre></td><td><pre><code>ElementTag (Cause name)
</code></pre></td></tr><tr><td><pre><code>&#x3C;context.war>
</code></pre></td><td><pre><code>War
</code></pre></td><td><pre><code>ListTag(Two warring clans)
</code></pre></td></tr></tbody></table>

### Old docs

#### 2.1

:warning: Don't forget that SCDenizenBridge 3.0.1 doesn't support events from 2.1!\
If you used 2.1 you will be forced to rewrite all your scripts to the latest format.

| Event                     | Contexts                                                              |
| ------------------------- | --------------------------------------------------------------------- |
| `clan ally add`           | `first_clan, second_clan`                                             |
| `clan ally remove`        | `first_clan, second_clan`                                             |
| `clan balance update`     | `clan, clan_balance, clan_new_balance, updater_name, updater_balance` |
| `clanplayer chat`         | `sender, message, receivers`                                          |
| `clan create`             | `clan`                                                                |
| `clan disband`            | `clan`                                                                |
| `clanplayer home regroup` | `clan, issuer`                                                        |
| `clanplayer home set`     | `location, clan, clanplayer`                                          |
| `clanplayer demote`       | `clan, clanplayer`                                                    |
| `clanplayer join`         | `clan, clanplayer`                                                    |
| `clanplayer kick`         | `clan, clanplayer`                                                    |
| `clanplayer kill`         | `attacker, victim`                                                    |
| `clanplayer promote`      | `clan, clanplayer`                                                    |
| `clanplayer teleport`     | `clanplayer, origin, destination`                                     |
| `pre clan create`         | `tag, name`                                                           |
| `pre rank create`         | `clan, rank_name`                                                     |
| `clan rival add`          | `first_clan, second_clan`                                             |
| `clan rival remove`       | `first_clan, second_clan`                                             |
| `clan tag change`         | `tag, clan`                                                           |
| `clan war end`            | `first_clan, second_clan, reason`                                     |
| `frame (<frame>) open`    | `frame`                                                               |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wiki.roinujnosde.me/scdenizenbridge/writing-your-scripts/events.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
