I made this model as you explained how it works.
 
	 
 
//Add a call function in item
// callfunc "Boxx";
function	script	Boxx	{
	//Item ID
	//==
	setarray .@ItemID[0],1108,2104,5011,2301,2404;
	//check if you still have an item with a refine lower than 10
	//==
	for(set .@i,0; .@i<getarraysize(.@ItemID); set .@i,.@i+1)
		if((getd("eqi_"+.@ItemID[.@i])-1) < 10) setarray .@equips[getarraysize(.@equips)],.@ItemID[.@i];
	
	//All refined +10
	//==
	if(!getarraysize(.@equips)){ dispbottom "Bye bye."; end; }
	
	set .@idx,rand(getarraysize(.@equips));
	set .@slot,getiteminfo(.@equips[.@idx],ITEMINFO_LOC);
	
	switch(.@slot)
	{
		case 2: set .@slot,EQI_HAND_R; break;
		case 16: set .@slot,EQI_ARMOR; break;
		case 32: set .@slot,EQI_HAND_L; break;
		case 64: set .@slot,EQI_SHOES; break;
		case 256: set .@slot,EQI_HEAD_TOP; break;
	}	
	if(getd("eqi_"+.@equips[.@idx]))
	{		
		if(!countitem(.@equips[.@idx])){ dispbottom "Item not found "+getitemname(.@equips[.@idx])+"!"; end; }
		if(getequipid(.@slot) != .@equips[.@idx]) equip .@equips[.@idx];
		successrefitem .@slot;
		setd "eqi_"+.@equips[.@idx],getd("eqi_"+.@equips[.@idx])+1;
	}
	else
	{ setd "eqi_"+.@equips[.@idx],1; getitem .@equips[.@idx],1; }
	
end;
}