# Installation guide

{% hint style="danger" %}
If you don't have any experience in development we are highly recommend to follow each step in this documentation, and if you have a developer ask them to install the script for you as they have more experience.
{% endhint %}

***

## Asset download&#x20;

{% hint style="success" %}
Once the purchase is made on our [<mark style="color:blue;">official website</mark>](https://store.brutalscripts.com), you will receive your asset directly in your [<mark style="color:blue;">Keymaster</mark>](https://keymaster.fivem.net), in the Granted Assets panel you will see the asset, download it and do the following steps to install it correctly.
{% endhint %}

* Put the script folder to your server.
* Start the script in the server.cfg. (ensure brutal\_housing)
* Restart your server! (And you get permission to use the script)

{% hint style="info" %}
[<mark style="color:blue;">**Click here if you haven't installed any script ever**</mark>](https://www.youtube.com/watch?v=55RQrpLhs1w)
{% endhint %}

***

## Upload the SQL

{% hint style="warning" %}
Do not rename your previous SQL or columns to adapt them to this system, use the complete database without making use of edits in your old databases.
{% endhint %}

{% tabs %}
{% tab title="ESX" %}

```sql
CREATE TABLE IF NOT EXISTS `brutal_housing` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `type` text CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `model` text CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `theme` int(11) NOT NULL DEFAULT 0,
  `previousOwner` text DEFAULT NULL,
  `owner` text CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `keyid` text DEFAULT NULL,
  `phone` text DEFAULT '',
  `isRented` int(11) DEFAULT 0,
  `forSale` int(11) DEFAULT 1,
  `rentable` int(11) DEFAULT 1,
  `defaultPrice` int(11) DEFAULT NULL,
  `purchasePrice` int(11) DEFAULT NULL,
  `salePrice` int(11) DEFAULT NULL,
  `label` text CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `address` text CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `url` text CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `coords` text CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `lastPaid` longtext DEFAULT NULL,
  `messages` longtext CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `furnitures` longtext DEFAULT NULL,
  `securityData` longtext DEFAULT NULL,
  `garage` int(11) DEFAULT 0,
  `lastUpdated` text DEFAULT NULL,
  UNIQUE KEY `Index 2` (`id`),
  KEY `Index 1` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=armscii8 COLLATE=armscii8_bin;


CREATE TABLE IF NOT EXISTS `brutal_housing_estates` (
  `job` text NOT NULL,
  `balance` int(11) DEFAULT NULL,
  `soldProperties` longtext DEFAULT '[]',
  UNIQUE KEY `UNIQUE` (`job`(100)) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;


CREATE TABLE IF NOT EXISTS `brutal_housing_garages` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `type` text NOT NULL,
  `model` text DEFAULT NULL,
  `theme` int(11) NOT NULL DEFAULT 0,
  `previousOwner` text DEFAULT NULL,
  `owner` text DEFAULT NULL,
  `keyid` text DEFAULT NULL,
  `phone` text DEFAULT '',
  `isRented` int(11) DEFAULT 0,
  `forSale` int(11) DEFAULT 1,
  `rentable` int(11) DEFAULT 1,
  `defaultPrice` int(11) DEFAULT NULL,
  `purchasePrice` int(11) DEFAULT NULL,
  `salePrice` int(11) DEFAULT NULL,
  `label` text DEFAULT NULL,
  `address` text DEFAULT NULL,
  `url` text DEFAULT NULL,
  `coords` text DEFAULT NULL,
  `lastPaid` longtext DEFAULT NULL,
  `messages` longtext DEFAULT NULL,
  `vehicles` longtext DEFAULT NULL,
  `house` int(11) DEFAULT NULL,
  `lastUpdated` text DEFAULT NULL,
  UNIQUE KEY `Index 2` (`id`),
  KEY `Index 1` (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

ALTER TABLE `users`
ADD COLUMN `fav_property` TEXT NULL DEFAULT NULL COLLATE 'utf8_general_ci';
```

{% endtab %}

{% tab title="QBCORE" %}

```sql
CREATE TABLE IF NOT EXISTS `brutal_housing` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `type` text CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `model` text CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `theme` int(11) NOT NULL DEFAULT 0,
  `previousOwner` text DEFAULT NULL,
  `owner` text CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `keyid` text DEFAULT NULL,
  `phone` text DEFAULT '',
  `isRented` int(11) DEFAULT 0,
  `forSale` int(11) DEFAULT 1,
  `rentable` int(11) DEFAULT 1,
  `defaultPrice` int(11) DEFAULT NULL,
  `purchasePrice` int(11) DEFAULT NULL,
  `salePrice` int(11) DEFAULT NULL,
  `label` text CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `address` text CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `url` text CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `coords` text CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `lastPaid` longtext DEFAULT NULL,
  `messages` longtext CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `furnitures` longtext DEFAULT NULL,
  `securityData` longtext DEFAULT NULL,
  `garage` int(11) DEFAULT 0,
  `lastUpdated` text DEFAULT NULL,
  UNIQUE KEY `Index 2` (`id`),
  KEY `Index 1` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=armscii8 COLLATE=armscii8_bin;


CREATE TABLE IF NOT EXISTS `brutal_housing_estates` (
  `job` text NOT NULL,
  `balance` int(11) DEFAULT NULL,
  `soldProperties` longtext DEFAULT '[]',
  UNIQUE KEY `UNIQUE` (`job`(100)) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;


CREATE TABLE IF NOT EXISTS `brutal_housing_garages` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `type` text NOT NULL,
  `model` text DEFAULT NULL,
  `theme` int(11) NOT NULL DEFAULT 0,
  `previousOwner` text DEFAULT NULL,
  `owner` text DEFAULT NULL,
  `keyid` text DEFAULT NULL,
  `phone` text DEFAULT '',
  `isRented` int(11) DEFAULT 0,
  `forSale` int(11) DEFAULT 1,
  `rentable` int(11) DEFAULT 1,
  `defaultPrice` int(11) DEFAULT NULL,
  `purchasePrice` int(11) DEFAULT NULL,
  `salePrice` int(11) DEFAULT NULL,
  `label` text DEFAULT NULL,
  `address` text DEFAULT NULL,
  `url` text DEFAULT NULL,
  `coords` text DEFAULT NULL,
  `lastPaid` longtext DEFAULT NULL,
  `messages` longtext DEFAULT NULL,
  `vehicles` longtext DEFAULT NULL,
  `house` int(11) DEFAULT NULL,
  `lastUpdated` text DEFAULT NULL,
  UNIQUE KEY `Index 2` (`id`),
  KEY `Index 1` (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

ALTER TABLE `players`
ADD COLUMN `fav_property` TEXT NULL DEFAULT NULL COLLATE 'utf8_general_ci';
```

{% endtab %}

{% tab title="QBOX" %}

```sql
CREATE TABLE IF NOT EXISTS `brutal_housing` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `type` text CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `model` text CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `theme` int(11) NOT NULL DEFAULT 0,
  `previousOwner` text DEFAULT NULL,
  `owner` text CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `keyid` text DEFAULT NULL,
  `phone` text DEFAULT '',
  `isRented` int(11) DEFAULT 0,
  `forSale` int(11) DEFAULT 1,
  `rentable` int(11) DEFAULT 1,
  `defaultPrice` int(11) DEFAULT NULL,
  `purchasePrice` int(11) DEFAULT NULL,
  `salePrice` int(11) DEFAULT NULL,
  `label` text CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `address` text CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `url` text CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `coords` text CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `lastPaid` longtext DEFAULT NULL,
  `messages` longtext CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `furnitures` longtext DEFAULT NULL,
  `securityData` longtext DEFAULT NULL,
  `garage` int(11) DEFAULT 0,
  `lastUpdated` text DEFAULT NULL,
  UNIQUE KEY `Index 2` (`id`),
  KEY `Index 1` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=armscii8 COLLATE=armscii8_bin;


CREATE TABLE IF NOT EXISTS `brutal_housing_estates` (
  `job` text NOT NULL,
  `balance` int(11) DEFAULT NULL,
  `soldProperties` longtext DEFAULT '[]',
  UNIQUE KEY `UNIQUE` (`job`(100)) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;


CREATE TABLE IF NOT EXISTS `brutal_housing_garages` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `type` text NOT NULL,
  `model` text DEFAULT NULL,
  `theme` int(11) NOT NULL DEFAULT 0,
  `previousOwner` text DEFAULT NULL,
  `owner` text DEFAULT NULL,
  `keyid` text DEFAULT NULL,
  `phone` text DEFAULT '',
  `isRented` int(11) DEFAULT 0,
  `forSale` int(11) DEFAULT 1,
  `rentable` int(11) DEFAULT 1,
  `defaultPrice` int(11) DEFAULT NULL,
  `purchasePrice` int(11) DEFAULT NULL,
  `salePrice` int(11) DEFAULT NULL,
  `label` text DEFAULT NULL,
  `address` text DEFAULT NULL,
  `url` text DEFAULT NULL,
  `coords` text DEFAULT NULL,
  `lastPaid` longtext DEFAULT NULL,
  `messages` longtext DEFAULT NULL,
  `vehicles` longtext DEFAULT NULL,
  `house` int(11) DEFAULT NULL,
  `lastUpdated` text DEFAULT NULL,
  UNIQUE KEY `Index 2` (`id`),
  KEY `Index 1` (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

ALTER TABLE player_vehicles DROP FOREIGN KEY player_vehicles_ibfk_1;

ALTER TABLE `players`
ADD COLUMN `fav_property` TEXT NULL DEFAULT NULL COLLATE 'utf8_general_ci';
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
[<mark style="color:blue;">**Click here if you don't know how to upload the sql, here is a quick guide**</mark>](https://www.youtube.com/watch?v=NXqmYn7bbMM)
{% endhint %}

{% embed url="<https://forum.cfx.re/t/how-to-how-to-import-an-sql-into-your-database/5168087/2>" %}

***

## Upload the items&#x20;

{% hint style="warning" %}
If you don't have the items integrated correctly, you will receive random errors.
{% endhint %}

{% hint style="danger" %}
Check that you don't have duplicate items in your inventory or database before integrating them, otherwise you might have some errors.
{% endhint %}

This asset depends on certain items for its operation, so don't forget to integrate all items correctly into your database or inventory system, depending on how you use your server.

If your inventory is not among the following, you can create the file yourself using the examples of each item by displaying any of the following tabs.

<details>

<summary>Items for esx_inventory</summary>

```sql
INSERT INTO `items` (`name`, `label`, `weight`, `rare`, `can_remove`) VALUES
('lockpick', 'Lockpick', 1, 0, 1),
('laptop', 'Laptop', 1, 0, 1),
```

</details>

<details>

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

```lua
['lockpick'] 			 		 = {['name'] = 'lockpick', 						['label'] = 'Lockpick', 						['weight'] = 1, 		['type'] = 'item', 		['image'] = 'lockpick.png', 				['unique'] = false, 	['useable'] = false, 	['shouldClose'] = true,	   ['combinable'] = nil,   ['description'] = ''},
['laptop'] 			 			 = {['name'] = 'laptop', 							['label'] = 'Laptop', 						['weight'] = 1, 		['type'] = 'item', 		['image'] = 'laptop.png', 				['unique'] = false, 	['useable'] = false, 	['shouldClose'] = true,	   ['combinable'] = nil,   ['description'] = ''},
```

</details>

<details>

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

```lua
["lockpick"] = {
    ["name"] = "lockpick",
    ["label"] = "Lockpick",
    ["weight"] = 10,
    ["type"] = "item",
    ["image"] = "lockpick.png",
    ["unique"] = false,
    ["useable"] = false,
    ["shouldClose"] = true,
    ["combinable"] = nil,
    ["description"] = "Not have"
},

["laptop"] = {
    ["name"] = "laptop",
    ["label"] = "Laptop",
    ["weight"] = 10,
    ["type"] = "item",
    ["image"] = "laptop.png",
    ["unique"] = false,
    ["useable"] = false,
    ["shouldClose"] = true,
    ["combinable"] = nil,
    ["description"] = "Not have"
},
```

</details>

<details>

<summary>Items for ox-inventory</summary>

```lua
["lockpick"] = {
    label = "Lockpick",
    weight = 1,
    stack = true,
    close = false,
},

["laptop"] = {
    label = "Laptop",
    weight = 1,
    stack = true,
    close = false,
},
```

</details>

{% hint style="info" %}
[<mark style="color:blue;">**Click here if you don't know how to upload the sql, here is a quick guide**</mark>](https://www.youtube.com/watch?v=NXqmYn7bbMM)
{% endhint %}

***

## Asset positioning

{% hint style="danger" %}
Correctly position the assets in the server.cfg by following this step, if something goes wrong you will probably get errors about exports not found, do not skip this step!
{% endhint %}

```lua
-- First we will start the cores, never below
ensure es_extended or qb-core

-- The Notify / TextUI or target system / Progressbar / Inventory / Billing have to be above our asset
ensure [notify]
ensure [inventory]
ensure [billing]
ensure [textui] -- or target system 

-- Start the Brutal Housing at the end
ensure brutal_housing
```

***

## Setting up the Webhook&#x20;

If you want to use the opportunnities which can be given by a webhook then you will have to set it up in our assets. You can do it by changeing a value to your [<mark style="color:blue;">discord webhook</mark>](https://docs.brutalscripts.com/site/others/discord-webhook) in the sv-utils.lua file.

<figure><img src="https://4039149930-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7v0UUR2mr3gc8OlYzKhO%2Fuploads%2FYD3dBIsrNLZ1Jvx3Sm8L%2FK%C3%A9perny%C5%91k%C3%A9p%202024-02-16%20213349.png?alt=media&#x26;token=fa6bcf52-a448-4a88-acfe-f12faacb75a3" alt=""><figcaption><p>sv-utils.lua</p></figcaption></figure>

{% content-ref url="../../others/discord-webhook" %}
[discord-webhook](https://docs.brutalscripts.com/site/others/discord-webhook)
{% endcontent-ref %}

***

## Setting the loaded event

{% hint style="danger" %}
If you are using a multicharacter system then this step is really important to make our script working propetly! If you don't use any or the loaded event is the same as the basic core one then you are done with this step.
{% endhint %}

In the client-core.lua file go to the LoadedEvent variable and if you are using a different event then paste there your event which is used on your server.

<figure><img src="https://4039149930-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7v0UUR2mr3gc8OlYzKhO%2Fuploads%2FiZsIrf5OSm3hfTPFbEiS%2FK%C3%A9perny%C5%91k%C3%A9p%202024-03-03%20210541.png?alt=media&#x26;token=c320d17a-ed65-4f76-8933-67914ef7b8c9" alt=""><figcaption><p>client-core.lua</p></figcaption></figure>

***

## Checking the Config file

Please make sure that you go through the whole file during the installation and check everything. It is one of the most important things as if you miss this step the script might won't work propetly.

### Most important steps

The most important things always at the top of the config so pay the most attencion to these elements.

<details>

<summary>Setting the Core</summary>

Set your server's core wether it's using es\_extended or qb-core, other cores aren't supported .

</details>

<details>

<summary>Setting the Notify</summary>

If you are using the [<mark style="color:blue;">Brutal Notify</mark>](https://docs.brutalscripts.com/site/scripts/notify) then it is good news, you don't have to do anything.\
If you aren't then set the BrutalNotify value to false in the config and set up your own notify in the cl-utils.lua

</details>

<details>

<summary>Setting the TextUI or Target</summary>

Set the TextUI from the options which are commented out. If your server using an other TextUI  it is not a problem, you can set it up in the cl-utils.lua. If you want to use a target system then set the TextUI to false and set your target.

</details>

***

### PolyZone

Download this version from the polyzone in order to make the housing work.&#x20;

{% file src="<https://4039149930-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7v0UUR2mr3gc8OlYzKhO%2Fuploads%2Fm5FBV022utazcmf9mCqe%2FPolyZone.zip?alt=media&token=a9760cb2-e2d6-4364-bb15-5a0fee8e3425>" %}

### Lockpicking Minigame

Download this script to use the lockpicking minigame.

{% file src="<https://4039149930-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7v0UUR2mr3gc8OlYzKhO%2Fuploads%2FMYfOUqBG7ZkOAKSULSSB%2Flockpick.zip?alt=media&token=a6ae85c2-fcc9-4a10-8f3d-25d31218dd52>" %}

### Break-in/Raid Minigame

Download this script to have minigames when you break into a house or raid one&#x20;

{% file src="<https://4039149930-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7v0UUR2mr3gc8OlYzKhO%2Fuploads%2FXuWlNJf8z1iLBbtF2w0G%2Fps-ui-main.zip?alt=media&token=7146e0c2-3cfd-4d6b-8b2c-9a85abadeb82>" %}

### Doorlock

Download this script to be able to create locks for the mlo type houses

{% file src="<https://4039149930-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7v0UUR2mr3gc8OlYzKhO%2Fuploads%2FrByGhkBL8PLRmzUyH8bL%2Fox_doorlock.zip?alt=media&token=43faebf1-7a80-48a7-af49-26f0b3d55245>" %}

{% hint style="info" %}
The sql for the door lock.
{% endhint %}

```sql
CREATE TABLE
    IF NOT EXISTS `ox_doorlock` (
        `id` int (11) unsigned NOT NULL AUTO_INCREMENT,
        `name` varchar(50) NOT NULL,
        `data` longtext NOT NULL,
        PRIMARY KEY (`id`)
    );
```

## Setting up the interiors

{% hint style="info" %}
If you want to add your own interiors/apartments/furnitures you have to navigate to the <mark style="color:purple;">configs folder</mark>.
{% endhint %}

### Download the preconfigured shells

Here are two links to the preconfigured shells, which are basically in the interiors.lua file

{% embed url="<https://k4mb1maps.com/product/5015840>" %}

{% embed url="<https://github.com/Lynxist/lynx_shells>" %}

***

## Setting up the core

{% hint style="warning" %}
To use this script you will have to make some changes in your core. These steps have to be done to make our asset work 100%.
{% endhint %}

Paste this line to the <mark style="color:yellow;">server.cfg</mark> file. Otherwise you can't place door objects.&#x20;

```
setr game_enableDynamicDoorCreation "true"
```

<details>

<summary>QBOX </summary>

If you are using the QBOX core then set your core to "qbcore" in the config.lua file. Then follow our guide on discord how to make the script compatible with the QBOX core. [Discord Room ](https://discord.com/channels/913910099750289478/1302958411209510984)\
\
Unfortunately the qbox\_vehiclekeys is not working propetly with our housing system. You have to use our key system or any other creator's key system in order to make the garages work.&#x20;

</details>

## If you got any error

If you followed the installation guide and the script still don't work or you get any errors the please check the common errors, here in the docs and in our [<mark style="color:blue;">discord</mark> ](https://discord.gg/85u2u5c8q9)server, for more informations.
