> For the complete documentation index, see [llms.txt](https://docs.redutzu.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.redutzu.com/resources/redutzu-mdt/exports-events/server-exports/incidents.md).

# Incidents

Here, you'll find key exports for managing incidents. These exports allow you to create, update, and delete incidents as needed.

***

## Type

<pre class="language-typescript"><code class="lang-typescript"><strong>type Incident = {
</strong>    id: number,
    name: string,
    description: string, // stringified JSON
    vehicles: string[],
    evidences: number[],
    players: {
        identifier: string,
        name: string
    }[],
    victims: {
        identifier: string,
        name: string
    }[],
    cops: {
        identifier: string,
        name: string
    }[],
    charges: {
        list: { id: number, name: string }[],
        reduction: {
            fine: 50,
            jail: 70
        },
        amount: {
            fine: 15000,
            jail: 60
        }
    },
    createdAt: string
}
</code></pre>

***

## Exports

### Search for an incident

<pre class="language-lua"><code class="lang-lua"><strong>-- It returns the incident data
</strong><strong>exports['redutzu-mdt']:SearchIncident(id)
</strong></code></pre>

```lua
local incident = exports['redutzu-mdt']:SearchIncident(1)
print(incident.name)
```

***

### Create an incident

```lua
-- It returns the id of the created incident
exports['redutzu-mdt']:CreateIncident(data, sender)
```

```lua
RegisterCommand('createIncident', function(source)
    exports['redutzu-mdt']:CreateIncident({
        name = 'Incident Name',
        description = '[]',
        players = { 'identifier' },
        victims = { 'identifier' },
        cops = { 'identifier' },
        vehicles = { 'plate' },
        evidences = { 1, 5 },
        charges = {
            list = { 2, 4, 8 },
            amount = { fine = 15000, jail = 50 },
            reduction = { fine = 35, jail = 80 }
        }
    }, source)
end, false)
```

***

### Update an incident

<pre class="language-lua"><code class="lang-lua"><strong>-- It returns a boolean (if it was successfully updated)
</strong>exports['redutzu-mdt']:UpdateIncident(id, data)
</code></pre>

```lua
local success = exports['redutzu-mdt']:UpdateIncident(1, {
    name = 'Updated Incident',
    vehicles = { 'XYZ987' }
})

if not success then
    print('There was an error updating the incident')
    return
end

print('Incident updated')
```

***

### Delete an incident

```lua
-- It returns a boolean (if it was successfully deleted)
exports['redutzu-mdt']:DeleteIncident(id)
```

```lua
local success = exports['redutzu-mdt']:DeleteIncident(1)

if not success then
    print('There was an error deleting the incident')
    return
end

print('Incident deleted')
```


---

# 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://docs.redutzu.com/resources/redutzu-mdt/exports-events/server-exports/incidents.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.
