ReZurrecti0n
Member
- ServUO Version
- Publish Unknown
- Ultima Expansion
- None
I'm trying to create a simple function to remove items at a location, but the server just crashes. If I remove the 't.Delete();' line, everything else works as intended.
The Crash Message:
EDIT:
You may need the entire script come to think of it...
Code:
IPooledEnumerable items = map.GetItemsInRange( new Point3D( x, y, 0 ), 0 );
foreach ( Item t in items )
{
t.Delete();
}
The Crash Message:
Crash:
Exception:
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.ThrowHelper.ThrowArgumentOutOfRangeException()
at System.Collections.Generic.List`1.get_Item(Int32 index)
at System.Collections.Generic.List`1.System.Collections.IList.get_Item(Int32 index)
at Server.Map.TypedEnumerator.MoveNext()
at Server.AVGenerator.AddItem(Boolean wipe, Int32 itemid, Int32 x, Int32 y, Int32 z, Map map, String name, Int32 hue)
at Server.AVGenerator.AVGenerate()
at Server.Commands.CommandSystem.Handle(Mobile from, String text, MessageType type)
at Server.Mobile.DoSpeech(String text, Int32[] keywords, MessageType type, Int32 hue)
at Server.Mobiles.PlayerMobile.DoSpeech(String text, Int32[] keywords, MessageType type, Int32 hue)
at Server.Network.PacketHandlers.UnicodeSpeech(NetState state, PacketReader pvSrc)
at Server.Network.MessagePump.HandleReceive(NetState ns)
at Server.Network.MessagePump.Slice()
at Server.Core.Main(String[] args)
EDIT:
You may need the entire script come to think of it...
Script:
using System;
using Server;
using Server.Commands;
using Server.Items;
using Server.Mobiles;
namespace Server
{
public class AVGenerator
{
public static void Initialize()
{
CommandSystem.Register( "AVGen", AccessLevel.Administrator, new CommandEventHandler( AVGen_OnCommand ) );
}
[Usage( "AVGen" )]
[Description( "Generates AV World" )]
public static void AVGen_OnCommand( CommandEventArgs e )
{
AVGenerate();
}
private static Map m_Map;
public static void AVGenerate()
{
World.Broadcast( 0x35, true, "Generating AV World, please wait..." );
Network.NetState.FlushAll();
Network.NetState.Pause();
AddItem( true, 1801, 5951, 343, -22, Map.Trammel, "", 0);
Network.NetState.Resume();
World.Broadcast( 0x43, true, "AV World generation complete." );
}
private static void AddItem( bool wipe, int itemid, int x, int y, int z, Map map, string name, int hue )
{
if(wipe)
{
IPooledEnumerable items = map.GetItemsInRange( new Point3D( x, y, 0 ), 0 );
foreach ( Item t in items )
{
t.Delete();
World.Broadcast( 1150, true, "TM: Item was detected!" );
}
}
Item item = new GreySlateFloor();
item.ItemID = itemid;
if(name != "")
{ item.Name = name; }
if(hue != 0)
{ item.Hue = hue; }
item.MoveToWorld(new Point3D( x, y, z ), map);
}
}
}
Last edited: