Fix hotwiring bought car
Generic script
If after you purchase a vehicle you have to hotwire it, you only have to add this simple line of code in your script code, after you know that the vehicle is added in owned_vehicles
/ player_vehicles
table (depending on the framework)
You may want to add a Citizen.Wait(2000)
before that line in case the vehicle wasn't yet in the table in the moment you triggered the event
esx_vehicleshop
First step
Go to esx_vehicleshop/server/main.lua
and search for the following code:

And add this line
exports["vehicles_keys"]:refreshPlayerOwnedVehicles(playerId)

Second step
Go to esx_vehicleshop/server/main.lua
(the same file as before) and search for the following code:

And add this line
exports["vehicles_keys"]:refreshPlayerOwnedVehicles(source)

esx_advancedvehicleshop
Go to esx_advancedvehicleshop/server/main.lua
and search for the following code:

And add this line
exports["vehicles_keys"]:refreshPlayerOwnedVehicles(source)

qb-vehicleshop
First step
Go to qb-vehicleshop/server.lua
and you will have to add the following code after all exports.oxmysql:insert
In the example, it will be shown only one time, but you have to add it multiple times

And add the following code
SetTimeout(1000, function()
exports["vehicles_keys"]:refreshPlayerOwnedVehicles( pData.PlayerData.source )
end)
In certain parts, you will have to replace pData
with something else, here it will show where to add the code and on what pData
depends

Note: the green circles showed in the screenshot must match, so if the first one is for example targetPlayer
, the second one must be targetPlayer
as well
Second step
Go to qb-vehicleshop/server.lua
(the same file as before) and replace all these events (they are at the bottom of the file)
TriggerClientEvent('vehiclekeys:client:SetOwner', buyerId, plate)
with the following code
exports["vehicles_keys"]:refreshPlayerOwnedVehicles(buyerId)
okokVehicleShop
Go to okokVehicleShop/sv_utils.lua
and search for the following code:

And add this line
exports["vehicles_keys"]:refreshPlayerOwnedVehicles(_source)

s4-vehicleshop
Go to s4-vehicleshop/server.lua
and search for the following code:

And add the following code:
SetTimeout(1000, function()
exports["vehicles_keys"]:refreshPlayerOwnedVehicles(src)
end)

Note: this code will work for both oxmysql and ghmattimysql versions
t1ger_dealerships
First step
Go to t1ger_dealerships/server/main.lua
and add the following line below all codes (more than one) like as shown in the example
exports['t1ger_keys']:UpdateKeysToDatabase(props.plate, true)

And add the following line
exports["vehicles_keys"]:refreshPlayerOwnedVehicles(xPlayer.source)

Second step
Go to t1ger_dealerships/server/main.lua
(same file as before) and search for the following code:

And add the following line
exports["vehicles_keys"]:refreshPlayerOwnedVehicles(xPlayer.source)

Last updated
Was this helpful?