Skip to content

Latest commit

 

History

History
70 lines (62 loc) · 2.68 KB

ReadMe - Copia.md

File metadata and controls

70 lines (62 loc) · 2.68 KB

function vRP.itemWeightList(item) return inventario.get_item_peso(item) end

function vRP.getItemWeight(idname) return inventario.get_item_peso(item) end


-- GETINVENTORYITEMAMOUNT

function vRP.getInventoryItemAmount(user_id,idname) local data = vRP.getUserDataTable(user_id) if data and data.inventory then local entry = data.inventory[idname] if entry then return entry.amount end end return 0 end

-- GIVEINVENTORYITEM

function vRP.giveInventoryItem(user_id,idname,amount) local amount = parseInt(amount) local data = vRP.getUserDataTable(user_id) if data and amount > 0 then local entry = data.inventory[idname] if entry then entry.amount = entry.amount + amount else data.inventory[idname] = { amount = amount } end end end

-- TRYGETINVENTORYITEM

function vRP.tryGetInventoryItem(user_id,idname,amount) local amount = parseInt(amount) local data = vRP.getUserDataTable(user_id) if data and amount > 0 then --if idname == "tora" or idname == "carnedepuma" or idname == "etiqueta" then --creativeLogs(creative_itens,"USER_ID: "..user_id.." ITEM: "..idname.." - QUANTIDADE: "..parseInt(amount).." - "..os.date("%H:%M:%S")) --end local entry = data.inventory[idname] if entry and entry.amount >= amount then entry.amount = entry.amount - amount

		if entry.amount <= 0 then
			data.inventory[idname] = nil
		end
		return true
	end
end
return false

end

-- REMOVEINVENTORYITEM

function vRP.removeInventoryItem(user_id,idname,amount,notify) local current_amount = vRP.getInventoryItemAmount(idname) return vRP.tryGetInventoryItem(user_id,idname,current_amount) end