Scripts
Garbage Job
Grab the truck, work the neighbourhoods, haul the bags. A crew job that is easy to pick up and pays per bag.
- Requires
- ox_lib
- Frameworks
- ox, qb, qbx & esx through open bridges
- Target & inventory
- ox or qb target, ox_inventory, or your own
- Vehicle keys
- qbx or qb, or your own
#Install
#Install dependencies
Install (or update)
ox_lib, and start it before this script in yourserver.cfg.github.com/CommunityOx/ox_lib/releases
0
#Check your inventory, target, keys and notify
Besides
ox_lib, the script needs an inventory, a target, vehicle keys and notifications. Pick yours undersysteminconfigs/cl_config.lua:oxandqbresources work out of the box, andqbx_vehiclekeysorqb-vehiclekeysfor keys.Using something else? Make your own in
utils/cl_utils.luaandutils/sv_utils.lua. These are the calls the script makes, shown with theoxand Qbox resources:lua-- Client side return exports.ox_inventory:Search('count', item) >= count -- Server side return exports.ox_inventory:AddItem(source, item, count, metadata or nil) -- Has to be able to remove items from a vehicle trunk or glovebox return exports.ox_inventory:RemoveItem(inv, item, count, metadata, slot, ignoreTotal, strict) return exports.ox_inventory:Search(source, 'count', item) >= count return exports.ox_inventory:GetItem(inv, item, metadata, returnsCount)lua-- Client side return exports.ox_target:addSphereZone({ coords = data.coords, radius = data.radius or 1.0, debug = data.debug or false, options = utils.getTargetOptions(data.options) }) return exports.ox_target:addLocalEntity(entity, utils.getTargetOptions(options)) exports.ox_target:removeZone(zone) exports.ox_target:removeModel(models) return exports.ox_target:addModel(models, utils.getTargetOptions(options))lua-- Client side lib.notify({ title = data.title or '', description = data.description or '', type = data.type or 'info', position = data.position or 'bottom', duration = data.duration or 3000, }) -- Server side TriggerClientEvent('ox_lib:notify', data.source, data, 'bottom')lua-- Server side return exports.qbx_vehiclekeys:HasKeys(data.source, data.vehicle) exports.qbx_vehiclekeys:GiveKeys(data.source, data.vehicle, true)#Add the item
The job uses one item, the garbage bag. Find an image for it (items.rainmad.com/ has plenty), name it
garbage_bag.pngand put it in your inventory's image folder.Paste this into
ox_inventory/data/items.lua:lua['garbage_bag'] = { label = 'Garbage Bag', weight = 250, stack = false, },Paste this into
qb-core/shared/items.lua:lua['garbage_bag'] = {['name'] = 'garbage_bag', ['label'] = 'Garbage Bag', ['weight'] = 250, ['type'] = 'item', ['image'] = 'garbage_bag.png', ['unique'] = false},#Start the script
- Put the
l3th-garbagejobfolder in your resources folder - Add
ensure l3th-garbagejobto yourserver.cfg, after its dependencies - Restart the server
- Put the
#Configuration
Go through configs/cl_config.lua and configs/sv_config.lua and set them up to your liking.
#Only allow bags in the garbage truck
With ox_inventory you can make sure players can only put garbage bags in their crew's truck, not in any other car. Paste this hook into utils/sv_utils.lua:
local hookId = exports.ox_inventory:registerHook('swapItems', function(payload)
local groupId = group.findGroupByMember(payload.source)
if not groupId then return false end
if not job[groupId] then return false end
local vehicleInventory = 'trunk' .. string.strtrim(job[groupId].vehPlate or '')
return payload.toInventory == vehicleInventory
end, {
print = false,
itemFilter = {
garbage_bag = true,
},
inventoryFilter = {
'^trunk[%w]+',
}
})#Need help?
Most issues come from a missing dependency or the wrong start order in server.cfg, so run through the steps once more first. Still stuck? See Common problems or open a ticket on Discord.