# Integration

### Introduction

The whole boosting concept by design uses many parts of one's server. Fully integrating it into a server can't be automatically done by us, since code must be inserted into multiple resources.&#x20;

These integrations aren't required - the resource successfully works after completing the installation steps. However, we recommend that you do the integrations so the full potential of our system could be harnessed.

There are thousands of garage, dispatch, inventory or lockpicking scripts out there. We can't possibly provide an example for every one, since it would take an unreasonably long amount of time (and money, since many are paid resources).

It's your task as a developer to do the integrations. They aren't hard - with basic coding knowledge, you should easily be able to finish them in a reasonable amount of time.&#x20;

To help some of the inexperienced developers out there (or just people looking to save time), we have created examples for some of the most popular resources.

{% hint style="danger" %}
If you can't find your resource example(s) below, please refrain from requesting code from our support. We will get overwhelmed if everyone were to request custom integrations. Please look at other resources and use them as an example.
{% endhint %}

{% hint style="info" %}
If you successfully integrated something and think it would be useful for others as well, then feel free to share it with us and we'll add it to the documentation.
{% endhint %}

### Item creation&#x20;

If you wish to use items (instead of the default commands that come with the resource).

{% tabs %}
{% tab title="qb-inventory" %}
Add the following lines to to <mark style="color:blue;">qb-core/shared/items.lua</mark>

```lua
['boostingtablet'] = { ['name'] = 'boostingtablet', ['label'] = 'Boosting tablet', ['weight'] = 1000, ['type'] = 'item', ['image'] = 'boostingtablet.png', ['unique'] = true, ['useable'] = true, ['shouldClose'] = true, ['combinable'] = nil, ['description'] = "Seems like something's installed on this."},
['hackingdevice'] = { ['name'] = 'hackingdevice', ['label'] = 'Hacking device', ['weight'] = 1000, ['type'] = 'item', ['image'] = 'hackingdevice.png', ['unique'] = true, ['useable'] = true, ['shouldClose'] = true, ['combinable'] = nil, ['description'] = 'Will allow you to bypass vehicle security systems.' },
['gpshackingdevice'] = { ['name'] = 'gpshackingdevice', ['label'] = 'GPS hacking device', ['weight'] = 1000, ['type'] = 'item', ['image'] = 'gpshackingdevice.png', ['unique'] = true, ['useable'] = true, ['shouldClose'] = true, ['combinable'] = nil, ['description'] = 'If you wish to disable vehicle GPS systems.' },
```

Add the following image file as <mark style="color:blue;">qb-inventory/html/images/boostingtablet.png</mark>

<figure><img src="https://2340261896-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FH10xunhFUE8KSIDcSB6v%2Fuploads%2FA8JGYMyh9uDtCjecfqqu%2Fboostingtablet.png?alt=media&#x26;token=d697edbc-3480-41ff-a865-28e0b66ba916" alt=""><figcaption></figcaption></figure>

Add the following image file as <mark style="color:blue;">qb-inventory/html/images/hackingdevice.png</mark>

<figure><img src="https://2340261896-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FH10xunhFUE8KSIDcSB6v%2Fuploads%2FJyIrdnkkfHUqb2AcVLoM%2Fhackingdevice.png?alt=media&#x26;token=35cc6bb0-deb9-4584-923b-685e1145235c" alt=""><figcaption></figcaption></figure>

Add the following image file as <mark style="color:blue;">qb-inventory/html/images/gpshackingdevice.png</mark>

<figure><img src="https://2340261896-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FH10xunhFUE8KSIDcSB6v%2Fuploads%2FSul6fAknvpgoltb0QsB0%2Fgpshackingdevice.png?alt=media&#x26;token=94bdca50-aaa9-4ce6-a6ca-3630916167ec" alt=""><figcaption></figcaption></figure>

Add the following section to the end of <mark style="color:blue;">rahe-boosting/api/server.lua</mark>

```lua
QBCore.Functions.CreateUseableItem("boostingtablet", function(source, item)
    TriggerClientEvent("rahe-boosting:client:openTablet", source)
end)

QBCore.Functions.CreateUseableItem("hackingdevice", function(source, item)
    TriggerClientEvent("rahe-boosting:client:hackingDeviceUsed", source)
end)

QBCore.Functions.CreateUseableItem("gpshackingdevice", function(source, item)
    TriggerClientEvent("rahe-boosting:client:gpsHackingDeviceUsed", source)
end)
```

{% endtab %}

{% tab title="ox\_inventory" %}
Add this section to <mark style="color:blue;">ox\_inventory/data/items.lua</mark>

