# Warrants

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

***

## Type

```typescript
type Warrant = {
    id: number,
    reason: string,
    house: string | number, // depends on your housing script
    date: number,
    active: boolean,
    createdAt: string,
    tag?: {
        identifier: string,
        label: string,
        color: string
    },
    players: {
        identifier: string,
        name: string
    }[]
}
```

## Exports

### SearchWarrant

```lua
exports['redutzu-mdt']:SearchWarrant(id: number) // WarrantType | null
```

### CreateWarrant

```lua
exports['redutzu-mdt']:CreateWarrant({
  reason = 'Warrant reason',
  players = { 'license:1234', 'license:4321' }, -- array of identifiers/citizenids
  house = 1, -- depends on your housing script (usually the id)
  tag = 'tag identifier',
  date = 1716935068 -- javascript timestamp (this is the starting date)
}) -- number (id)
```

### UpdateWarrant

```lua
-- It returns a boolean (if it was successfully updated)
exports['redutzu-mdt']:UpdateWarrant(id, {
  reason = 'New reason',
  players = { 'license:0000' }
}) -- boolean
```

```lua
local success = exports['redutzu-mdt']:UpdateWarrant(1, {
    reason = 'New reason',
    players = { 'license:0000' }
})

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

print('Warrant updated')
```

### DeleteWarrant

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

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

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

print('Warrant deleted')
```
