Installation
Be sure to follow all the steps for a good installation.
Step 1:
Download the script from the keymaster (always make sure you have the latest version).
Then make sure you have also downloaded the script called “ox_lib” as it is a prerequisite for this script. Download Ox Lib
Step 2:
Then we will install the SQL which is very important to make a good installation for the script to work correctly.
ESX:
In case of esx you normally use the owned_vehicles table to store the players vehicles, so you will have to add this box to your sql:
ALTER TABLE owned_vehicles ADD COLUMN tow_truck JSON DEFAULT NULL;
QBCORE:
In case of qbcore you normally use the player_vehicles table to store the players vehicles, so you will have to add this box to your sql:
ALTER TABLE player_vehicles ADD COLUMN tow_truck JSON DEFAULT NULL;
Custom:
If you want to do a custom integration you will have to open a ticket in our discord so we can give you support (totally free).
Step 3:
Now we need to install the items but you have to follow the guide very well because the items need to work with metadata and each inventory will have a variation, I will leave a small guide as an example using ox_inventory, but if you have another inventory and you can't do it then you can open ticket and we will help you.
This is an example of the item that we will have to implement in ox_inventory, as you can see it has a previously configured server export.
['papers'] = {
label = 'Vehicle Papers',
weight = 100,
stack = false,
close = true,
description = 'Official vehicle ownership documents.',
consume = 0,
server = {
export = 'an_towtruck_job.papers_use'
}
},
Then in the script it is important to configure the way in which the item is delivered to correctly add the metadata, to configure it we will have to go to server/Custom/boss_menu.lua there we will find the logic that delivers the item, in this case I will leave an example using ox_inventory:
function GivePappersInventory(source, name, plate, price)
local metadata = {
Name = name,
Plate = plate,
Price = price,
description = ('Name: %s\n Vehicle Papers\nPlate: %s\nPrice: $%s'):format(name, plate, price)
}
local success = exports.ox_inventory:AddItem(source, 'papers', 1, metadata)
if success then
TriggerClientEvent('ox_lib:notify', source, {description = 'You received vehicle papers for plate: ' .. plate, type = 'success'})
return true
else
TriggerClientEvent('ox_lib:notify', source, {description = 'Failed to generate papers!', type = 'error'})
return false
end
end
Now we will have to configure the way in which the item is used, also this will depend on each inventory, here is an example with ox_inventory for this we will have to go to server/Custom/use_papers.lua
exports('papers_use', function(event, item, inventory, slot, data)
if event == 'usingItem' then
local src = inventory.id
local itemSlot = exports.ox_inventory:GetSlot(inventory.id, slot)
if itemSlot and itemSlot.metadata then
TriggerClientEvent("an_towtruck_job_:UsePapers", src, itemSlot.metadata.Name, itemSlot.metadata.Plate, itemSlot.metadata.Price)
else
TriggerClientEvent('ox_lib:notify', src, {description = 'Invalid vehicle papers.', type = 'error'})
end
end
end)
It is important to always pass the correct parameters in this case with ox inventory I extract correctly the metadata of the item and pass it to the trigger in this way: itemSlot.metadata.Name, itemSlot.metadata.Plate, itemSlot.metadata.Price.
Last updated