> For the complete documentation index, see [llms.txt](https://tgiann.gitbook.io/tgiann/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tgiann.gitbook.io/tgiann/scripts/tgiann-policealert/exports.md).

# Exports

## Client

### Alert

```lua
exports["tgiann-policealert"]:Alert({
    jobs = { "police" },
    label = "Alert Test",
    coords = nil,
    code = nil,
    policeCount = nil,
    icon = nil,
    iconColor = nil,
    bgAnimate = false,
    vehicle = {
        label = true,
        plate = true,
        color = true
    },
    gender = true,
    sound = true,
    soundName = nil,
    blip = nil,
    custom = nil
})
```

#### Parameters

* jobs: `string[]`
* label: `string`
* coords?: `vector3` or `vector4` or `{ x: number, y: number, z: number }` if nil, will use the player's current position
* code?: `string` Alert code, e.g. "10-29"
* policeCount?: `string` or `number` Number of police officers responding to the alert, if nil, it will not be displayed (string or number)
* icon?: `string` `Default: triangle-exclamation` FontAwesome icon name, e.g. "car-on"
* iconColor?: `string` Hex color for the icon, e.g. "#FF0000"
* bgAnimate?: `boolean` `Default: false`If true, the background will animate
* vehicle?: `{ label?: boolean, plate?: boolean, color?: boolean }` Vehicle information (if null all vehicle data will be send)
  * label?: `boolean` `Default: true` If true, the vehicle label will be included
  * plate?: `boolean` `Default: true` If true, the vehicle plate will be included
  * color?: `boolean` `Default: true` If true, the vehicle color will be included
* gender?: `boolean` `Default: true` If true, the player's gender is displayed.
* sound?: `boolean` `Default: true` If true, the alert will play a sound
* soundName?: `string` `Default: "HUD_FRONTEND_DEFAULT_SOUNDSET"` Sound name to play, e.g. "HUD\_FRONTEND\_DEFAULT\_SOUNDSET"
* blip?: `number` Blip ID for the alert on the map, e.g. 280
* custom?: `{ labelLeft: string, labelRight: string, icon: string }[]` Custom information to display in the alert

***

## Server

### Alert

```lua
exports["tgiann-policealert"]:Alert(src, {
    jobs = { "police" },
    label = "Alert Test",
    coords = nil,
    code = nil,
    policeCount = nil,
    icon = nil,
    iconColor = nil,
    bgAnimate = false,
    vehicle = {
        label = true,
        plate = true,
        color = true
    },
    gender = true,
    sound = true,
    soundName = nil,
    blip = nil,
    custom = nil
})
```

#### Parameters

* src: `number`
* jobs: `string[]`
* label: `string`
* coords?: `vector3` or `vector4` or `{ x: number, y: number, z: number }` if nil, will use the player's current position
* code?: `string` Alert code, e.g. "10-29"
* policeCount?: `string` or `number` Number of police officers responding to the alert, if nil, it will not be displayed (string or number)
* icon?: `string` `Default: triangle-exclamation` FontAwesome icon name, e.g. "car-on"
* iconColor?: `string` Hex color for the icon, e.g. "#FF0000"
* bgAnimate?: `boolean` `Default: false`If true, the background will animate
* vehicle?: `{ label?: boolean, plate?: boolean, color?: boolean }` Vehicle information (if null all vehicle data will be send)
  * label?: `boolean` `Default: true` If true, the vehicle label will be included
  * plate?: `boolean` `Default: true` If true, the vehicle plate will be included
  * color?: `boolean` `Default: true` If true, the vehicle color will be included
* gender?: `boolean` `Default: true` If true, the player's gender is displayed.
* sound?: `boolean` `Default: true` If true, the alert will play a sound
* soundName?: `string` `Default: "HUD_FRONTEND_DEFAULT_SOUNDSET"` Sound name to play, e.g. "HUD\_FRONTEND\_DEFAULT\_SOUNDSET"
* blip?: `number` Blip ID for the alert on the map, e.g. 280
* custom?: `{ labelLeft: string, labelRight: string, icon: string }[]` Custom information to display in the alert

***

### SendCustomAlert

```lua
exports["tgiann-policealert"]:SendCustomAlert(alertData, jobs, srcList)

exports["tgiann-policealert"]:SendCustomAlert({
    coords = { x = 1000.0, y = 250.5, z = 300.5 },
    duration = 5,
    code = nil,
    icon = nil,
    iconColor = nil,
    label = "My Custom Alert",
    information = {
        time = os.time(),
        location = { street = "Street Name", avenue = "Avenue Name" },
        vehicle = { label = "Sultan Rs", plate = "ABC123", color = { text = "Green and black", hex1 = "green", hex2 = "black" } },
        gender = "m",
        custom = {
            {
                labelLeft = "Car Type",
                labelRight = "A Plus",
                icon = "car"
            },
            {
                labelLeft = "Race Information",
                labelRight = "Secret",
                icon = "car"
            }
        }
    },
    policelist = { "tgiann test" },
    bgAnimate = false,
    sound = { active = false, name = nil, isCodeSound = false },
    blip = nil,
    src = nil,
}, { "police", "ambulance", "sheriff" })
```

#### Parameters

* alertData: `table` see fields below
* jobs?: `string[]` the alert is sent to all players belonging to the jobs in the array list. (Cannot be used at the same time as `srcList`)
* srcList?: `number[]` the alert is sent to the sources in the array list. (Cannot be used at the same time as `jobs`)

**alertData**

* coords: `vector3` or `vector4` or `{ x: number, y: number, z: number }`
* duration: `number`
* code?: `string`
* icon?: `string`
* iconColor?: `string`
* label: `string`
* information
  * time: `date`
  * location: `{ street: string, avenue: string }`
    * street: `string`
    * avenue: `string`
  * vehicle? `{ label: string, plate: string, color: { text: string, hex1: string, hex2: string } }`
    * label?: `string`
    * plate?: `string`
    * color?:
      * text?: `string`
      * hex1?: `string`
      * hex2?: `string`
  * gender: `m` or `f`
  * custom: `{ labelLeft: string, labelRight: string, icon: string }[]`
    * labelLeft: `string`
    * labelRight: `string`
    * icon: `string`
* policelist: `string[]`
* bgAnimate?: `boolean`
* sound
  * active?: `boolean`
  * name?: `string`
  * isCodeSound?: `boolean`
* blip?: `number`
* src?: `number`

***

### GetPersonalData

```lua
local data = exports["tgiann-policealert"]:GetPersonalData(citizenid, "police")
```

#### Parameters

* citizenid: `string` or `number`
* jobName?: `string` if omitted, searches across every job the personnel has a record in

#### Returns

* `PersonalListData` or `nil` if the personnel has no record

***

### GetPersonalRank

```lua
local rank = exports["tgiann-policealert"]:GetPersonalRank(citizenid, "police")
```

#### Parameters

* citizenid: `string` or `number`
* jobName?: `string` if omitted, searches across every job the personnel has a record in

#### Returns

* `number` or `nil` if the personnel has no record

***

### IsPersonalBusy

```lua
local busy = exports["tgiann-policealert"]:IsPersonalBusy(citizenid, "police")
```

#### Parameters

* citizenid: `string` or `number`
* jobName?: `string` if omitted, searches across every job the personnel has a record in

#### Returns

* `boolean` true if the personnel is BUSY (Code 7). `false` if not busy or if they have no record

***

### IsPersonalOnDuty

```lua
local onDuty = exports["tgiann-policealert"]:IsPersonalOnDuty(citizenid, "police")
```

#### Parameters

* citizenid: `string` or `number`
* jobName?: `string` if omitted, searches across every job the personnel has a record in

#### Returns

* `boolean` true if the personnel is connected and on duty. Independent of Code 7 status

***

### AddPersonalWarning

```lua
local newWarnings = exports["tgiann-policealert"]:AddPersonalWarning(citizenid, "police", 1)
```

#### Parameters

* citizenid: `string` or `number`
* jobName: `string`
* amount?: `number` `Default: 1` use a negative number to remove warnings. The result is clamped to a minimum of 0

#### Returns

* `number` the personnel's new warning count, or `nil` if they have no record for that job

***

### GetBusy / IsBusy

Aliases of the same function.

```lua
local busy = exports["tgiann-policealert"]:GetBusy(src)
local busy = exports["tgiann-policealert"]:IsBusy(src)
```

#### Parameters

* src: `number`

#### Returns

* `boolean` true if the connected officer is BUSY (Code 7)

***

### SetBusy

Sets an officer to busy (Code 7) or available. Useful for example to auto-set an officer busy on death.

```lua
exports["tgiann-policealert"]:SetBusy(src, true)
```

#### Parameters

* src: `number`
* state: `boolean` `true` sets Code 7 (busy), `false` sets available/on duty

#### Returns

* `boolean` `false` if the player has no personnel record

***

### GetBusyCount

O(1) read, kept in sync internally, safe to call frequently.

```lua
local count = exports["tgiann-policealert"]:GetBusyCount("police")
local count = exports["tgiann-policealert"]:GetBusyCount({ "police", "sheriff" })
```

#### Parameters

* jobs: `string` or `string[]`

#### Returns

* `number` count of personnel currently BUSY (Code 7) for the given job(s)

***

### GetActivePersonalCount

O(1) read, kept in sync internally, safe to call frequently.

```lua
local count = exports["tgiann-policealert"]:GetActivePersonalCount({ "police", "sheriff" })
```

#### Parameters

* jobs: `string` or `string[]`

#### Returns

* `number` count of active (connected + on duty) personnel for the given job(s), **including** those on Code 7

***

### GetAvailablePersonalCount

O(1) read, kept in sync internally, safe to call frequently.

```lua
local count = exports["tgiann-policealert"]:GetAvailablePersonalCount({ "police", "sheriff" })
```

#### Parameters

* jobs: `string` or `string[]`

#### Returns

* `number` count of active personnel for the given job(s), **excluding** those on Code 7 (i.e. actually available)

***

### GetJobPersonalCount

```lua
local count = exports["tgiann-policealert"]:GetJobPersonalCount("police")
```

#### Parameters

* jobs: `string` or `string[]`

#### Returns

* `number` total registered personnel for the given job(s), online or not (full roster size)

***

### GetJobPersonalList

```lua
local list = exports["tgiann-policealert"]:GetJobPersonalList("police")
```

#### Parameters

* jobName: `string`

#### Returns

* `PersonalListData[]` the same personnel data sent to the UI

***

### GetPersonalBadgeList

Works on both client and server.

```lua
local badgeList = exports["tgiann-policealert"]:GetPersonalBadgeList()
```

#### Returns

* `table` the `config.personalBadgeList` table

***

### SetCharacterName / SetCharacterNameById

```lua
exports["tgiann-policealert"]:SetCharacterName(src, "John Doe")
exports["tgiann-policealert"]:SetCharacterNameById(citizenid, "John Doe")
```

#### Parameters

* src (SetCharacterName only): `number`
* citizenid (SetCharacterNameById only): `string` or `number`
* name: `string`
* update?: `boolean` `Default: false` if `false`, the name is only set when nothing is cached yet for that personnel; pass `true` to overwrite an already-cached name
