> For the complete documentation index, see [llms.txt](https://piotreq-scripts.gitbook.io/piotreq-scripts/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://piotreq-scripts.gitbook.io/piotreq-scripts/assets-and-guides/police-mdt/setup-server.md).

# Setup Server

How to setup server for GPT

## SSN / Citizen ID System \[FOR ESX]

If you already use system like this just skip this part

1. Go to your es\_extended / server / main.lua and find variable "loadPlayer"
2. if you find that, add in this `id` like on screenshot below.

<figure><img src="https://3808595786-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWtp2CzACAMvuPWbeJ3cy%2Fuploads%2FCMPO4uPVJRAXifu7hMJ8%2Fimage.png?alt=media&amp;token=a250fec2-27ba-49f4-bcf8-5e531052f636" alt=""><figcaption><p>Example</p></figcaption></figure>

3. Next scroll to function LoadESXPlayer and add `ssn = nil` in userData table
4. Next add `userData.ssn = tonumber(result.id)` below `result`

<figure><img src="https://3808595786-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWtp2CzACAMvuPWbeJ3cy%2Fuploads%2FLEF6YymHE9g8uFFRL2FF%2Fimage.png?alt=media&amp;token=15755bff-7b26-45aa-93c1-d5a956c1b831" alt=""><figcaption><p>Example</p></figcaption></figure>

5. Next scroll to `local xPlayer = CreateExtendedPlayer` and add `userData.ssn` in arguments
6. Next add `Core.playersBySsn[userData.ssn] = xPlayer` like on screenshot

<figure><img src="https://3808595786-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWtp2CzACAMvuPWbeJ3cy%2Fuploads%2FiiOtOQNmAdUC7pCmi4rz%2Fimage.png?alt=media&amp;token=d9130cd6-b6d0-4114-9bbb-34f8b86e53cf" alt=""><figcaption><p>Example</p></figcaption></figure>

7. Next scroll to `playerDropped` event handler and add `Core.playersBySsn[xPlayer.ssn] = nil` also do it in `esx:playerLogout`

<figure><img src="https://3808595786-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWtp2CzACAMvuPWbeJ3cy%2Fuploads%2F9wsMPmgZCaNMaOf81y4M%2Fimage.png?alt=media&amp;token=6337bf7d-6c0b-40b1-8456-9dd7a6e82d2f" alt=""><figcaption><p>Example</p></figcaption></figure>

8. Next go to server / common.lua and add `Core.playersBySsn = {}`

<figure><img src="https://3808595786-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWtp2CzACAMvuPWbeJ3cy%2Fuploads%2FcsF9mpodyB6ujnYnxTed%2Fimage.png?alt=media&amp;token=a01be135-15e5-4dd6-9fe5-d0bb035d84f9" alt=""><figcaption><p>Example</p></figcaption></figure>

10. Next go to server / functions.lua and add new function like on screenshot

<figure><img src="https://3808595786-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWtp2CzACAMvuPWbeJ3cy%2Fuploads%2Fcjb1Qb2HkLMoPWIKMvzQ%2Fimage.png?alt=media&amp;token=5c6caa4c-2224-462f-b820-17d13307f8f2" alt=""><figcaption><p>Example</p></figcaption></figure>

11. Next go to server / classes / player.lua and add `ssn` argument in function `CreateExtendedPlayer`
12. Next add `self.ssn = ssn` and add statebag `stateBag:set("ssn", self.ssn, true)`

<figure><img src="https://3808595786-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWtp2CzACAMvuPWbeJ3cy%2Fuploads%2FbdknTd73iGLwOflbxE6L%2Fimage.png?alt=media&amp;token=f7c5bf61-b997-48ff-9369-6d9bf7626605" alt=""><figcaption><p>Example</p></figcaption></figure>

13. Thats all, at the end make sure ur column `id` in users are auto increment

***

## VIN System

You can skip this part if you already use one.

1. Go to your vehicle shop server side file and find MySQL execute to database like on screenshot.

<figure><img src="https://3808595786-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWtp2CzACAMvuPWbeJ3cy%2Fuploads%2F7T7eEJ6QRk37wBwQVgew%2Fimage.png?alt=media&amp;token=250b44be-20a9-48bc-8045-dd2adef8feb3" alt=""><figcaption><p>Example</p></figcaption></figure>

2. Next add vin in columns and values like on screenshot below.

<figure><img src="https://3808595786-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWtp2CzACAMvuPWbeJ3cy%2Fuploads%2Fpc1jAZltiCS2GaUjpUKf%2Fimage.png?alt=media&amp;token=4ca3314b-8f26-4123-bb39-ab98dbdc400e" alt=""><figcaption><p>Example</p></figcaption></figure>

3. And thats all, if you want to add vin for givecar script, its very similiar.

```lua
exports['piotreq_gpt']:GenerateVIN() -- only server side
```
