jimathy / jim-shops

QBCore QB-Menu based replacement for qb-shops
53 stars 42 forks source link

[ script:jim-shops] SCRIPT ERROR: @jim-shops/server.lua:125: attempt to get length of a nil value (field 'products') [ script:jim-shops] > handler (@jim-shops/server.lua:3) #15

Closed subhampro closed 2 years ago

subhampro commented 2 years ago

Error :

image

AddEventHandler('onResourceStart', function(resource) if GetCurrentResourceName() == resource then TriggerEvent("jim-shops:MakeStash") end
    for k, v in pairs(Config.Products) do
        for i = 1, #v do
            if not QBCore.Shared.Items[Config.Products[k][i].name] then
                print("Config.Products['"..k.."'] can't find item: "..Config.Products[k][i].name)
            end
        end
    end
    for k, v in pairs(Config.Locations) do
        if v["products"] == nil then
            print("Config.Locations['"..k.."'] can't find its product table")
        end
    end
end)

Line No 125 : for i = 1, #v["products"] do


    for k, v in pairs(Config.Locations) do
        local stashTable = {}
        for l, b in pairs(v["coords"]) do
            for i = 1, #v["products"] do
                if Config.Debug then print("MakeStash - Searching for item '"..v["products"][i].name.."'")
                    if not QBCore.Shared.Items[v["products"][i].name:lower()] then 
                        print ("MakeStash - Can't find item '"..v["products"][i].name.."'")
                    end
                end
                local itemInfo = QBCore.Shared.Items[v["products"][i].name:lower()]
                stashTable[i] = {
                    name = itemInfo["name"],
                    amount = tonumber(v["products"][i].amount),
                    info = {},
                    label = itemInfo["label"],
                    description = itemInfo["description"] ~= nil and itemInfo["description"] or "",
                    weight = itemInfo["weight"],
                    type = itemInfo["type"],
                    unique = itemInfo["unique"],
                    useable = itemInfo["useable"],
                    image = itemInfo["image"],
                    slot = i,
                }
            end
        if Config.Limit then TriggerEvent('jim-shops:server:SaveStashItems', "["..k.."("..l..")]", stashTable)
        elseif Config.Limit == false then stashname = "["..k.."("..l..")]" MySQL.Async.execute('DELETE FROM stashitems WHERE stash= ?', {stashname}) end 
        end
    end
end)```
jimathy commented 2 years ago

I believe it's telling you issue. It can't find drugstore in products, either it can't find ANY of them or just that one.

subhampro commented 2 years ago

I believe it's telling you issue. It can't find drugstore in products, either it can't find ANY of them or just that one.

bro i know drugstore issue i can fix it !!

I am asking for

[ script:jim-shops] SCRIPT ERROR: @jim-shops/server.lua:125: attempt to get length of a nil value (field 'products') [ script:jim-shops] > handler (@jim-shops/server.lua:3) 
jimathy commented 2 years ago

Like I said I think there's an issue in your products making it so it cant find the entire table. I don't know.

damino974 commented 1 month ago

SCRIPT ERROR: @jim-shops/server.lua:274: jim-shops was unable to execute a query! [ script:jim-shops] Query: SELECT * FROM stashitems [ script:jim-shops] [1]