RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

InternalMap Cleanup

Status
Not open for further replies.

]Raiden[

Wanderer
Voran,

Here it is..

[code:1]using System;
using System.Collections;
using Server;
using Server.Network;
using Server.Mobiles;
using Server.Accounting;

namespace Server.Gumps
{
public class InternalItemGump : Gump
{
public static void Initialize()
{
Commands.Register( "InternalItems", AccessLevel.Administrator, new CommandEventHandler( InternalItems_OnCommand ) );
}
public static string m_args;
[Usage( "InternalItems" )]
[Description( "Lists all items on Internal map." )]
private static void InternalItems_OnCommand( CommandEventArgs e )
{
e.Mobile.SendGump( new InternalItemGump( e.Mobile ) );
}

public const int GumpOffsetX = 30;
public const int GumpOffsetY = 30;

public const int TextHue = 0;
public const int TextOffsetX = 2;

public const int OffsetGumpID = 0x0052; // Pure black
public const int HeaderGumpID = 0x0E14; // Dark navy blue, textured
public const int EntryGumpID = 0x0BBC; // Light offwhite, textured
public const int BackGumpID = 0x13BE; // Gray slate/stoney
public const int ButtonGumpID = 0x0E14; // Dark navy blue, textured

public const int ButtonWidth = 20;

public const int GoOffsetX = 2, GoOffsetY = 2;
public const int GoButtonID1 = 0x15E1; // Arrow pointing right
public const int GoButtonID2 = 0x15E5; // " pressed

public const int DeleteOffsetX = 1, DeleteOffsetY = 1;
public const int DeleteButtonID1 = 0x0A94; // 'X' Button
public const int DeleteButtonID2 = 0x0A95; // " pressed

public const int PrevWidth = 20;
public const int PrevOffsetX = 2, PrevOffsetY = 2;
public const int PrevButtonID1 = 0x15E3; // Arrow pointing left
public const int PrevButtonID2 = 0x15E7; // " pressed

public const int NextWidth = 20;
public const int NextOffsetX = 2, NextOffsetY = 2;
public const int NextButtonID1 = 0x15E1; // Arrow pointing right
public const int NextButtonID2 = 0x15E5; // " pressed

public const int WipeWidth = 20;
public const int WipeOffsetX = 0, WipeOffsetY = 1;
public const int WipeButtonID1 = 0x0A94; // 'X' Button
public const int WipeButtonID2 = 0x0A95; // " pressed

public const int OffsetSize = 1;

public const int EntryHeight = 20;
public const int BorderSize = 10;

private static bool PrevLabel = false, NextLabel = false, WipeLabel = true;

private const int PrevLabelOffsetX = PrevWidth + 1;
private const int PrevLabelOffsetY = 0;

private const int NextLabelOffsetX = -29;
private const int NextLabelOffsetY = 0;

private const int WipeLabelOffsetX = WipeWidth + 1;
private const int WipeLabelOffsetY = 0;

private const int EntryWidth = 500;
private const int EntryCount = 15;

private const int TotalWidth = OffsetSize + EntryWidth + OffsetSize + (ButtonWidth * 2) + OffsetSize;
private const int TotalHeight = OffsetSize + ((EntryHeight + OffsetSize) * (EntryCount + 2));

private const int BackWidth = BorderSize + TotalWidth + BorderSize;
private const int BackHeight = BorderSize + TotalHeight + BorderSize;

private Mobile m_Owner;
private ArrayList m_Names;
private int m_Page;

public InternalItemGump( Mobile owner ) : this( owner, BuildList( owner ), 0 )
{
}

public InternalItemGump( Mobile owner, ArrayList list, int page ) : base( GumpOffsetX, GumpOffsetY )
{
owner.CloseGump( typeof( InternalItemGump ) );

m_Owner = owner;
m_Names = list;

Initialize( page );
}

public static ArrayList BuildList( Mobile owner )
{
ArrayList list = new ArrayList();
foreach ( Item i in World.Items.Values )
{
if (i.Map == Map.Internal && i.Parent == null)
list.Add(i);
}
return list;
}

public void Initialize( int page )
{
m_Page = page;

int count = m_Names.Count - (page * EntryCount);

if ( count < 0 )
count = 0;
else if ( count > EntryCount )
count = EntryCount;

int totalHeight = OffsetSize + ((EntryHeight + OffsetSize) * (count + 2));

AddPage( 0 );

AddBackground( 0, 0, BackWidth, BorderSize + totalHeight + BorderSize, BackGumpID );
AddImageTiled( BorderSize, BorderSize, TotalWidth, totalHeight, OffsetGumpID );

int x = BorderSize + OffsetSize;
int y = BorderSize + OffsetSize;

//int emptyWidth = TotalWidth - PrevWidth - NextWidth - (OffsetSize * 4);
int emptyWidth = EntryWidth;

AddImageTiled( x, y, emptyWidth, EntryHeight, EntryGumpID );

AddLabel( x + TextOffsetX, y, TextHue, string.Format( "Page {0} of {1} ({2}) - Matches for: {3}", page+1, (m_Names.Count + EntryCount - 1) / EntryCount, m_Names.Count, m_args) );

x += emptyWidth + OffsetSize;

AddImageTiled( x, y, PrevWidth, EntryHeight, HeaderGumpID );

if ( page > 0 )
{
AddButton( x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 1, GumpButtonType.Reply, 0 );

if ( PrevLabel )
AddLabel( x + PrevLabelOffsetX, y + PrevLabelOffsetY, TextHue, "Previous" );
}

x += PrevWidth + OffsetSize;

AddImageTiled( x, y, NextWidth, EntryHeight, HeaderGumpID );

if ( (page + 1) * EntryCount < m_Names.Count )
{
AddButton( x + NextOffsetX, y + NextOffsetY, NextButtonID1, NextButtonID2, 2, GumpButtonType.Reply, 1 );

if ( NextLabel )
AddLabel( x + NextLabelOffsetX, y + NextLabelOffsetY, TextHue, "Next" );
}

for ( int i = 0, index = page * EntryCount; i < EntryCount && index < m_Names.Count; ++i, ++index )
{
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;

Item item = (Item)m_Names[index];

AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, 33,
item.Deleted ? "(deleted)" : (string.Format("{0}:{1}:{2}:{3}", item.GetType().Name, item.ItemID , item.Map, item.Location ) ));

if ( !item.Deleted )
{
x += EntryWidth + OffsetSize;
AddImageTiled( x, y, ButtonWidth, EntryHeight, ButtonGumpID );
AddButton( x + DeleteOffsetX, y + DeleteOffsetY, DeleteButtonID1, DeleteButtonID2, i + 4, GumpButtonType.Reply, 0 );

x += ButtonWidth + OffsetSize;
AddImageTiled( x, y, ButtonWidth, EntryHeight, ButtonGumpID );
}
}

x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;

AddImageTiled( x, y, TotalWidth, EntryHeight, EntryGumpID );

AddImageTiled( x, y, WipeWidth, EntryHeight, HeaderGumpID );

AddButton( x + WipeOffsetX, y + WipeOffsetY, WipeButtonID1, WipeButtonID2, 3, GumpButtonType.Reply, 1 );

if ( WipeLabel )
AddLabel( x + WipeLabelOffsetX, y + WipeLabelOffsetY, TextHue, "Wipe All Items Not Attached to Players" );
}

public override void OnResponse( NetState state, RelayInfo info )
{
Mobile from = state.Mobile;

switch ( info.ButtonID )
{
case 0: // Closed
{
return;
}
case 1: // Previous
{
if ( m_Page > 0 )
from.SendGump( new InternalItemGump( from, m_Names, m_Page - 1 ) );

break;
}
case 2: // Next
{
if ( (m_Page + 1) * EntryCount < m_Names.Count )
if( from != null)
from.SendGump( new InternalItemGump( from, m_Names, m_Page + 1 ) );
break;
}
case 3: // Wipe All Listed
{
from.SendGump( new WipeAllGump(from, m_Names) );
break;
}
default:
{
int index = (m_Page * EntryCount) + (info.ButtonID - 4);
bool deleting = index < 1000;
if (!deleting)
index -= 1000;

if ( index >= 0 && index < m_Names.Count )
{
Item s = (Item)m_Names[index];

if ( s.Deleted )
{
from.SendMessage( "That item no longer exists." );
from.SendGump( new InternalItemGump( from, m_Names, m_Page ) );
}
else
{
if (deleting)
from.SendGump( new DeleteItemGump(from, m_Names, index) );
}
}

break;
}
}
}

private class DeleteItemGump : Gump
{
private Mobile m_From;
private ArrayList m_Names;
private int m_Index;

public DeleteItemGump( Mobile from, ArrayList spawners, int index ) : base( 50, 50 )
{
m_From = from;
m_Names = spawners;
m_Index = index;

AddPage( 0 );

AddBackground( 0, 0, 270, 120, 5054 );
AddBackground( 10, 10, 250, 100, 3000 );

AddHtml( 20, 15, 230, 60, "Are you sure you wish to delete this item?", true, true );

AddButton( 20, 80, 4005, 4007, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 80, 75, 20, 1011011, false, false ); // CONTINUE

AddButton( 135, 80, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 170, 80, 75, 20, 1011012, false, false ); // CANCEL
}

public override void OnResponse( Server.Network.NetState sender, RelayInfo info )
{
if ( info.ButtonID == 2 )
{
((Item)m_Names[m_Index]).Delete();
m_Names.RemoveAt(m_Index);
m_From.SendLocalizedMessage( 1010303 ); // deleted object
}
m_From.SendGump( new InternalItemGump( m_From, m_Names, 0 ) );
}
}

private class WipeAllGump : Gump
{
private Mobile m_From;
private ArrayList m_Names;

public WipeAllGump( Mobile from, ArrayList spawners ) : base( 50, 50 )
{
m_From = from;
m_Names = spawners;

AddPage( 0 );

AddBackground( 0, 0, 270, 120, 5054 );
AddBackground( 10, 10, 250, 100, 3000 );

AddHtml( 20, 15, 230, 60,
"Are you sure you wish to delete all listed items?", true, true );

AddButton( 20, 80, 4005, 4007, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 80, 75, 20, 1011011, false, false ); // CONTINUE

AddButton( 135, 80, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 170, 80, 75, 20, 1011012, false, false ); // CANCEL
}

public override void OnResponse( Server.Network.NetState sender, RelayInfo info )
{
if ( info.ButtonID == 2 )
{
foreach ( Item item in m_Names )
{
item.Delete();
}

m_From.SendMessage( "Deleted items." );
}
}
}
}
}[/code:1]
 

