MojiaGarages icon indicating copy to clipboard operation
MojiaGarages copied to clipboard

Lose keys after tsunami (new qb-vehiclekeys)

Open Dersicko opened this issue 2 years ago • 5 comments

So the cars stay after tsunami but the players lose their keys, its fine when they quit or dc but not after tsunami

Dersicko avatar May 14 '22 14:05 Dersicko

Same here, any cars that are parked outside the garage, they are unable to access as they don't have the key.

richiepleaserich avatar May 18 '22 22:05 richiepleaserich

no fix anyone?

MrRasmus avatar May 25 '22 14:05 MrRasmus

I've got the same issue too

Calypso460 avatar May 25 '22 17:05 Calypso460

Add this (anywhere) to your qb-vehiclekeys/server.lua

RegisterNetEvent('vehiclekeys:server:CheckOwnerExt')
AddEventHandler('vehiclekeys:server:CheckOwnerExt', function()
    local src = source
    local Player = QBCore.Functions.GetPlayer(src)
    exports.oxmysql:execute('SELECT citizenid, plate FROM player_vehicles WHERE citizenid = ?', {Player.PlayerData.citizenid}, function(result)
        if #result > 0 then
            for i = 1, #result do
                TriggerClientEvent('vehiclekeys:client:SetOwner', src, result[i].plate)
            end
        end
    end)
end)

And add this at the beginning of qb-vehiclekeys/client.lua

AddEventHandler('QBCore:Client:OnPlayerLoaded', function()
    local Player = QBCore.Functions.GetPlayerData()
    TriggerServerEvent('vehiclekeys:server:CheckOwnerExt')
end)

This was kindly provided by a user!
The only issue I had was that when you load into the city, you get a notification that you received keys for every vehicle you owned. I removed the notify event for that so it wouldn't happen.

JustMeGaming avatar Jun 01 '22 06:06 JustMeGaming

cheers for the fix JustMeGaming .... any chance you could tell a noob like myself how to turn notifications for keys off i like to have alot of cars lol @JustMeGaming

DopeLovingHippy avatar Nov 11 '22 18:11 DopeLovingHippy