# QB-RadialMenu

{% hint style="danger" %}
If you are utilizing [**qb-radialmenu**](https://github.com/qbcore-framework/qb-radialmenu) and want to incorporate impound/garages/insurance through it, then this section will help you incorporate it with written code by ***Cisoko.***
{% endhint %}

{% tabs %}
{% tab title="Public Garages" %} <mark style="color:orange;">**CLIENT-SIDED**</mark>

First, ensure you comment out the sections highlighted in the provided photo to avoid conflicts. Additionally, insert a <mark style="color:yellow;">`Citizen.Wait(1000)`</mark> to prevent crashes when entering the PolyZone.

The specified code is located at `client/publicGarages.lua`

<figure><img src="/files/Pf88Tw8uLCNpdo8Z2tD9" alt=""><figcaption></figcaption></figure>

This code needs to be incorporated directly within TCVS, specifically inside the `client/publicGarages.lua` file. This addition will introduce two options when entering a garage PolyZone and remove those Public Garages options upon exiting the PolyZone.

{% hint style="info" %}

<pre class="language-lua"><code class="lang-lua">RegisterNetEvent('TCVS:client:store')
AddEventHandler('TCVS:client:store', function()
    if(globalPlayerVehicle ~= 0)then
        local plate = GetVehicleNumberPlateText(globalPlayerVehicle)
        plate = string.gsub(plate, " ", "")
        local isPlayerInsideGaragePoly, polyType, garageID = exports['realisticVehicleSystem']:IsPlayerInsidePoly()
                    
        if(isPlayerInsideGaragePoly and polyType == "garage-public")then
            exports['realisticVehicleSystem']:StoreVehicleInGarage(garageID + 10000, plate)
        end
    end
end)
<strong>
</strong><strong>RegisterNetEvent('TCVS:client:form')
</strong>AddEventHandler('TCVS:client:form', function(garageID, owner)
        local isPlayerInsideGaragePoly, polyType, garageID = exports['realisticVehicleSystem']:IsPlayerInsidePoly()
                    
        if(isPlayerInsideGaragePoly and polyType == "garage-public")then
            exports['realisticVehicleSystem']:SetupGarageForm(garageID)
        end
    end
end)

Citizen.CreateThread(function()

    local radialmenu, radialmenu2

    while vehicleList == nil or Config == nil do
        Citizen.Wait(100)
    end

    while true do
        Citizen.Wait(500)
        local isPlayerInsideGaragePoly, polyType, garageID = exports['realisticVehicleSystem']:IsPlayerInsidePoly()
                
        if(isPlayerInsideGaragePoly and polyType == "garage-public")then
            if not radialmenu then
                radialmenu = exports['qb-radialmenu']:AddOption({
                    id = 'store_in_garage',
                    title = 'Store in Garage',
                    icon = 'car',
                    type = 'client',
                    event = 'TCVS:client:store',
                    shouldClose = true
                })
            end
            if not radialmenu2 then
                radialmenu = exports['qb-radialmenu']:AddOption({
                    id = 'open_garage',
                    title = 'Open Garage',
                    icon = 'car',
                    type = 'client',
                    event = 'TCVS:client:form',
                    shouldClose = true
                })
            end
        else
            if radialmenu then
                exports['qb-radialmenu']:RemoveOption(radialmenu)
                radialmenu = nil
            end
            if radialmenu2 then
                exports['qb-radialmenu']:RemoveOption(radialmenu2)
                radialmenu2 = nil
            end
        end
    end
end)
</code></pre>

{% endhint %}
{% endtab %}

{% tab title="Impound" %} <mark style="color:orange;">**CLIENT-SIDED**</mark>

First, ensure you comment out the sections highlighted in the provided photos to avoid conflicts. Additionally, insert a <mark style="color:yellow;">`Citizen.Wait(1000)`</mark> to prevent crashes when entering the PolyZone.

The specified code is located at `client/impound.lua`

<figure><img src="/files/n2isW4f1NQmoXDvfnRHB" alt=""><figcaption><p>Impound Retrieve</p></figcaption></figure>

<figure><img src="/files/NxqMMhzpTNq5PFONNFSH" alt=""><figcaption><p>Impound Lock</p></figcaption></figure>

This code needs to be incorporated directly within TCVS, specifically inside the `client/impound.lua` file. This addition will introduce two options when entering a impound related PolyZone and remove the options upon exiting the PolyZones.

{% hint style="info" %}

```lua
RegisterNetEvent('TCVS:client:impoundLock')
AddEventHandler('TCVS:client:impoundLock', function()
    local isPlayerInsideImpoundPoly, polyType = exports['realisticVehicleSystem']:IsPlayerInsidePoly()
    if(isPlayerInsideImpoundPoly and polyType == "impound-lock") then
        exports['realisticVehicleSystem']:SetupImpoundLockForm(localisedUnlockImpoundID)
    end
end)

RegisterNetEvent('TCVS:client:impoundRetrieve')
AddEventHandler('TCVS:client:impoundRetrieve', function()
    local isPlayerInsideImpoundPoly, polyType = exports['realisticVehicleSystem']:IsPlayerInsidePoly()
    if(isPlayerInsideImpoundPoly and polyType == "impound-retrieve") then
        exports['realisticVehicleSystem']:SetupImpoundRetrieveForm(localisedImpoundID)
    end
end)

Citizen.CreateThread(function()
    local radialmenuImpoundLock, radialmenuImpoundRetrieve
    
    while true do
        Citizen.Wait(500)
        local isPlayerInsideImpoundLockPoly, polyTypeLock = exports['realisticVehicleSystem']:IsPlayerInsidePoly()
        local isPlayerInsideImpoundRetrievePoly, polyTypeRetrieve = exports['realisticVehicleSystem']:IsPlayerInsidePoly()
        
        if(isPlayerInsideImpoundLockPoly and polyTypeLock == "impound-lock") then
            if not radialmenuImpoundLock then
                radialmenuImpoundLock = exports['qb-radialmenu']:AddOption({
                    id = 'impound_lock',
                    title = 'Lock Vehicle',
                    icon = 'lock',
                    type = 'client',
                    event = 'TCVS:client:impoundLock',
                    shouldClose = true
                })
            end
        else
            if radialmenuImpoundLock then
                exports['qb-radialmenu']:RemoveOption(radialmenuImpoundLock)
                radialmenuImpoundLock = nil
            end
        end
        
        if(isPlayerInsideImpoundRetrievePoly and polyTypeRetrieve == "impound-retrieve") then
            if not radialmenuImpoundRetrieve then
                radialmenuImpoundRetrieve = exports['qb-radialmenu']:AddOption({
                    id = 'impound_retrieve',
                    title = 'Retrieve Vehicle',
                    icon = 'car',
                    type = 'client',
                    event = 'TCVS:client:impoundRetrieve',
                    shouldClose = true
                })
            end
        else
            if radialmenuImpoundRetrieve then
                exports['qb-radialmenu']:RemoveOption(radialmenuImpoundRetrieve)
                radialmenuImpoundRetrieve = nil
            end
        end
    end
end)

```

{% endhint %}
{% endtab %}

{% tab title="Insurance" %} <mark style="color:orange;">**CLIENT-SIDED**</mark>

First, ensure you comment out the sections highlighted in the provided photo to avoid conflicts. Additionally, insert a <mark style="color:yellow;">`Citizen.Wait(1000)`</mark> to prevent crashes when entering the PolyZone.

The specified code is located at `client/insurance.lua`

<figure><img src="/files/65E9p3SlHUGXItoK6fFN" alt=""><figcaption></figcaption></figure>

This code needs to be incorporated directly within TCVS, specifically inside the `client/insurance.lua` file. This addition will introduce the option when entering an insurance PolyZone and remove the options upon exiting the PolyZone.

{% hint style="info" %}

```lua
RegisterNetEvent('TCVS:client:insurance')
AddEventHandler('TCVS:client:insurance', function()
    local isPlayerInsideInsurancePoly, polyType = exports['realisticVehicleSystem']:IsPlayerInsidePoly()
    if(isPlayerInsideInsurancePoly and polyType == "insurance") then
        exports['realisticVehicleSystem']:SetupInsuranceForm(localisedInsuranceID)
    end
end)

Citizen.CreateThread(function()
    local radialmenuInsurance
    
    while true do
        Citizen.Wait(500)
        local isPlayerInsideInsurancePoly, polyType = exports['realisticVehicleSystem']:IsPlayerInsidePoly()
        
        if(isPlayerInsideInsurancePoly and polyType == "insurance") then
            if not radialmenuInsurance then
                radialmenuInsurance = exports['qb-radialmenu']:AddOption({
                    id = 'insurance',
                    title = 'Insurance',
                    icon = 'briefcase-medical',
                    type = 'client',
                    event = 'TCVS:client:insurance',
                    shouldClose = true
                })
            end
        else
            if radialmenuInsurance then
                exports['qb-radialmenu']:RemoveOption(radialmenuInsurance)
                radialmenuInsurance = nil
            end
        end
    end
end)
```

{% endhint %}
{% endtab %}
{% endtabs %}


---

# 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://docs.cisoko.net/the-complete-vehicle-system/snippets/qb-radialmenu.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.
