So I am working on a burglary script that pulls a random amount of a random item from a table. this is my table
cfg.items = {
["stolen_jewels"] = { min = 1, max = 3 },
["dirty_money"] = { min = 200, max = 1000 },
["pills"] = { min = 1, max = 7 },
["lockpicking_kit"] = { min = 1, max = 3 },
}
However, I can retrieve the items, but I get all the items with a random amount, this is my function and my thread.
I only want 1 item with a random amount to show be picked up.
Citizen.CreateThread(function()
while true do
Citizen.Wait(1)
local coords = GetEntityCoords(PlayerPedId())
local pair = cfg.items
for key,value in pairs(cfg.homes) do
if onBurglary then
for k,search in pairs(value.spots) do
if Vdist(coords, search.x, search.y, search.z) < 1.4 then
DrawTxt3D(search.x, search.y, search.z, textSearch, 0.3)
if IsControlJustPressed(0, 38) then
BRGserver.searchForItems(pair)
end
end
end
end
end
end
end)
function vRPbrg.searchForItems(pair)
for item,v in pairs(pair) do
local user_id = vRP.getUserId(source)
local found = pair[item]
local amount = math.random(found.min,found.max)
vRP.giveInventoryItem(user_id,item,amount,true)
end
end
note: I know it’s vRP, but this is really a lua table question and not a framework issue. Any help would be great!