Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] When /dv a car it dont show up in dept and says out in garages #370

Open
EliteModzz opened this issue Dec 31, 2024 · 4 comments
Open
Labels
bug Something isn't working

Comments

@EliteModzz
Copy link

Describe the bug
When I dv a car as admin the car does not go back to the garage or depot
To Reproduce
Steps to reproduce the behavior:
/dv
Expected behavior
To goto the depot like past versions

Screenshots
When DV'ed at Garage
image
When DV'ed at Depot
image

@EliteModzz EliteModzz added the bug Something isn't working label Dec 31, 2024
@EliteModzz
Copy link
Author

Also forgot to mention but if you restart and/or ensure the script while in the server the car goes back to the garage. I also have no errors

@johnny-development
Copy link

johnny-development commented Dec 31, 2024

Hey Elite, below is some code that should fix your issue.

Replace the DV command script with this:

RegisterCommand("dv", function(source, args, rawCommand)
    local src = source
    local ped = GetPlayerPed(src)
    local veh = GetVehiclePedIsIn(ped, false)

    if veh ~= 0 then
        local plate = GetVehicleNumberPlateText(veh)

        MySQL.Async.fetchScalar('SELECT garage FROM player_vehicles WHERE plate = @plate', {
            ['@plate'] = plate
        }, function(lastGarage)
            if lastGarage then
                DeleteEntity(veh)

                MySQL.Async.execute('UPDATE player_vehicles SET state = @state WHERE plate = @plate', {
                    ['@state'] = 'Garage',
                    ['@plate'] = plate
                })

                TriggerClientEvent('QBCore:Notify', src, 'Vehicle sent back to garage: ' .. lastGarage, 'success')
            else
                TriggerClientEvent('QBCore:Notify', src, 'Garage not found for this vehicle. Sending to depot.', 'error')
                
                -- Update vehicle status to Depot if no garage is found
                MySQL.Async.execute('UPDATE player_vehicles SET state = @state WHERE plate = @plate', {
                    ['@state'] = 'Depot',
                    ['@plate'] = plate
                })
            end
        end)
    else
        TriggerClientEvent('QBCore:Notify', src, 'No vehicle found.', 'error')
    end
end)

The Dv command should be located in the qb-adminmenu

@johnny-development
Copy link

qb-core/server/commands.lua line 190

@EliteModzz
Copy link
Author

This didnt fix the issue still getting this
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants