Qbox-project / qbx_radialmenu

Deprecated. Use ox_lib radial menu directly
GNU General Public License v3.0
9 stars 27 forks source link

Flipvehicle to smallresources #54

Open ArturMichalak opened 4 months ago

ArturMichalak commented 4 months ago

The problem

It would be nice if the radialmenu:flipVehicle event was included in smallresources. This makes more sense than keeping it in the radialmenu. The event can be called flipVehicle:client:flip or qbx_smallresources:client:flip.

Ideal solution

--- [qbx]/qbx_smallresources/client/flipvehicle.lua
local config = require 'config.client'

RegisterNetEvent('flipVehicle:client:flip', function()
    if cache.vehicle then return end
    local coords = GetEntityCoords(cache.ped)
    local vehicle = lib.getClosestVehicle(coords)
    if not vehicle then return exports.qbx_core:Notify(locale('error.no_vehicle_nearby'), 'error') end
    if lib.progressBar({
        label = locale('progress.flipping_car'),
        duration = config.flipTime,
        useWhileDead = false,
        canCancel = true,
        disable = {
            move = true,
            car = true,
            mouse = false,
            combat = true
        },
        anim = {
            dict = 'mini@repair',
            clip = 'fixing_a_ped'
        },
    })
    then
        SetVehicleOnGroundProperly(vehicle)
        exports.qbx_core:Notify(locale('success.flipped_car'), 'success')
    else
        exports.qbx_core:Notify(locale('error.cancel_task'), 'error')
    end
end)

Alternative solutions

No response

Additional context

No response