Skip to content

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:

esx_vehicleshop before

And add this line

exports["vehicles_keys"]:refreshPlayerOwnedVehicles(playerId)

esx_vehicleshop before

Second step

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

esx_vehicleshop before

And add this line

exports["vehicles_keys"]:refreshPlayerOwnedVehicles(source)

esx_vehicleshop before

esx_advancedvehicleshop

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

esx_advancedvehicleshop before

And add this line

exports["vehicles_keys"]:refreshPlayerOwnedVehicles(source)

esx_advancedvehicleshop after

esx_contract

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

esx_contract before

And add these lines

exports["vehicles_keys"]:refreshPlayerOwnedVehicles(_source)
exports["vehicles_keys"]:refreshPlayerOwnedVehicles(_target)

esx_contract before

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

qb-vehicleshop before

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

qb-vehicleshop after

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

SetTimeout(1000, function() 
    exports["vehicles_keys"]:refreshPlayerOwnedVehicles(buyerId)
end)

okokVehicleShop

Go to okokVehicleShop/sv_utils.lua and search for the following code:

okokVehicleShop before

And add this line

exports["vehicles_keys"]:refreshPlayerOwnedVehicles(_source)

okokVehicleShop before

s4-vehicleshop

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

s4-vehicleshop before

And add the following code:

SetTimeout(1000, function() 
    exports["vehicles_keys"]:refreshPlayerOwnedVehicles(src)
end)

s4-vehicleshop after

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)

t1ger_dealerships after

And add the following line

exports["vehicles_keys"]:refreshPlayerOwnedVehicles(xPlayer.source)

t1ger_dealerships after

Second step

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

t1ger_dealerships 2 before

And add the following line

exports["vehicles_keys"]:refreshPlayerOwnedVehicles(xPlayer.source)

t1ger_dealerships 2 after