Storage Areas Question

Here you can post threads requesting help on the official POL Ultima Online Emulator Core 097.
Note: Core 097 is no longer officially supported.
Post Reply
Gnafu
Grandmaster Poster
Posts: 136
Joined: Thu Feb 02, 2006 7:29 am

Storage Areas Question

Post by Gnafu »

Hi to all..

I cannot find a function to list all the root items in a storage area.

I can do this:

Code: Select all


  var objects:= array;
  var storage_areas := StorageAreas(); 
   foreach area_name in ( storage_areas ) 
      var storage_area := FindStorageArea(area_name); 
      SendSysMessage(who, "Nome: "+area_name);
      SendSysMessage(who, "Area: "+storage_area);

      foreach root_container in ( storage_area ) 
         if ( !(root_container in objects) ) 
            objects.Append(root_container); 
            SendSysMessage(who, "Oggetto: "+root_container);
         endif 

         foreach item in ( EnumerateItemsInContainer(root_container) ) 
            if ( !(item in objects) ) 
              objects.Append(item); 
            SendSysMessage(who, "Oggetto: "+root_container);
            endif 
         endforeach 
      endforeach 
   endforeach 

The line "SendSysMessage(who, "Area: "+storage_area);" allways print "Area: 0" to the screen.

Can anyone explain how storage areas are organized and who can i iterate through all the items in it?

Thanks in advance

Gnafu
User avatar
CWO
POL Expert
Posts: 1160
Joined: Sat Feb 04, 2006 5:49 pm

Post by CWO »

I think I ripped this script from distro... there may be a few modifications from that but this is what I use to list everything in all storage areas. This is a WWW script.

Code: Select all

use uo;
use os;
use http;
use polsys;


program HTMLPage()
	DoHeader("Server Management Storage");

	TableHeader("Storage");
	var storage_area := QueryParam("Area");
	var container := QueryParam("Root");

	if ( storage_area && container )
		ShowContainer(storage_area, container);
	elseif ( storage_area )
		ShowStorageArea(storage_area);
	else
		ListStorageAreas();
	endif

	DoFooter();

	return 1;
endprogram

function ShowContainer(storage_area, container)
	container := SystemFindObjectBySerial(CInt(container));

	WriteHTML("<P>Storage Area - <A HREF='?Area="+storage_area+"'>"+storage_area+"</A><BR>");
	WriteHTML("Root Container - "+container.desc+"</P>");

	WriteHTML("<TABLE>");
	WriteHTML("<TR>");
	WriteHTML("<TD CLASS='header2'>Name</TD><TD CLASS='header2'>Serial</TD>");
	WriteHTML("</TR>");
	foreach item in ( EnumerateItemsInContainer(container) )
		WriteHTML("<TR>");
		WriteHTML("<TD>"+item.desc+"</TD>");
		WriteHTML("<TD>"+Hex(item.serial)+"</TD>");
		WriteHTML("</TR>");
		SleepMS(2);
	endforeach
	WriteHTML("</TABLE>");

	return 1;
endfunction

function ShowStorageArea(storage_area)
	var storage_areas := StorageAreas();
	var area := storage_areas[storage_area];

	WriteHTML("<P>Storage Area - "+storage_area+"</P>");
	WriteHTML("<P>Root Items: "+area.count+"<BR>");
	WriteHTML("Total Items: "+area.totalcount+"</P>");

	WriteHTML("<TABLE>");
	WriteHTML("<TR>");
	WriteHTML("<TD CLASS='header2'>Name</TD><TD CLASS='header2'>Item Count</TD>");
	WriteHTML("</TR>");
	foreach container in ( area )
		WriteHTML("<TR>");
		WriteHTML("<TD><A HREF='?Area="+storage_area+"&Root="+Hex(container.serial)+"'>"+container.desc+"</TD>");
		WriteHTML("<TD>"+container.item_count+"</TD>");
		WriteHTML("</TR>");
		SleepMS(2);
	endforeach

	WriteHTML("</TABLE>");

	return 1;
endfunction

function ListStorageAreas()
	WriteHTML("<P>Storage Areas</P>");

	WriteHTML("<TABLE>");
	WriteHTML("<TR>");
	WriteHTML("<TD CLASS='header2'>Area Name</TD>");
	WriteHTML("<TD CLASS='header2'>Root Item Count</TD>");
	WriteHTML("<TD CLASS='header2'>Total Items</TD>");
	foreach area in ( StorageAreas() )
		WriteHTML("<TR>");
		WriteHTML("<TD><A HREF='?Area="+area+"'>"+area+"</A></TD>");
		WriteHTML("<TD>"+area.count+"</TD>");
		WriteHTML("<TD>"+area.totalcount+"</TD>");
		WriteHTML("</TR>");
		SleepMS(2);
	endforeach

	WriteHTML("</TABLE>");

	return 1;
endfunction

function DoHeader(title:="")
	WriteHTML("<HEAD>");
	WriteHTML("<TITLE>"+title+"</TITLE>");
	WriteHTML("<LINK REL='stylesheet' TYPE='text/css' HREF='../../stylesheet.css'>");
	WriteHTML("</HEAD>");

	WriteHTML("<BODY>");
	return 1;
endfunction

function DoFooter()
	WriteHTML("</BODY>");

	return 1;
endfunction

function TableHeader(name:="")
	WriteHtmlRaw("<TABLE WIDTH='100%'>"
		+"<TR>"
		+"<TD VALIGN='TOP' WIDTH='100%' CLASS='header'><STRONG><BIG>"+name+"</BIG></STRONG></TD>"
		+"<TD WIDTH='100' VALIGN='TOP' ALIGN='CENTER' NOWRAP CLASS='header2'><A HREF='index.ecl'><FONT SIZE=1>ServMgmt Home</FONT></A></TD>"
		+"</TR>"
		+"</TABLE>");

	return 1;
endfunction
Post Reply