# Voucher

{% hint style="info" %}
For giving the player the voucher when he creates a new character you need to make some changes in your es\_extended (ESX) and qb-core (QB Core) files
{% endhint %}

## 1. Creating item

To use the voucher, you need to have it has item.

You can simply do it adding it to your inventory shared items or to your sql (it depends on your inventory)

### Here you have some pre-made implementations

You can change the description as you want.

Its currently on portuguese.

### ESX - SQL

```sql
INSERT INTO `items` (name, label, weight, rare, can_remove) VALUES
  ('voucher','Voucher - 35.000€', 0, 1, 0)
;
```

### QB Core - qb-core/shared/items.lua

```lua
['voucher']                  = {['name'] = 'voucher',                     ['label'] = 'Voucher PDM',                     ['weight'] = 0,         ['type'] = 'item',         ['image'] = 'voucher.png',                 ['unique'] = false,     ['useable'] = true,     ['shouldClose'] = true,       ['combinable'] = nil,   ['description'] = 'Voucher valor: 35.000€, Este artigo é pessoal e não pode ser vendido ou repassado.'},
```

{% hint style="info" %}
You can use any name for the item, just make sure you use the same name name on your items file and on Config.ItemVoucher
{% endhint %}

## 2. Item when player is created

In order to give the item to the player when he creates a new character you will need to change the core files of your server.

Here you have all the steps to do it according to your framework

### ESX

Insert this sql to your DataBase.

It may vary depending on your version. On latest ESX Legacy works fine.

If your inventory uses his own sql column to save the items contact you inventory creator

```sql
ALTER TABLE users
ALTER COLUMN inventory SET DEFAULT '{"voucher":1}';
```

### QB Core

You need to go to qb-core/shared/main.lua and add the following line to QBShared.StarterItems

```lua
    ['voucher'] = { amount = 1, item = 'voucher'}
```

So it will look like this

```lua
QBShared.StarterItems = {
    ['phone'] = { amount = 1, item = 'phone' },
    ['id_card'] = { amount = 1, item = 'id_card' },
    ['driver_license'] = { amount = 1, item = 'driver_license' },
    ['voucher'] = { amount = 1, item = 'voucher'}
}
```

## 3. Ready

Now its full set, every time a new player joins your server he will receive a Voucher to buy any vehicle he wants with the same or less price you set up in config.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://playooze-scripts.gitbook.io/playooze-scripts/script-guides/playooze-dealership/voucher.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
