> For the complete documentation index, see [llms.txt](https://veil-development.gitbook.io/veil-development-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://veil-development.gitbook.io/veil-development-documentation/paid-resources/government-system/listeners-and-exports.md).

# Listeners and Exports

**What are listeners?**\
Listeners are function references that get triggered when a specific action is done by the system, and can be registered on the `Server Side Only`\
\
**Available Listeners**\
These are the current listeners available to you

* onCaseCreation
* onCaseUpdate
* onCaseVerdict
* onCaseDismissal
* onCaseAdjournment
* onCaseHearingScheduled

**Example**

```lua
local listener = exports['veil-government']:registerListener('onCaseCreation', function(payload)
    print('Case event received')
    print(payload)
    if (type(payload) == 'table') then
        for k,v in pairs(payload) do
            print(k,v)
        end
    end
end)
```

This outputs the following

```lua
Case event received
table: 00000000495CF7C0
id 187472
plaintiff G3BY378F
plaintiffName John Doe
defendant BF2H378F
defendantName John Dae
date 2024/01/01 12:00:00 PM
verdict 
judge
judgeName
jurors
charges
evidence
witnesses
notes
status Pending
history table: 0000000278H3D2
penalty table: 000000072H783D
isClosed false
```

The following are the listeners and the data they provide

```
# onCaseCreation -> [id: string, plaintiff: string, plaintiffName: string, defendant: string, defendantName: string, date: string, verdict: string, judge: string, judgeName: string, jurors: {}, charges: { count: number, type: "civil" | "criminal", degree: "civil-infraction" | "misdemeanor" | "felony", name: string }, evidence: { id: string, name: string, type: "image" | "video" "audio" | "document", url: string }, witnesses: { identifier: string, name: string, side: "plaintiff" | "defendant" }, notes: string, status: string, history: { date: string, action: string, action_by: string }, penalty: { fine: number, jailtime: number }, isClosed: boolean]
# onCaseUpdate -> [id: string, plaintiff: string, plaintiffName: string, defendant: string, defendantName: string, date: string, verdict: string, judge: string, judgeName: string, jurors: {}, charges: { count: number, type: "civil" | "criminal", degree: "civil-infraction" | "misdemeanor" | "felony", name: string }, evidence: { id: string, name: string, type: "image" | "video" "audio" | "document", url: string }, witnesses: { identifier: string, name: string, side: "plaintiff" | "defendant" }, notes: string, status: string, history: { date: string, action: string, action_by: string }, penalty: { fine: number, jailtime: number }, isClosed: boolean]
# onCaseVerdict -> [id: string, plaintiff: string, plaintiffName: string, defendant: string, defendantName: string, date: string, verdict: string, judge: string, judgeName: string, jurors: {}, charges: { count: number, type: "civil" | "criminal", degree: "civil-infraction" | "misdemeanor" | "felony", name: string }, evidence: { id: string, name: string, type: "image" | "video" "audio" | "document", url: string }, witnesses: { identifier: string, name: string, side: "plaintiff" | "defendant" }, notes: string, status: string, history: { date: string, action: string, action_by: string }, penalty: { fine: number, jailtime: number }, isClosed: boolean]
# onCaseDismissal -> [id: string, plaintiff: string, plaintiffName: string, defendant: string, defendantName: string, date: string, verdict: string, judge: string, judgeName: string, jurors: {}, charges: { count: number, type: "civil" | "criminal", degree: "civil-infraction" | "misdemeanor" | "felony", name: string }, evidence: { id: string, name: string, type: "image" | "video" "audio" | "document", url: string }, witnesses: { identifier: string, name: string, side: "plaintiff" | "defendant" }, notes: string, status: string, history: { date: string, action: string, action_by: string }, penalty: { fine: number, jailtime: number }, isClosed: boolean]
# onCaseAdjournment -> [id: string, plaintiff: string, plaintiffName: string, defendant: string, defendantName: string, date: string, verdict: string, judge: string, judgeName: string, jurors: {}, charges: { count: number, type: "civil" | "criminal", degree: "civil-infraction" | "misdemeanor" | "felony", name: string }, evidence: { id: string, name: string, type: "image" | "video" "audio" | "document", url: string }, witnesses: { identifier: string, name: string, side: "plaintiff" | "defendant" }, notes: string, status: string, history: { date: string, action: string, action_by: string }, penalty: { fine: number, jailtime: number }, isClosed: boolean]
# onCaseHearingScheduled -> [id: string, plaintiff: string, plaintiffName: string, defendant: string, defendantName: string, date: string, verdict: string, judge: string, judgeName: string, jurors: {}, charges: { count: number, type: "civil" | "criminal", degree: "civil-infraction" | "misdemeanor" | "felony", name: string }, evidence: { id: string, name: string, type: "image" | "video" "audio" | "document", url: string }, witnesses: { identifier: string, name: string, side: "plaintiff" | "defendant" }, notes: string, status: string, history: { date: string, action: string, action_by: string }, penalty: { fine: number, jailtime: number }, isClosed: boolean]
```

The following are the exports available

```
# getTaxData(identifier: string) -> [identifier: string, assets: number, income: number, amountDue: number; dueDate: string, status: "paid" | "unpaid" | "late", actions?: { type: "vehicle-seized" | "property-seized" | "bank-account-frozen" | "none" }, content: string, asset: [ { name: string, label: string, value: number, identifier?: string } ], name?: string]
# onVehiclePurchase(src: number, price: number) -> void
# onMarketSale(src: number, price: number -> void
# onPropertyTransaction(src: number, price: number) -> void
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://veil-development.gitbook.io/veil-development-documentation/paid-resources/government-system/listeners-and-exports.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
