# Installation Guide

## Police MDT Script Installation Guide

This page is dedicated to installation of our Police MDT script. Follow steps listed below to start using pScripts Police MDT on your server.

### Prerequisities

Before you begin, ensure you have:

1. FiveM server with administrator access
2. Access to your server's database
3. File transfer capability (FTP or direct file access)

## Step 1: Installing the dependencies

Our script requires 4 dependencies:

1. [ox\_lib](https://github.com/overextended/ox_lib)
2. [oxmysql](https://github.com/overextended/oxmysql/releases)
3. [ox\_target ](https://github.com/overextended/ox_target/releases)/ [qb-target](https://github.com/qbcore-framework/qb-target)
4. [p\_bridge](https://github.com/PiotreeQ/p_bridge)

*Additionaly, we recommend you use* [*MariaDB*](https://mariadb.org/) *as your Database Management System.*

## Step 2: Setting up the Database

{% hint style="warning" %}
Police MDT automatically install a database for you! In case something is wrong, you can use SQL below to import it manually!
{% endhint %}

<details>

<summary>SQL</summary>

```sql
CREATE TABLE `p_mdt_applications` (
    `id` INT(11) NOT NULL,
    `applicant` LONGTEXT NOT NULL,
    `questions` LONGTEXT NOT NULL,
    `status` VARCHAR(30) NOT NULL DEFAULT 'pending',
    `timestamp` BIGINT(30) NOT NULL,
    `reviewer` LONGTEXT DEFAULT NULL,
    `reviewNote` VARCHAR(300) DEFAULT NULL,
    `reviewedAt` BIGINT(30) DEFAULT NULL,
    `job` VARCHAR(60) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

CREATE TABLE `p_mdt_bolo` (
    `id` INT(11) NOT NULL,
    `title` VARCHAR(100) NOT NULL,
    `description` LONGTEXT NOT NULL,
    `target` LONGTEXT NOT NULL,
    `tags` LONGTEXT NOT NULL,
    `status` VARCHAR(20) NOT NULL,
    `creator` LONGTEXT NOT NULL,
    `timestamp` BIGINT(30) NOT NULL,
    `expire` BIGINT(30) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

CREATE TABLE `p_mdt_charges` (
    `name` VARCHAR(60) NOT NULL,
    `charges` LONGTEXT NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

CREATE TABLE `p_mdt_citizens` (
    `identifier` VARCHAR(100) NOT NULL,
    `avatar` LONGTEXT DEFAULT NULL,
    `notes` LONGTEXT NOT NULL DEFAULT '[]'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

CREATE TABLE `p_mdt_evidences` (
    `id` INT(11) NOT NULL,
    `type` VARCHAR(40) NOT NULL,
    `title` VARCHAR(200) NOT NULL,
    `description` LONGTEXT NOT NULL,
    `location` VARCHAR(100) NOT NULL,
    `itemData` LONGTEXT DEFAULT NULL,
    `mediaUrl` LONGTEXT NOT NULL,
    `creator` LONGTEXT NOT NULL,
    `history` LONGTEXT NOT NULL DEFAULT '[]',
    `status` VARCHAR(30) NOT NULL DEFAULT 'undeposited',
    `timestamp` BIGINT(30) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

CREATE TABLE `p_mdt_garage` (
    `id` INT(11) NOT NULL,
    `vehicle` LONGTEXT NOT NULL,
    `job` VARCHAR(60) NOT NULL,
    `status` VARCHAR(10) NOT NULL,
    `grades` LONGTEXT NOT NULL DEFAULT '[]',
    `officers` LONGTEXT NOT NULL DEFAULT '[]',
    `licences` LONGTEXT NOT NULL DEFAULT '[]'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

CREATE TABLE `p_mdt_incidents` (
    `id` INT(11) NOT NULL,
    `title` VARCHAR(100) NOT NULL,
    `description` LONGTEXT NOT NULL,
    `tags` LONGTEXT NOT NULL,
    `creator` LONGTEXT NOT NULL,
    `timestamp` BIGINT(30) NOT NULL,
    `expire` BIGINT(30) DEFAULT NULL,
    `citizens` LONGTEXT DEFAULT NULL,
    `vehicles` LONGTEXT DEFAULT NULL,
    `status` VARCHAR(15) NOT NULL DEFAULT 'open'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

CREATE TABLE `p_mdt_judgments` (
    `id` INT(11) NOT NULL,
    `targets` LONGTEXT NOT NULL,
    `charges` LONGTEXT NOT NULL,
    `timestamp` BIGINT(30) NOT NULL,
    `officer` LONGTEXT NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

CREATE TABLE `p_mdt_logs` (
    `id` INT(11) NOT NULL,
    `identifier` VARCHAR(100) NOT NULL,
    `category` VARCHAR(60) NOT NULL,
    `action` VARCHAR(60) NOT NULL,
    `message` VARCHAR(300) NOT NULL,
    `name` VARCHAR(200) NOT NULL,
    `timestamp` BIGINT(30) NOT NULL,
    `job` VARCHAR(30) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

CREATE TABLE `p_mdt_officers` (
    `identifier` VARCHAR(100) NOT NULL,
    `data` LONGTEXT DEFAULT NULL,
    `licences` LONGTEXT NOT NULL DEFAULT '[]'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

DROP TABLE IF EXISTS `p_mdt_permissions`;

CREATE TABLE `p_mdt_permissions` (
    `id` INT(11) NOT NULL,
    `job` VARCHAR(60) NOT NULL,
    `grade` VARCHAR(60) NOT NULL,
    `permissions` LONGTEXT NOT NULL,
    `timestamp` BIGINT(30) NOT NULL,
    `modifiedBy` VARCHAR(120) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

CREATE TABLE `p_mdt_reports` (
    `id` INT(11) NOT NULL,
    `title` VARCHAR(200) NOT NULL,
    `type` VARCHAR(50) NOT NULL,
    `status` VARCHAR(30) NOT NULL DEFAULT 'open',
    `content` LONGTEXT NOT NULL,
    `tags` LONGTEXT NOT NULL,
    `officers` LONGTEXT NOT NULL,
    `suspects` LONGTEXT NOT NULL,
    `civilians` LONGTEXT NOT NULL,
    `vehicles` LONGTEXT NOT NULL,
    `photos` LONGTEXT NOT NULL,
    `weapons` LONGTEXT NOT NULL,
    `evidences` LONGTEXT NOT NULL,
    `incidents` LONGTEXT NOT NULL,
    `warrants` LONGTEXT NOT NULL,
    `timestamp` BIGINT(30) NOT NULL,
    `creator` LONGTEXT NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

CREATE TABLE `p_mdt_vehicles` (
    `plate` VARCHAR(10) NOT NULL,
    `avatar` LONGTEXT DEFAULT NULL,
    `notes` LONGTEXT NOT NULL DEFAULT '[]',
    `photos` LONGTEXT NOT NULL DEFAULT '[]',
    `tags` LONGTEXT NOT NULL DEFAULT '[]'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

CREATE TABLE `p_mdt_warrants` (
    `id` INT(11) NOT NULL,
    `type` VARCHAR(60) NOT NULL,
    `title` VARCHAR(200) NOT NULL,
    `content` LONGTEXT NOT NULL,
    `target` LONGTEXT NOT NULL,
    `location` VARCHAR(200) DEFAULT NULL,
    `status` VARCHAR(30) NOT NULL DEFAULT 'active',
    `expire` BIGINT(30) DEFAULT NULL,
    `timestamp` BIGINT(30) NOT NULL,
    `creator` LONGTEXT NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

CREATE TABLE `p_mdt_weapons` (
    `serial` VARCHAR(30) NOT NULL,
    `model` VARCHAR(100) NOT NULL,
    `owner` LONGTEXT NOT NULL,
    `timestamp` BIGINT(30) NOT NULL,
    `note` LONGTEXT DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

ALTER TABLE `p_mdt_applications` ADD PRIMARY KEY(`id`);
ALTER TABLE `p_mdt_bolo` ADD PRIMARY KEY(`id`);
ALTER TABLE `p_mdt_charges` ADD PRIMARY KEY(`name`);
ALTER TABLE `p_mdt_citizens` ADD PRIMARY KEY(`identifier`);
ALTER TABLE `p_mdt_evidences` ADD PRIMARY KEY(`id`);
ALTER TABLE `p_mdt_garage` ADD PRIMARY KEY(`id`);
ALTER TABLE `p_mdt_incidents` ADD PRIMARY KEY(`id`);
ALTER TABLE `p_mdt_judgments` ADD PRIMARY KEY(`id`);
ALTER TABLE `p_mdt_logs` ADD PRIMARY KEY(`id`);
ALTER TABLE `p_mdt_officers` ADD PRIMARY KEY(`identifier`);
ALTER TABLE `p_mdt_permissions` ADD PRIMARY KEY(`id`);
ALTER TABLE `p_mdt_reports` ADD PRIMARY KEY(`id`);
ALTER TABLE `p_mdt_vehicles` ADD PRIMARY KEY(`plate`);
ALTER TABLE `p_mdt_warrants` ADD PRIMARY KEY(`id`);
ALTER TABLE `p_mdt_weapons` ADD PRIMARY KEY(`serial`);

ALTER TABLE `p_mdt_applications` MODIFY `id` INT(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `p_mdt_bolo` MODIFY `id` INT(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `p_mdt_evidences` MODIFY `id` INT(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `p_mdt_garage` MODIFY `id` INT(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `p_mdt_incidents` MODIFY `id` INT(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `p_mdt_judgments` MODIFY `id` INT(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `p_mdt_logs` MODIFY `id` INT(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `p_mdt_reports` MODIFY `id` INT(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `p_mdt_permissions` MODIFY `id` INT(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `p_mdt_warrants` MODIFY `id` INT(11) NOT NULL AUTO_INCREMENT;

COMMIT;
```

</details>

You can run these on your preferred Database Management Tool (ex. HeidiSQL, phpMyAdmin etc.)

## Step 3: Downloading the Script

1. Download the script from your [Keymaster](https://portal.cfx.re/assets/granted-assets).
2. Extract the files to your resources (or any other preffered) folder.
3. Add the following line to your `server.cfg`<br>

   ```
   ensure p_mdt
   ```

## Step 4: Configuration

1. Open `config.lua` file in the Script folder
2. Configure our script basing on your needs.

## Step 5: P\_Bridge Configuration

1. Download and extract [p\_bridge](https://github.com/PiotreeQ/p_bridge) onto your server.
2. Configure p\_bridge and its funtions in `config.lua`
3. Add the following line to your `server.cfg`

<pre><code><strong>ensure p_bridge
</strong></code></pre>

{% hint style="danger" %}
Make sure p\_bridge starts before any of **OUR** scripts
{% endhint %}

It's important for your resources to start in a logical order to prevent errors from missing dependencies.

```
ensure oxmysql # this should be one of the first resources
ensure ox_lib
ensure framework # the name of your framework (i.e. ox_core, es_extended, qbx_core)
ensure ox_target
ensure ox_inventory
ensure p_bridge # Our bridge here, should start after main resources
ensure p_mdt # Every our script should start after bridge
```

## Step 6: Start using our script

1. Save all changes
2. Restart / Start your FiveM server

Enjoy using our Police MDT! :tada:


---

# 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://piotreq-scripts.gitbook.io/piotreq-scripts/assets-and-guides/police-mdt-v2/installation-guide.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.
