# QB Core Mapping Tutorial

## Character Mapping

QB Core stores player information in the `players` table.

The player's first and last name is stored as JSON in the `charinfo` column. We'll toggle these as a `JSON Column` and set the JSON keys to `firstname` and `lastname`.

The `citizenid` column stores a unique player ID. This will be our `Character Mapping Column`.

![](https://232668649-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4pGN81fb4R6zFhodcu%2Fuploads%2Fgo3VwhM9E2EBmNoksYih%2Fimage.png?alt=media\&token=320e0e60-2e00-4ae0-b235-93b4bc273655)

![](https://232668649-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4pGN81fb4R6zFhodcu%2Fuploads%2FVkC0wnDp7ciKgnN6pUkG%2Fimage.png?alt=media\&token=e6dc2cef-6d7e-417f-b8f2-53edc69407d6)

### Multiple Residency

QB Core also allows players to own multiple residences at once.

Sonoran CAD's DB Sync will pull all of these from their external `player_houses` table.

![QB Core - DB Sync - Residency Mapping](https://232668649-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4pGN81fb4R6zFhodcu%2Fuploads%2Fq4mHaTYV9NIDeNKDAWBP%2Fimage.png?alt=media\&token=9a720d96-1e88-4781-b73b-08a217887f1e)

Because multiple residences can be listed at once, it's recommended you update your custom record's residence field to the `textarea` type.

![](https://232668649-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4pGN81fb4R6zFhodcu%2Fuploads%2FDCuGahRjNrIslwBDgpRv%2Fimage.png?alt=media\&token=c9156a11-4efd-4835-add9-51d19ee0cc37)

The custom record now shows the residency textarea with all owned addresses.

![QB Core - Multi Residence in Custom Record with DB Sync](https://232668649-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4pGN81fb4R6zFhodcu%2Fuploads%2FixDQAQJxmsiNqanQcxd1%2Fimage.png?alt=media\&token=414696ad-a269-4243-85a8-093baf1fc035)

## Vehicle Mapping

QB Core stores the vehicle information in the `player_vehicles` table.

The `Unique ID` for vehicles is stored in the `citizenid` column and matches the values stored in the `citizenid` column from our player mapping.

The `plate` column stores the vehicle's license plates.

You can configure other custom fields may include color, make, model, etc. Vehicle colors are often stored as a number. You can use [friendly mapping](https://docs.sonoransoftware.com/cad/integration-plugins/database-sync-and-merge/..#friendly-mapping) to convert a number to a color name.

![](https://232668649-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4pGN81fb4R6zFhodcu%2Fuploads%2FsQSd22Q2nhZi0VNP0osA%2Fimage.png?alt=media\&token=b7ac44dd-a484-4706-b66c-610f83d42e7d)

![](https://232668649-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4pGN81fb4R6zFhodcu%2Fuploads%2F9Ax4CdvmyhVRcm5HnXhQ%2Fimage.png?alt=media\&token=44e8227f-e64a-4958-a045-96c0c1686442)

## License Mapping

Because of how licenses are stored in QB Core, this process adds a couple of extra steps.

### 1. Open Admin panel to License Record

You will first need to edit the License record to adapt it for how QBCore stores its licenses. Open the Admin Panel by going to the following...

`Admin Panel` -> `Customization` -> `Custom Records` -> Click `#4 - License`

![Sonoran CAD Custom Record Editor](https://232668649-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4pGN81fb4R6zFhodcu%2Fuploads%2F2xnTi5mUfRTlWuRwQnsB%2Fimage.png?alt=media\&token=0bbdade5-dedb-4cd1-84b9-d190c22e3c3f)

### **2**. Edit License Information Section

Replace the last three fields in the `License Information:` section with the following. Make sure to change the `type` to `text` and remove the `mask`. You can use the screenshot below as a guide. Then click `Save` before moving on.

{% hint style="danger" %}
**Don't forget to click Save before continuing!**
{% endhint %}

![Sonoran CAD custom record editor](https://232668649-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4pGN81fb4R6zFhodcu%2Fuploads%2Flnuebcdb2vxRdwo2pDsd%2Fimage.png?alt=media\&token=f45eccf9-0825-42ad-af0e-e2f5b5bb4da0)

### 3. Open DBSync Settings

Click `Advanced` -> `In-Game Integration` to open the DBSync settings menu.

### 4. Fill in DBSync Settings

As of writing on 2/28/2022, the following pictured settings will work for QBCore's latest version. Fill in the `Table Name`, `Character Mapping Column`, `Column Name`s, `JSON Column`s and `Friendly Mapping`s as shown below. Make sure to click `Save Mapping Config` once finished.

{% hint style="info" %}
We are aware of the misspelling "licence", this is intentional in QBCore to differentiate between another piece of data referred to as "license"
{% endhint %}

![Sonoran CAD DBSync Settings](https://232668649-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4pGN81fb4R6zFhodcu%2Fuploads%2F6nCsWAO6RyiZWlgHGHFX%2Fimage.png?alt=media\&token=3ea8092c-04ca-4785-b6ea-5ef53706157a)

![Sonoran CAD DBSync Friendly Mapping Settings](https://232668649-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4pGN81fb4R6zFhodcu%2Fuploads%2FIXnHtdsO3fjXYUI1z59G%2Fimage.png?alt=media\&token=bc7c593c-3a5d-466b-b419-0256ed34b640)

Congratulations! You should now be all set up to display your licenses from QBCore in Sonoran CAD. Feel free to test a record lookup to verify everything is in order.

![Example QBCore DBSynced license data](https://232668649-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4pGN81fb4R6zFhodcu%2Fuploads%2F6O1hNStzAEauNyRemSFL%2Fimage.png?alt=media\&token=20b0376a-6024-4285-a38f-9067cbc6f7df)
