EZ Scripts
DiscordTebex
  • 💡Welcome To EZ Scripts
  • FIVEM
    • 🍀EZ White Widow
      • Config File
      • Add more locations
      • Common Issues
    • 🟣EZ Lean Drug
      • Config File
      • Add more locations
    • ❄️EZ Coke & Crack Drug
      • Config File
      • Add more locations
    • 🔠EZ Plate Changer
      • Config File
    • 📑Ez Lib
      • Config File
    • 🛡️Ez Admin Authority
      • Config File
    • 🫳Ez Item Spawner
      • Config File
      • Permission Check
      • Add Item
      • Get Items
  • RedM
    • 💼EZ Society & Job Meny
      • Config File
      • Exports
      • Syn Society
    • 🌍EZ Fast Travel
      • Config File
    • 🛡️Ez Admin Authority
      • Config File
    • 🍖Ez Consumables
      • Config File
    • 📺Ez HUD
      • Config File
      • Exports and Events
    • 🚷EZ Combat Logging
      • Config File
    • 🗽EZ Life Style
      • Getting Life Style
      • Config File
    • ☢️EZ Radial Menu
      • Config File
    • 🫳Ez Item Spawner
      • Config File
      • Permission Check
      • Add Item
      • Get Items
Powered by GitBook
On this page
  • VORP
  • QBCore

Was this helpful?

  1. RedM
  2. Ez Item Spawner

Add Item

A function which adds item to a player. How you can adapt the function for other framework example.

VORP

SConfig.AddItem = function(source, item, amount, type)
    local VORPInv = exports.vorp_inventory
    if type == "item" then
        local itemCheck = VORPInv:getItemDB(item)
        local canCarry = VORPInv:canCarryItems(source, amount)       --can carry inv space
        local canCarry2 = VORPInv:canCarryItem(source, item, amount) --cancarry item limit

        if not itemCheck or not canCarry or not canCarry2 then
           return false
        end

        VORPInv:addItem(source, item, amount)
    elseif type == "weapon" then
        local canCarry = VORPInv:canCarryWeapons(source, amount, nil, item)
        if canCarry then
            return false
        end
        local result = VORPInv:createWeapon(source, item, {})
        if not result then
            return false
        end
    end
    return true
end

QBCore

SConfig.AddItem = function(source, item, amount, type)
    local Player = QBCore.Functions.GetPlayer(source)
    if not Player then return false end
    if not Player.Functions.AddItem(item, amount) then
        return false
    end
    return true
end
PreviousPermission CheckNextGet Items

Last updated 4 months ago

Was this helpful?

🫳