looking for a simple function to create usable items from a config list each item triggers the same function with item name passed and dont want to make 30+ functions for them
eveything i try fails
example
Config.UsableSeeds = {
"weed_tropicana-cookies_seed",
"weed_mai-tai_seed",
"weed_green-crack_seed",
"weed_hawaiian-haze_seed",
}
QBCore.Functions.CreateUseableItem(Config.UsableSeeds, function(source, item)
src = source
local player = QBCore.Functions.GetPlayer(src)
local citizenid = player.PlayerData.citizenid
local planttype = Config.Plants[item.name].Type
local result = MySQL.query.await('SELECT * FROM plant_limits WHERE citizenid= ?', {citizenid})
if result[1] ~= nil then
if result[1].amount < Config.MaximumAmount then
plantweed(source, item.name)
else
if result[1].amount >= Config.MaximumAmount then
QBCore.Functions.Notify(src, "You have reached max amount allowed", 'error', 3500)
end
end
else
plantweed(source, item.name)
end
end)
just tried: and didnt work either
for k, v inpairs(Config.UsableSeeds) do
QBCore.Functions.CreateUseableItem(v, function(source, item)
src = source
local player = QBCore.Functions.GetPlayer(src)
local citizenid = player.PlayerData.citizenid
local planttype = Config.Plants[item.name].Type
local result = MySQL.query.await('SELECT * FROM plant_limits WHERE citizenid= ?', {citizenid})
if result[1] ~= nil then
if result[1].amount < Config.MaximumAmount then
plantweed(source, item.name)
else
if result[1].amount >= Config.MaximumAmount then
QBCore.Functions.Notify(src, "You have reached max amount allowed", 'error', 3500)
end
end
else
plantweed(source, item.name)
end
end)
end