⚙ī¸Integration

Information about how to integrate our boosting system with your server's resources.

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.

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.

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.

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.

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.

Item creation

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

Add the following lines to to qb-core/shared/items.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 qb-inventory/html/images/boostingtablet.png

Add the following image file as qb-inventory/html/images/hackingdevice.png

Add the following image file as qb-inventory/html/images/gpshackingdevice.png

Add the following section to the end of rahe-boosting/api/server.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)

Giving store items

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

In rahe-boosting/api/server.lua, change the giveItem function to this

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   

Saving VIN scratched vehicles

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

In rahe-boosting/api/server.lua, change the vinScratchSuccessful event to this

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)

Police dispatch calls

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

In rahe-boosting/api/client.lua, change the importantBoostStarted event to this

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)

Giving vehicle keys

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

In rahe-boosting/api/client.lua, change the giveKeys event to this

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

Make vehicle enterable once the outside hack is completed

Only required if you are using qb-vehiclekeys. This is because it doesn't allow you to simply unlock the doors. It requires for you to set a variable in qb-vehiclekeys.

In qb-vehiclekeys/client/main.lua, add the following event

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

In rahe-boosting/api/client.lua, change the hackingDeviceUsed event to this

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 /usehackingdevice command, change it in rahe-boosting/api/client.lua to this

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

If you use ox_inventory (with the export), then also trigger that event in the export.

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.

Add the following code block into your LockpickDoor function in qb-vehiclekeys/client/main.lua:

local boosingInfo = 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

In the end, your LockpickDoor function should look something like this:

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 

Don't overwrite your whole LockpickDoor 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 LockpickDoor function might be a newer / older version compared to our example (and therefore different).

Last updated