For your second question, just change prefix_num here to whatever value you want
1
for i=1, math.random(0,prefix_num) do
If tibia stores the player's inventory using item ids then you will have to hack it a little so it uses tables storing the item data directly instead.