# Installations

## Step 1 ➡ Dependencies&#x20;

This is one of the most important parts, since without the dependencies, the resource will never work or not start, here we will list the dependencies with their respective links for you to download and add them to your server.

{% embed url="<https://github.com/overextended/oxmysql>" %}

{% embed url="<https://github.com/citizenfx/screenshot-basic>" %}

{% embed url="<https://github.com/mkafrin/PolyZone>" %}
pre-configured for PolyZone in client\_editable.lua/server\_editable.lua
{% endembed %}

{% embed url="<https://github.com/overextended/ox_lib>" %}
pre-configured for ox\_lib in client\_editable.lua/server\_editable.lua
{% endembed %}

{% embed url="<https://store.scriptsfivem.com/package/5834252>" %}

### Not required but recommended:

{% embed url="<https://github.com/overextended/ox_inventory>" %}
pre-configured for ox\_inventory in client\_editable.lua/server\_editable.lua
{% endembed %}

## Step 2 ➡ Resources in server.cfg

{% hint style="warning" %}
if you are using ESX ➡ NEVER, but NEVER, you must place the resources above `es_extended`, if you do this they will never work and will throw errors
{% endhint %}

The correct order of the resources is as follows, always keeping <mark style="color:orange;">es\_extended, sfjob</mark> and its cores above, but the other normal resources below

```
ensure sfpolice
```

## Step 3 ➡ Database

Run query/SQL query and paste below code

{% code fullWidth="false" %}

```sql
CREATE TABLE `jobs_police_cars` (
  `id` int(11) NOT NULL,
  `plate` varchar(16) NOT NULL,
  `status` text NOT NULL DEFAULT ('[]'),
  `notes` text NOT NULL DEFAULT ('[]'),
  `towtruck` text NOT NULL DEFAULT ('[]'),
  `historyowner` text NOT NULL DEFAULT ('[]')
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

CREATE TABLE `jobs_police_category` (
  `id` int(11) NOT NULL,
  `name` varchar(64) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

CREATE TABLE `jobs_police_matters` (
  `id` int(11) NOT NULL,
  `title` varchar(128) NOT NULL,
  `date` varchar(32) NOT NULL,
  `date_create` varchar(32) NOT NULL,
  `whoAdd` varchar(64) NOT NULL,
  `status` int(11) NOT NULL DEFAULT 0,
  `citizens` text NOT NULL DEFAULT ('[]'),
  `officers` text NOT NULL DEFAULT ('[]'),
  `cars` text NOT NULL DEFAULT ('[]'),
  `photos` text NOT NULL DEFAULT ('[]'),
  `message` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

CREATE TABLE `jobs_police_otherdata` (
  `lastWantedPeoples` text NOT NULL DEFAULT ('[]'),
  `lastWantedCars` text NOT NULL DEFAULT ('[]')
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

INSERT INTO `jobs_police_otherdata` (`lastWantedPeoples`, `lastWantedCars`) VALUES ('[]', '[]');

CREATE TABLE `jobs_police_players` (
  `id` int(11) NOT NULL,
  `cid` varchar(64) NOT NULL,
  `avatar` varchar(1024) DEFAULT NULL,
  `status` text NOT NULL DEFAULT ('[]'),
  `notes` text NOT NULL DEFAULT ('[]'),
  `historyJudgments` text NOT NULL DEFAULT ('[]'),
  `fingerprint` int(2) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

CREATE TABLE `jobs_police_regulations` (
  `id` int(11) NOT NULL,
  `name` varchar(128) NOT NULL,
  `category` int(11) NOT NULL,
  `money` int(11) NOT NULL,
  `time` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

CREATE TABLE `sf_customstash` (
  `id` int(11) NOT NULL,
  `name` varchar(128) NOT NULL,
  `job` varchar(32) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

CREATE TABLE `jobs_police_evidenceItems` (
  `id` int(11) NOT NULL,
  `item` varchar(64) NOT NULL,
  `name` varchar(128) NOT NULL,
  `serial` varchar(64) NOT NULL,
  `date` varchar(64) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

ALTER TABLE `jobs_police_cars` ADD PRIMARY KEY (`id`);
ALTER TABLE `jobs_police_category` ADD PRIMARY KEY (`id`);
ALTER TABLE `jobs_police_matters` ADD PRIMARY KEY (`id`);
ALTER TABLE `jobs_police_players` ADD PRIMARY KEY (`id`);
ALTER TABLE `jobs_police_regulations` ADD PRIMARY KEY (`id`);
ALTER TABLE `sf_customstash` ADD PRIMARY KEY (`id`);
ALTER TABLE `jobs_police_evidenceItems` ADD PRIMARY KEY (`id`);

ALTER TABLE `jobs_police_cars` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;
ALTER TABLE `jobs_police_category` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;
ALTER TABLE `jobs_police_matters` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;
ALTER TABLE `jobs_police_players` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;
ALTER TABLE `jobs_police_regulations` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;
ALTER TABLE `sf_customstash` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;
ALTER TABLE `jobs_police_evidenceItems` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;;
```

{% endcode %}

Example data:

```sql
INSERT INTO `jobs_police_category` (`id`, `name`) VALUES
(1, 'Traffic offenses'),
(2, 'Other');
```

A `vin` column should be added to the table with vehicles. For example, in ESX, in the `owned_vehicles` table, add the `vin` column varchar(32) not null.

```sql
ALTER TABLE `owned_vehicles` ADD `vin` varchar(32) NOT NULL AFTER `plate`;
```

## Step 4 ➡ folder install-need-data

Copy the data to the appropriate scripts or database, everything is described there.

## Step 5 ➡ folder install-need-data

Add the VIN number generation code to the script where the vehicle can be purchased so that the VIN number is generated (in the script, e.g.: esx\_vehicleshop)

```lua
function GenerateVIN()
	local foundNumber = false
	local vin = nil
	while not foundNumber do
		vin = makeid(16)
		local result = exports.oxmysql:executeSync('SELECT COUNT(*) AS `count` FROM `owned_vehicles` WHERE `vin`=@info',{['@info'] = vin})
		local count  = tonumber(result[1].count)
		if count == 0 then
		  foundNumber = true
		end
	end
	return vin
end

local charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
math.randomseed(os.time())
function makeid(length)
	local ret = {}
	local r
	for i = 1, length do
		r = math.random(1, #charset)
		table.insert(ret, charset:sub(r, r))
	end
	return table.concat(ret)
end
```

## Step 6 ➡ Click on [Config](https://docs.scriptsfivem.com/resources/sfpolice/config)&#x20;