SonnyJim

Wanderer
um i dont know why but i keep getting gems in the internal map thousands of them every day i have to do internalitems 2 delete them any ideas why the gems keep going to internal map?
 

SoulStone

Wanderer
Re: this will delete mounts

Dragon Slayer said:
this code you have posted or this command will delete bonded pets or mounts in the game have no clue why :(

Yes, this code is an older version and is incomplete. Try to download the current one from the link (as it is working pretty well now). The script will work fine except it will delete commodity items too. To fix it change this (around line 109):
[code:1] if (i.Map == Map.Internal && i.Parent == null && !(i is Server.Items.Fists) && !(i is MountItem) && !(i is Server.Items.EffectItem) )[/code:1]
To this:
[code:1] if (i.Map == Map.Internal && i.Parent == null && !(i is Server.Items.Fists) && !(i is MountItem) && !(i is Server.Items.EffectItem) && ! ( i is ICommodity ) )[/code:1]
Oh! And don`t forget to include this on the top of the file or it won`t compile:
[code:1]using Server.Items; [/code:1]

I hope this will help! 8)


SoulStone.
 

Fury

Wanderer
Download now includes the fix for commodity deeds... also if your using basequests that was added as well but you need to uncomment it.
 

Haramis

Wanderer
I just dropped it in, managed to get a crash with the following report :

[code:1]Exception:
System.NullReferenceException: Object reference not set to and object. at Server.Gumps.InternalMobilesGump.Initialize(Int32 page)
at Server.Gumps.InternalMobilesGump..ctor(Mobile owner, ArrayList list, Int32 page)
at Server.Gumps.InternalMobilesGump.OnResponse(NetState state, RelayInfo info)
at Server.Network.PacketHandlers.DisplayGumpResponse(NetState state, PacketReader pvSrc)
at Server.Network.MessagePump.HandleReceive(NetState ns)
at Server.Network.MessagePump.Slice()
at Server.Core.Main(String[] args)[/code:1]

thx for help :)
btw I get a horde of chicken in my internal map :( eeeeeeep....

edit : crash happens when I scroll thru pages, on internalmobiles, I got 24 pages the first 2 times it was on like page 10 last time I scrolled til page 24... maybe that helps :)
 

Knightshade

Wanderer
That's the same error I posted about. After getting to a particular page...BOOM! crash! :eek:

...and since the shard crashes before displaying the page, I can't tell what it is that's causing it on that particular page. :(
 
Status
Not open for further replies.
Top