```lua
['boostingtablet'] = {
    label = 'Boosting tablet',
    weight = 0,
    description = "Seems like something's installed on this.",
    client = {
	export = 'rahe-boosting.boostingtablet',
    }
},
['hackingdevice'] = {
    label = 'Hacking device',
    weight = 0,
    description = 'Will allow you to bypass vehicle security systems.',
    client = {
	export = 'rahe-boosting.hackingdevice',
    }
},
['gpshackingdevice'] = {
    label = 'GPS hacking device',
    weight = 0,
    description = 'If you wish to disable vehicle GPS systems.',
    client = {
	export = 'rahe-boosting.gpshackingdevice',
    }
},
```

Add the following image file as <mark style="color:blue;">ox\_inventory/web/images/boostingtablet.png</mark>

<figure><img src="https://2340261896-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FH10xunhFUE8KSIDcSB6v%2Fuploads%2FA8JGYMyh9uDtCjecfqqu%2Fboostingtablet.png?alt=media&#x26;token=d697edbc-3480-41ff-a865-28e0b66ba916" alt="racingtablet.png"><figcaption></figcaption></figure>

Add the following image file as <mark style="color:blue;">ox\_inventory/web/images/hackingdevice.png</mark>

<figure><img src="https://2340261896-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FH10xunhFUE8KSIDcSB6v%2Fuploads%2FJyIrdnkkfHUqb2AcVLoM%2Fhackingdevice.png?alt=media&#x26;token=35cc6bb0-deb9-4584-923b-685e1145235c" alt="racingtablet.png"><figcaption></figcaption></figure>

Add the following image file as <mark style="color:blue;">ox\_inventory/web/images/gpshackingdevice.png</mark>

<figure><img src="https://2340261896-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FH10xunhFUE8KSIDcSB6v%2Fuploads%2FSul6fAknvpgoltb0QsB0%2Fgpshackingdevice.png?alt=media&#x26;token=94bdca50-aaa9-4ce6-a6ca-3630916167ec" alt="racingtablet.png"><figcaption></figcaption></figure>

Add this section to the end of <mark style="color:blue;">rahe-boosting/api/client.lua</mark>

```lua
exports('boostingtablet', function(data, slot)
    openTablet()
end)

exports('hackingdevice', function(data, slot)
    useHackingDevice()
end)

exports('gpshackingdevice', function(data, slot)
    useGpsHackingDevice()
end)
```

{% endtab %}

{% tab title="OTHER" %}
Create the items in your inventory system. Trigger the following client-side events:

* Event <mark style="color:blue;">rahe-boosting:client:openTablet</mark> on tablet item use.
* Event <mark style="color:blue;">rahe-boosting:client:hackingDeviceUsed</mark> on hacking device item use.
* Event <mark style="color:blue;">rahe-boosting:client:gpsHackingDeviceUsed</mark> on GPS hacking device item use.
  {% endtab %}
  {% endtabs %}

### Giving store items

If you wish to use the built-in store (items that are for sale in the Store tab for money & crypto).

{% tabs %}
{% tab title="qb-inventory" %}
In <mark style="color:blue;">rahe-boosting/api/server.lua</mark>, change the <mark style="color:blue;">giveItem</mark> function to this

```lua
function giveItem(playerId, itemId, amount)    
   if framework == 'ESX' then    
   
   elseif framework == 'QB' then    
      local Player = QBCore.Functions.GetPlayer(playerId) 
      Player.Functions.AddItem(itemId, amount, false)
   else
      -- CUSTOM
   end
end   
```

{% endtab %}

{% tab title="ox\_inventory" %}
In <mark style="color:blue;">rahe-boosting/api/server.lua</mark>, add the following line into your <mark style="color:blue;">giveItem</mark> function (choose the correct section based on your framework)

```lua
exports.ox_inventory:AddItem(playerId, itemId, amount)
```

{% endtab %}

{% tab title="OTHER" %}
Fill in the <mark style="color:blue;">giveItem</mark> function in <mark style="color:blue;">rahe-boosting/api/server.lua</mark> with a function you have in your inventory system to give items. The function must give the player X amount of item Y (check function parameters for playerId, itemId, amount).
{% endtab %}
{% endtabs %}

### Saving VIN scratched vehicles

If you wish that people would be able to VIN scratch vehicles (get the vehicles to their garage).

{% tabs %}
{% tab title="qb-garage" %}
In <mark style="color:blue;">rahe-boosting/api/server.lua</mark>, change the <mark style="color:blue;">vinScratchSuccessful</mark> event to this

