Coder Social home page Coder Social logo

[Bug] Selling Drugs about cad-drugsales HOT 3 CLOSED

cadburry6969 avatar cadburry6969 commented on August 15, 2024
[Bug] Selling Drugs

from cad-drugsales.

Comments (3)

MadManDanCat avatar MadManDanCat commented on August 15, 2024 1

@galibmahin replace this function

local function InitiateSell(ped, randamt)
local AlreadySold = false
local k = CurrentZone.name
randamt = randamt or 1 -- Set the default value for randamt if it's not provided

if Config.ZoneDrugs[k] then
    local player = QBCore.Functions.GetPlayerData()
    local playerInventory = player.items

    for _, randdrug in ipairs(Config.ZoneDrugs[k]) do
        local price = randdrug.price
        local item = QBCore.Shared.Items[randdrug.item]
        local itemData = nil

        for _, inventoryItem in ipairs(playerInventory) do
            if inventoryItem.name == randdrug.item then
                itemData = inventoryItem
                break
            end
        end

        if not AlreadySold then
            if itemData and itemData.amount >= randamt then
                AlreadySold = true
                InitiateSellProgress = true
                local SaleMenu = {
                    {
                        header = tostring(randamt).."x of "..QBCore.Shared.Items[tostring(randdrug.item)]['label'].." for "..QBCore.Shared.Round(randamt * price, 0).."$",
                        isMenuHeader = true
                    },
                    {
                        header = "Accept Offer",
                        params = {
                            event = 'cad-drugsales:salesinitiate',
                            args = {
                                type = 'buy',
                                item = randdrug.item,
                                price = price,
                                amt = randamt,
                                tped = ped
                            }
                        }
                    },
                    {
                        header = "Decline Offer",
                        params = {
                            event = 'cad-drugsales:salesinitiate',
                            args = {
                                type = 'close',
                                tped = ped
                            }
                        }
                    }
                }
                exports[Config.Menu]:openMenu(SaleMenu)
                TimeoutMenu(ped)
                break
            else
                if Config.Debug then
                    print("You don't have enough ["..randdrug.item.."] to sell")
                    if itemData then
                        print("You have ["..itemData.amount.."] but need ["..randamt.."]")
                    else
                        print("You have [0] but need ["..randamt.."]")
                    end
                end
            end
        end
    end
    if not AlreadySold then
        SetPedAsNoLongerNeeded(ped)
        TriggerEvent('QBCore:Notify', 'Person wanted more stuff but you didn\'t have!')
    end
end

end

from cad-drugsales.

cadburry6969 avatar cadburry6969 commented on August 15, 2024

are you using old qbcore?

from cad-drugsales.

cadburry6969 avatar cadburry6969 commented on August 15, 2024

@MadManDanCat & @galibmahin
Pushed Version 2.1.2 which should be a permanent fix to these

from cad-drugsales.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.