QB-RadialMenu

Explore snippets made by the community and developers for you to utilize within TCVS.

CLIENT-SIDED

First, ensure you comment out the sections highlighted in the provided photo to avoid conflicts. Additionally, insert a Citizen.Wait(1000) to prevent crashes when entering the PolyZone.

The specified code is located at client/publicGarages.lua

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.

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)

RegisterNetEvent('TCVS:client:form')
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)

Last updated

Was this helpful?