```lua
AddEventHandler('rahe-boosting:server:vinScratchSuccessful', function(playerId, vehicleModel, vehicleModelName, licensePlate, vehicleProperties, contractOwnerIdentifier)
    local Player = QBCore.Functions.GetPlayer(playerId)
    MySQL.insert('INSERT INTO player_vehicles (license, citizenid, vehicle, hash, mods, plate, garage, state) VALUES (?, ?, ?, ?, ?, ?, ?, ?)', {
        Player.PlayerData.license,
        Player.PlayerData.citizenid,
        vehicleModel,
        GetHashKey(vehicleModel),
        '{}',
        licensePlate,
        'pillboxgarage',
        1
    })
end)
```

{% endtab %}

{% tab title="OTHER" %}
In <mark style="color:blue;">rahe-boosting/api/server.lua</mark>, fill in the <mark style="color:blue;">vinScratchSuccessful</mark> event. The code you add should insert a vehicle into the database with the parameters available in the event.
{% endtab %}
{% endtabs %}

### Police dispatch calls&#x20;

If you wish police to receive dispatch calls / notifications when important boosts start.

{% tabs %}
{% tab title="ps-dispatch" %}
In <mark style="color:blue;">rahe-boosting/api/client.lua</mark>, change the <mark style="color:blue;">importantBoostStarted</mark> event to this

```lua
AddEventHandler('rahe-boosting:client:importantBoostStarted', function(location, vehicleId, vehicleClass)
    exports["ps-dispatch"]:CustomAlert({
        coords = location,
        message = "Vehicle boost in progress",
        dispatchCode = "10-35A",
        description = 'Vehicle boost',
        radius = 0,
        plate = ('%s (%s class)'):format(GetVehicleNumberPlateText(vehicleId), vehicleClass),
        sprite = 523,
        color = 5,
        scale = 1.5,
        length = 3,
    })
end)
```

{% endtab %}

{% tab title="OTHER" %}
In <mark style="color:blue;">rahe-boosting/api/client.lua</mark>, fill in the <mark style="color:blue;">importantBoostStarted</mark> event. The code you add should send a dispatch call to your online police members.
{% endtab %}
{% endtabs %}

### Giving vehicle keys

If you are using a vehicle key system and need players to have the keys after hacking a boost.

{% tabs %}
{% tab title="qb-vehiclekeys" %}
In <mark style="color:blue;">rahe-boosting/api/client.lua</mark>, change the <mark style="color:blue;">giveKeys</mark> event to this

```lua
AddEventHandler('rahe-boosting:client:giveKeys', function(vehicleId, licensePlate)
    TriggerServerEvent('qb-vehiclekeys:server:AcquireVehicleKeys', licensePlate)
end)
```

{% endtab %}

{% tab title="OTHER" %}
In <mark style="color:blue;">rahe-boosting/api/client.lua</mark>, fill in the <mark style="color:blue;">giveKeys</mark> function. The code you add should allow the player to start / stop the engine of the vehicle.
{% endtab %}
{% endtabs %}

### Make vehicle enterable once the outside hack is completed

{% hint style="danger" %}
**Only required if you are using&#x20;**<mark style="color:blue;">**qb-vehiclekeys**</mark>. This is because it doesn't allow you to simply unlock the doors. It requires for you to set a variable in qb-vehiclekeys.
{% endhint %}

{% tabs %}
{% tab title="qb-vehiclekeys" %}
In <mark style="color:blue;">qb-vehiclekeys/client/main.lua</mark>, add the following event

```lua
AddEventHandler('qb-vehiclekeys:client:setLastPickedVehicle', function(vehicle)
    lastPickedVehicle = vehicle
end)
```

In <mark style="color:blue;">rahe-boosting/api/client.lua</mark>, change the <mark style="color:blue;">hackingDeviceUsed</mark> event to this

```lua
RegisterNetEvent("rahe-boosting:client:hackingDeviceUsed")
AddEventHandler("rahe-boosting:client:hackingDeviceUsed", function()
    TriggerEvent('qb-vehiclekeys:client:setLastPickedVehicle', QBCore.Functions.GetClosestVehicle())
    useHackingDevice()
end)
```

If you use the <mark style="color:blue;">/usehackingdevice</mark> command, change it in <mark style="color:blue;">rahe-boosting/api/client.lua</mark> to this

```lua
RegisterCommand("usehackingdevice", function()
    TriggerEvent('qb-vehiclekeys:client:setLastPickedVehicle', QBCore.Functions.GetClosestVehicle())
    useHackingDevice()
end)
```

