Envi Scripts Documentation
  • 👋Introduction
  • 🌉Envi-Bridge
  • ⚙️Compatibility
  • 🖨️Licensing
  • 📒Premium Scripts
    • ❔FAQ / COMMON ISSUES
    • ‼️FIRST STEPS (READ FIRST)
    • ⭐Useful Resources
    • 👀Envi FiveM Showcase Server
    • 💊Envi-Addictions
      • ❗First Time Setup
      • Inventory Setup
      • Exports and Commands
      • Config File
    • 📸Envi-Camera
      • ❗First Steps
      • Inventory Setup
      • Editable Functionality
      • Complete Lens Kit
      • Printing Photos
      • Ped Reactions
      • Exports
      • Config File
    • 🪚Envi-ChopShop
      • Inventory Setup
      • How to Chop
      • Props for AntiCheats
      • Editable Functionality
      • Config File
    • 🪣Envi-Dumpsters
      • Common Issues
      • Inventory Setup
      • Editable Functionality
      • Exports
      • Exclusive Zones
      • Survival Items
      • Shopping Carts
      • Hobo Bowling
      • Hobo Taxi
      • Rats and Racoons
      • Config File
      • V2 Config
    • 💺Envi-Ejector-Seats
      • Inventory Setup
      • How to Eject
      • Editable Functionality
      • Config File
    • 🔥Envi-Flamethrower (Standalone)
      • Common Issues
      • Inventory Setup
      • Refueling
      • Editable Functionality
      • Config File
    • 🪽Envi-Flight-Suits
      • Inventory Setup
      • Flight Suits
      • Config File
    • 🍜Envi-Food-Truck
      • ❗VooDoo Required
      • Common Issues
      • Inventory Setup
      • Adding Additional Grill Items
      • Unique Shops with Liveries
      • Spawning the Trucks
      • Using the Trucks
      • Exports
      • Config File
    • 💍Envi-Forever-Rings
      • Inventory Setup
      • Editable Functionality
      • Ring Shop MLO
      • Config File
    • 💻Envi-Hack-Minigames (Standalone)
      • The Worm
      • Password
      • Firewall
      • Node Runner
      • Config File
    • 🎞️Envi-HUD
      • ❗First Time Setup
      • Common Issues
      • Inventory Setup
      • Adding Custom Weapons
      • Change Logo
      • Custom Fonts
      • Converting Notifications
      • Converting Progress Bars
      • Editable Functionality
      • Settings Save Location
      • Exports and Events
      • Commands
      • Vehicle Control
      • Anti Muscle Spasm
      • Ragdoll
      • Config File
    • 🎇Envi-Items
      • Inventory Setup
      • Config File
    • 🚑Envi-Medic
      • Common Issues
      • Fully Disable Transport to Hospital
      • Failsafe
      • Ambulance Scripts
      • Vehicle Fuel
      • Vehicle Keys
      • Exports
      • Config File
    • ☄️Envi-MethVan
      • Common Issues
      • Inventory Setup
      • Cooking Process
      • Editable Functionality
      • Adding a Vehicle
      • Config File
    • 🍃Envi-Megablower9000 (Standalone)
      • Inventory Setup
      • Config File
    • 👯Envi-Population (Standalone)
      • ❗Initial Setup
      • Common Issues
      • Config File
    • 🗒️Envi-Prescriptions
      • Common Issues
      • Inventory Setup
      • Editable Functionality
      • Config File
    • 🔧Envi-Sabotage
      • ❗First Time Setup
      • Common Issues
      • Inventory Setup
      • Exports
    • 🛒Envi-Shops
      • Common Issues
      • Inventory Setup
      • Exports
      • Editable Functionality
      • Config File
    • 📱Envi-Trap-Phone
      • Common Issues
      • Inventory Setup
      • Commands
      • Exports
      • Adding Custom Drugs
      • Using the Phone
      • Disabling Extra Services
      • Config Files
        • config.lua
        • dialogueSettings.lua
        • extraServices.lua
        • gangZoneSettings.lua
        • personalitySettings.lua
        • specialContactSettings.lua
    • 👰Envi-Weddings
      • Inventory Setup
      • Starting Info
      • Manually Removing Data
      • Commands
      • Config File
    • 🎅Envi Xmas-Weapons (Standalone)
      • Inventory Setup
      • Config File
    • 🗡️Envi-Zombie-Weapons (Standalone)
      • Inventory Setup
    • 🧟‍♂️Envi-Zombies
Powered by GitBook
On this page
  1. Premium Scripts
  2. Envi-Addictions

First Time Setup

IF YOU ARE USING OX_INVENTORY THEN SKIP THIS!!

ox_inventory users will automatically get this functionality without additional changes due to the hooks that ox_inventory provides. If you use ox and also follow these steps, then your addiction value changes will get doubled, since each item use will trigger two addiction updates


Update to your core script

For anyone not using ox_inventory you'll need to update the UseItem function in your core script to add an extra export. This is so envi-addictions knows when an item has been used and will be able to run the addiction checks upon use. If you do not do this, your addictions will not work!

  1. Navigate to qb-core/server/functions.lua

  2. Find the QBCore.Functions.UseItem function

    1. This should be around line 504, but could differ depending on your version

  3. Add the following export to the bottom of the function:

    1. exports['envi-addictions']:UsedItem(source, item)
    2. For example, if you're using qb-inventory then your updated function should look like this:

      function QBCore.Functions.UseItem(source, item)
          if GetResourceState('qb-inventory') == 'missing' then return end
          exports['qb-inventory']:UseItem(source, item) -- This might differ depending on what inventory you're using
          exports['envi-addictions']:UsedItem(source, item) -- MAKE SURE YOU ADD THIS LINE
      end

Only do this if you are NOT using ox_inventory

  1. Navigate to [core]/es_extended/server/functions.lua

  2. Find the ESX.UseItem function

    1. Should be around line 515

  3. Replace that function with the following:

    1. function ESX.UseItem(source, item, ...)
          if ESX.Items[item] then
              local itemCallback = Core.UsableItemsCallbacks[item]
      
              if itemCallback then
                  local success, result = pcall(itemCallback, source, item, ...)
      
                  if not success then
                      return result and print(result) or print(('[^3WARNING^7] An error occured when using item ^5"%s"^7! This was not caused by ESX.'):format(item))
                  end
                  
                  exports['envi-addictions']:UsedItem(source, item) -- NEWLY ADDED LINE
              end
          else
              print(('[^3WARNING^7] Item ^5"%s"^7 was used but does not exist!'):format(item))
          end
      end

There isn't an equivalent function to update in QBox, since that's pretty much hard coded to use ox_inventory, so if for some reason you switched to a different inventory then you might need to reach out in our discord to get some assistance with that

PreviousEnvi-AddictionsNextInventory Setup

Last updated 4 days ago

📒
💊
❗