L3THDocs

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
Latest version 1.2.9 View in store

#Install

  1. #Install dependencies

    Install (or update) ox_lib, and start it before this script in your server.cfg.

    github.com/CommunityOx/ox_lib/releases

    0

  2. #Check your inventory, target, keys and notify

    Besides ox_lib, the script needs an inventory, a target, vehicle keys and notifications. Pick yours under system in configs/cl_config.lua: ox and qb resources work out of the box, and qbx_vehiclekeys or qb-vehiclekeys for keys.

    Using something else? Make your own in utils/cl_utils.lua and utils/sv_utils.lua. These are the calls the script makes, shown with the ox and 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)
  3. #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.png and 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,
    },
  4. #Start the script

    • Put the l3th-garbagejob folder in your resources folder
    • Add ensure l3th-garbagejob to your server.cfg, after its dependencies
    • Restart the server

#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:

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.