If you use <mark style="color:blue;">ox\_inventory</mark> (with the export), then also trigger that event in the export.
{% endtab %}

{% tab title="OTHER" %}
Make sure the vehicles in your server can be entered when their doors are unlocked by the following native

```lua
SetVehicleDoorsLocked(vehicle, 1)
```

{% endtab %}
{% endtabs %}

### Stop lockpicking important boosts, don't allow boost stealing

If you wish to stop cheaters (people who try to lockpick important boosts, instead of hacking).

If you wish that people should not be able to steal other people's boosting vehicles.

{% tabs %}
{% tab title="qb-vehiclekeys" %}
Add the following code block into your <mark style="color:blue;">LockpickDoor</mark> function in <mark style="color:blue;">qb-vehiclekeys/client/main.lua</mark>:

<pre class="language-lua"><code class="lang-lua">local boos<a data-footnote-ref href="#user-content-fn-1">t</a>ingInfo = Entity(vehicle).state.boostingData
if boostingInfo ~= nil and ((not boostingInfo.groupIdentifiers and boostingInfo.cid ~= QBCore.Functions.GetPlayerData().citizenid) or (boostingInfo.groupIdentifiers and not boostingInfo.groupIdentifiers[QBCore.Functions.GetPlayerData().citizenid])) then
    QBCore.Functions.Notify('This vehicle is not meant for you!', 'error')
    return
end

if boostingInfo ~= nil and boostingInfo.advancedSystem then
    QBCore.Functions.Notify('This vehicle requires more advanced systems!', 'error')
    return
end
</code></pre>

In the end, your <mark style="color:blue;">LockpickDoor</mark> function should look something like this:

```lua
function LockpickDoor(isAdvanced)
    local ped = PlayerPedId()
    local pos = GetEntityCoords(ped)
    local vehicle = QBCore.Functions.GetClosestVehicle()

    if vehicle == nil or vehicle == 0 then return end
    if HasKeys(QBCore.Functions.GetPlate(vehicle)) then return end
    if #(pos - GetEntityCoords(vehicle)) > 2.5 then return end
    if GetVehicleDoorLockStatus(vehicle) <= 0 then return end

    local boostingInfo = Entity(vehicle).state.boostingData
    if boostingInfo ~= nil and ((not boostingInfo.groupIdentifiers and boostingInfo.cid ~= QBCore.Functions.GetPlayerData().citizenid) or (boostingInfo.groupIdentifiers and not boostingInfo.groupIdentifiers[QBCore.Functions.GetPlayerData().citizenid])) then
        QBCore.Functions.Notify('This vehicle is not meant for you!', 'error')
        return
    end

    if boostingInfo ~= nil and boostingInfo.advancedSystem then
        QBCore.Functions.Notify('This vehicle requires more advanced systems!', 'error')
        return
    end

    usingAdvanced = isAdvanced
    TriggerEvent('qb-lockpick:client:openLockpick', lockpickFinish)
end 
```

{% hint style="danger" %}
Don't overwrite your whole <mark style="color:blue;">LockpickDoor</mark> function with the example above. Manually insert only the code block needed into the correct place. If you overwrite it, you might break things as your <mark style="color:blue;">LockpickDoor</mark> function might be a newer / older version compared to our example (and therefore different).
{% endhint %}
{% endtab %}

{% tab title="OTHER" %}
If you have a lockpick script, you must not allow important (A / S class) boost vehicles to be lockpicked or started! To counter this, use the data in that vehicle statebag to stop it.

Implement this into your inventory / lockpick script using the following example

```lua
local boostingInfo = Entity(targetVehicle).state.boostingData
if boostingInfo ~= nil and boostingInfo.advancedSystem then
    TriggerEvent("yourNotificationEvent", 'You need a professional system to lockpick this vehicle!')
    return 
 end
```

Use the data in boostingData statebag to stop other players from taking foreign boosting cars. It's very demotivating if you're searching for a car for an hour, and then discover that someone else has taken it.&#x20;

Implement this into your inventory / lockpick script using the following example

```lua
local boostingInfo = Entity(targetVehicle).state.boostingData
if boostingInfo ~= nil and ((not boostingInfo.groupIdentifiers and boostingInfo.cid ~= playerIdentifier) or (boostingInfo.groupIdentifiers and not boostingInfo.groupIdentifiers[playerIdentifier])) then
    TriggerEvent("yourNotificationEvent", 'This vehicle is not meant for you!')
    return 
end
```

{% endtab %}
{% endtabs %}

[^1]:
