# Installation

## 1. Download Resource

Download the purchased resource from [**CFX Portal**](https://portal.cfx.re/assets/granted-assets) - the official site of FiveM with purchased resources.

***

## 2. Install Required Dependencies

This script needs a few extra resources to work properly.\
Below you will find a list of things to download - click the link, download and upload to your server just like other resources.

<table data-full-width="false"><thead><tr><th width="251">Resource</th><th data-type="content-ref">Download Link</th></tr></thead><tbody><tr><td><strong>MugShotBase64</strong></td><td><a href="https://github.com/BaziForYou/MugShotBase64">https://github.com/BaziForYou/MugShotBase64</a></td></tr></tbody></table>

***

## 3. Import Database Tables

This is a very important step - without it, the script will not work properly.\
Depending on the framework you are using (ESX or QB-Core), select the appropriate section below and **paste the SQL code into your database**.

{% hint style="warning" %}

## Not sure how to do it?

No worries - we've prepared a short guide that shows you step by step how to import an SQL file into your database:\
👉 [**Click here to view the tutorial.**](https://docs.vames-store.com/helpful/basic-server-knowledge/how-to-import-sql-to-database)
{% endhint %}

<details>

<summary>Database for ESX</summary>

```sql
ALTER TABLE `users`
    ADD COLUMN `ssn` varchar(16) DEFAULT NULL,
    ADD COLUMN `cityhall_data` longtext DEFAULT NULL;

ALTER TABLE `owned_vehicles`
    ADD COLUMN `vin` varchar(17) DEFAULT NULL,
    ADD COLUMN `vin_hidden` int(3) DEFAULT 0,
    ADD COLUMN `owner_name` varchar(80) DEFAULT NULL,
    ADD COLUMN `owner_history` longtext DEFAULT NULL,
    ADD COLUMN `insurance` longtext DEFAULT NULL;

CREATE TABLE IF NOT EXISTS `fines` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `type` varchar(60) DEFAULT NULL,
  `receiver` varchar(100) DEFAULT NULL,
  `issuer` varchar(100) DEFAULT NULL,
  `issuer_job` varchar(50) DEFAULT NULL,
  `amount` int(11) DEFAULT NULL,
  `issue_date` int(11) DEFAULT NULL,
  `date_to_pay` int(11) DEFAULT NULL,
  `data` longtext DEFAULT NULL,
  `is_paid` int(11) DEFAULT 0,
  `paid_date` int(11) DEFAULT NULL,
  `canceled` int(1) DEFAULT 0,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

CREATE TABLE IF NOT EXISTS `taxes` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `receiver` varchar(50) DEFAULT NULL,
  `receiver_name` varchar(150) DEFAULT NULL,
  `received_date` int(11) DEFAULT NULL,
  `title` varchar(450) DEFAULT NULL,
  `amount` int(11) DEFAULT NULL,
  `is_paid` tinyint(1) DEFAULT 0,
  `paid_date` int(11) DEFAULT NULL,
  `canceled` tinyint(1) DEFAULT 0,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

CREATE TABLE IF NOT EXISTS `taxes_business` (
  `job` varchar(60) NOT NULL,
  `job_label` varchar(50) DEFAULT NULL,
  `period` varchar(7) DEFAULT NULL,
  `amount` int(16) NOT NULL DEFAULT 0,
  `paid_amount` int(16) NOT NULL DEFAULT 0,
  `delayed_amount` int(16) DEFAULT 0,
  `late_fee_applied` int(5) DEFAULT 0,
  `is_paid` tinyint(1) NOT NULL DEFAULT 0,
  `paid_date` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

CREATE TABLE IF NOT EXISTS `resumes` (
  `job` varchar(50) NOT NULL,
  `allowed` tinyint(4) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

CREATE TABLE IF NOT EXISTS `resumes_data` (
  `sender` varchar(100) NOT NULL,
  `sender_name` varchar(50) DEFAULT NULL,
  `job` varchar(50) DEFAULT NULL,
  `date` bigint(20) NOT NULL DEFAULT 0,
  `informations` longtext NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

CREATE TABLE IF NOT EXISTS `vms_business` (
  `id` varchar(50) NOT NULL DEFAULT '',
  `type` varchar(50) NOT NULL DEFAULT '',
  `owner` mediumtext DEFAULT NULL,
  `employees` longtext DEFAULT '{}',
  `stock` longtext DEFAULT '{}',
  `data` longtext DEFAULT '{}',
  `announcements` longtext DEFAULT '{}',
  `orders` longtext DEFAULT '{}',
  `history` longtext DEFAULT '{}'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
```

</details>

<details>

<summary>Database for QB-Core</summary>

```sql
ALTER TABLE `players` ADD COLUMN `cityhall_data` longtext DEFAULT NULL;

ALTER TABLE `player_vehicles`
    ADD COLUMN `vin` varchar(17) DEFAULT NULL,
    ADD COLUMN `vin_hidden` int(3) DEFAULT 0,
    ADD COLUMN `owner_name` varchar(80) DEFAULT NULL,
    ADD COLUMN `owner_history` longtext DEFAULT NULL,
    ADD COLUMN `insurance` longtext DEFAULT NULL;
    
CREATE TABLE IF NOT EXISTS `fines` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `type` varchar(60) DEFAULT NULL,
  `receiver` varchar(100) DEFAULT NULL,
  `issuer` varchar(100) DEFAULT NULL,
  `issuer_job` varchar(50) DEFAULT NULL,
  `amount` int(11) DEFAULT NULL,
  `issue_date` int(11) DEFAULT NULL,
  `date_to_pay` int(11) DEFAULT NULL,
  `data` longtext DEFAULT NULL,
  `is_paid` int(11) DEFAULT 0,
  `paid_date` int(11) DEFAULT NULL,
  `canceled` int(1) DEFAULT 0,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

CREATE TABLE IF NOT EXISTS `taxes` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `receiver` varchar(50) DEFAULT NULL,
  `receiver_name` varchar(150) DEFAULT NULL,
  `received_date` int(11) DEFAULT NULL,
  `title` varchar(450) DEFAULT NULL,
  `amount` int(11) DEFAULT NULL,
  `is_paid` tinyint(1) DEFAULT 0,
  `paid_date` int(11) DEFAULT NULL,
  `canceled` tinyint(1) DEFAULT 0,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

CREATE TABLE IF NOT EXISTS `taxes_business` (
  `job` varchar(60) NOT NULL,
  `job_label` varchar(50) DEFAULT NULL,
  `period` varchar(7) DEFAULT NULL,
  `amount` int(16) NOT NULL DEFAULT 0,
  `paid_amount` int(16) NOT NULL DEFAULT 0,
  `delayed_amount` int(16) DEFAULT 0,
  `late_fee_applied` int(5) DEFAULT 0,
  `is_paid` tinyint(1) NOT NULL DEFAULT 0,
  `paid_date` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

CREATE TABLE IF NOT EXISTS `resumes` (
  `job` varchar(50) NOT NULL,
  `allowed` tinyint(4) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

CREATE TABLE IF NOT EXISTS `resumes_data` (
  `sender` varchar(100) NOT NULL,
  `sender_name` varchar(50) DEFAULT NULL,
  `job` varchar(50) DEFAULT NULL,
  `date` bigint(20) NOT NULL DEFAULT 0,
  `informations` longtext NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

CREATE TABLE IF NOT EXISTS `vms_business` (
  `id` varchar(50) NOT NULL DEFAULT '',
  `type` varchar(50) NOT NULL DEFAULT '',
  `owner` mediumtext DEFAULT NULL,
  `employees` longtext DEFAULT '{}',
  `stock` longtext DEFAULT '{}',
  `data` longtext DEFAULT '{}',
  `announcements` longtext DEFAULT '{}',
  `orders` longtext DEFAULT '{}',
  `history` longtext DEFAULT '{}'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
```

</details>

***

## 4. Add Required Items

The script uses its own items.\
Depending on what inventory you are using, select the appropriate section and add these items to either your item file or database.

<details>

<summary>Items for esx inventory</summary>

```sql
INSERT INTO `items` (`name`, `label`, `weight`, `rare`, `can_remove`) VALUES
    ("clerk_tablet", "Clerk Tablet", 10, 0, 1),
    ("vehicle_sale_agreement", "Sale Agreement", 4, 0, 1),
    ("signed_vehicle_sale_agreement", "Signed Sale Agreement", 5, 0, 1),
    ("empty_invoice", "Empty Invoice", 3, 0, 1),
    ("invoice", "Invoice", 4, 0, 1),
    ("empty_ticket", "Empty Ticket", 2, 0, 1),
    ("ticket", "Ticket", 3, 0, 1),
    ("payment_terminal", "Payment Terminal", 10, 0, 1),
    ("thermal_paper", "Thermal Paper", 1, 0, 1),
    ("receipt", "Receipt", 1, 0, 1)
;
```

</details>

<details>

<summary>Items for ox_inventory</summary>

```lua
['clerk_tablet'] = {
    label = 'Clerk Tablet',
    weight = 10,
    stack = true
},
['vehicle_sale_agreement'] = {
    label = 'Sale Agreement',
    weight = 4,
    stack = true
},
['signed_vehicle_sale_agreement'] = {
    label = 'Signed Sale Agreement',
    weight = 4,
    stack = false
},
['empty_invoice'] = {
    label = 'Empty Invoice',
    weight = 3,
    stack = true
},
['invoice'] = {
    label = 'Invoice',
    weight = 4,
    stack = false
},
['empty_ticket'] = {
    label = 'Empty Ticket',
    weight = 2,
    stack = true
},
['ticket'] = {
    label = 'Ticket',
    weight = 3,
    stack = false
},
['payment_terminal'] = {
    label = 'Payment Terminal',
    weight = 10,
    stack = false
},
['thermal_paper'] = {
    label = 'Thermal Paper',
    weight = 1,
    stack = false
},
['receipt'] = {
    label = 'Receipt',
    weight = 1,
    stack = false
},
```

</details>

<details>

<summary>Items for qb-inventory / qs-inventory / origen_inventory</summary>

```lua
['clerk_tablet'] = {
    ["name"] = 'clerk_tablet',
    ["label"] = "Clerk Tablet",
    ["weight"] = 10,
    ["type"] = "item",
    ["image"] = "clerk_tablet.png",
    ["unique"] = false,
    ["useable"] = true,
    ["shouldClose"] = false,
    ["combinable"] = nil,
    ["description"] = ""
},
['vehicle_sale_agreement'] = {
    ["name"] = 'vehicle_sale_agreement',
    ["label"] = "Vehicle Sale Agreement",
    ["weight"] = 4,
    ["type"] = "item",
    ["image"] = "vehicle_sale_agreement.png",
    ["unique"] = false,
    ["useable"] = true,
    ["shouldClose"] = false,
    ["combinable"] = nil,
    ["description"] = ""
},
['signed_vehicle_sale_agreement'] = {
    ["name"] = 'signed_vehicle_sale_agreement',
    ["label"] = "Signed Vehicle Sale Agreement",
    ["weight"] = 5,
    ["type"] = "item",
    ["image"] = "vehicle_sale_agreement.png",
    ["unique"] = true,
    ["useable"] = true,
    ["shouldClose"] = false,
    ["combinable"] = nil,
    ["description"] = ""
},
['empty_invoice'] = {
    ["name"] = 'empty_invoice',
    ["label"] = "Empty Invoice",
    ["weight"] = 3,
    ["type"] = "item",
    ["image"] = "empty_invoice.png",
    ["unique"] = false,
    ["useable"] = true,
    ["shouldClose"] = false,
    ["combinable"] = nil,
    ["description"] = ""
},
['invoice'] = {
    ["name"] = 'invoice',
    ["label"] = "Invoice",
    ["weight"] = 4,
    ["type"] = "item",
    ["image"] = "invoice.png",
    ["unique"] = true,
    ["useable"] = true,
    ["shouldClose"] = false,
    ["combinable"] = nil,
    ["description"] = ""
},
['empty_ticket'] = {
    ["name"] = 'empty_ticket',
    ["label"] = "Empty Ticket",
    ["weight"] = 2,
    ["type"] = "item",
    ["image"] = "empty_ticket.png",
    ["unique"] = false,
    ["useable"] = true,
    ["shouldClose"] = false,
    ["combinable"] = nil,
    ["description"] = ""
},
['ticket'] = {
    ["name"] = 'ticket',
    ["label"] = "Ticket",
    ["weight"] = 3,
    ["type"] = "item",
    ["image"] = "ticket.png",
    ["unique"] = true,
    ["useable"] = true,
    ["shouldClose"] = false,
    ["combinable"] = nil,
    ["description"] = ""
},
['payment_terminal'] = {
    ["name"] = 'payment_terminal',
    ["label"] = "Payment Terminal",
    ["weight"] = 10,
    ["type"] = "item",
    ["image"] = "payment_terminal.png",
    ["unique"] = false,
    ["useable"] = true,
    ["shouldClose"] = false,
    ["combinable"] = nil,
    ["description"] = ""
},
['thermal_paper'] = {
    ["name"] = 'thermal_paper',
    ["label"] = "Thermal Paper",
    ["weight"] = 1,
    ["type"] = "item",
    ["image"] = "thermal_paper.png",
    ["unique"] = false,
    ["useable"] = true,
    ["shouldClose"] = false,
    ["combinable"] = nil,
    ["description"] = ""
},
['receipt'] = {
    ["name"] = 'receipt',
    ["label"] = "Receipt",
    ["weight"] = 1,
    ["type"] = "item",
    ["image"] = "receipt.png",
    ["unique"] = true,
    ["useable"] = true,
    ["shouldClose"] = false,
    ["combinable"] = nil,
    ["description"] = ""
},
```

</details>

***

## 5. Register Jobs

Some functions work only if the player has a proper job.\
In this section, you will find ready-made job that you need to add in your framework (ESX/QB).

<details>

<summary>Jobs for ESX</summary>

```sql
INSERT INTO `jobs` (name, label) VALUES
    ('clerk', 'Clerk');

INSERT INTO `job_grades` (job_name, grade, name, label, salary, skin_male, skin_female) VALUES
    ('clerk', 0, 'trainee', 'Trainee', 150, '{}', '{}'),
    ('clerk', 1, 'clerk', 'Clerk', 300, '{}', '{}'),
    ('clerk', 2, 'senior_clerk', 'Senior Clerk', 450, '{}', '{}'),
    ('clerk', 3, 'department_head', 'Department Head', 500, '{}', '{}'),
    ('clerk', 4, 'director', 'Director', 550, '{}', '{}'),
    ('clerk', 5, 'boss', 'Chief Executive Officer', 600, '{}', '{}');
```

</details>

<details>

<summary>Jobs for QB-Core</summary>

```lua
['clerk'] = {
	label = 'Clerk',
	defaultDuty = true,
	offDutyPay = false,
	grades = {
        ['0'] = {name = 'Trainee', payment = 150},
        ['1'] = {name = 'Clerk', payment = 300},
        ['2'] = {name = 'Senior Clerk', payment = 450},
        ['3'] = {name = 'Department Head', payment = 500},
        ['4'] = {name = 'Director', payment = 550},
        ['5'] = {name = 'Chief Executive Officer', isboss = true, payment = 600},
    },
},
```

</details>

<details>

<summary>Jobs for QBX-Core</summary>

```lua
['clerk'] = {
    label = 'Clerk',
    defaultDuty = true,
    offDutyPay = false,
    grades = {
        [0] = {name = 'Trainee', payment = 150},
        [1] = {name = 'Clerk', payment = 300},
        [2] = {name = 'Senior Clerk', payment = 450},
        [3] = {name = 'Department Head', payment = 500},
        [4] = {name = 'Director', payment = 550},
        [5] = {name = 'Chief Executive Officer', isboss = true, payment = 600},
    },
},
```

</details>

***

## 6. Additional Integrations

{% stepper %}
{% step %}

### Automatic SSN generation in your framework

Read the guide [**here**](https://docs.vames-store.com/assets/vms_cityhall/guides/add-ssn-generation)
{% endstep %}

{% step %}

### Automatic VIN entry in your vehicleshop

Read the guide [**here**](https://docs.vames-store.com/assets/vms_cityhall/guides/add-vin-generation)
{% endstep %}
{% endstepper %}

***

## 7. Start Resource

To start a resource in your `server.cfg`, ensure that it begins after your framework has been initiated. For instance, if you are using a framework like `es_extended`, you should start resource after it, like so:

```python
start [core] # For example, here is your framework (esx/qb-core)

# Here you run your other resources like esx_policejob etc.

# VMS Resources
start MugShotBase64
start vms_cityhall
```

Ensure there are no syntax errors or incorrect paths in your `server.cfg`.
