Full Version : Need Help Please A Crash
xmlspawner >>Scripting Support >>Need Help Please A Crash


<< Prev | Next >>

Erica- 01-08-2007
Hi not sure what caused this crash but when i got home i saw that my shard had crashed can you please tell me what script might of caused it and how to fix it please heres the crash report
CODE
RunUO Version 2.0, Build 2564.7233
Operating System: Microsoft Windows NT 5.1.2600 Service Pack 2
.NET Framework: 2.0.50727.42
Time: 1/8/2007 3:45:41 PM
Mobiles: 5148
Items: 289378
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(ExceptionArgument argument, ExceptionResource resource)
  at System.ThrowHelper.ThrowArgumentOutOfRangeException()
  at Server.Misc.LeverPuzzle.MakeAttempt()
  at Server.Misc.LeverPuzzle.StandingPad.LeverPulled(Mobile from)
  at Server.Misc.LeverPuzzle.StandingPad.Lever.OnDoubleClick(Mobile from)
  at Server.Mobile.Use(Item item)
  at Server.Network.PacketHandlers.UseReq(NetState state, PacketReader pvSrc)
  at Server.Network.MessagePump.HandleReceive(NetState ns)
  at Server.Network.MessagePump.Slice()
  at Server.Core.Main(String[] args)

Clients:
- Count: 1
+ 24.231.203.71: (account = deffcon1) (mobile = 0x39E 'Ashton')


ArteGordon- 01-08-2007
looks like some custom script. Use AgentRansack to search for the string "LeverPuzzle" in your scripts to track it down.

Erica- 01-08-2007
Ah ok found the script heres the script
CODE
using System;
using System.Collections.Generic;
using Server;
using Server.Items;
using Server.Mobiles;

namespace Server.Misc
{
public class LeverPuzzle
{
 private static List<Statue> Statues = new List<Statue>();
 private static List<StandingPad> Pads = new List<StandingPad>();
 private static int[] Answers = new int[] { 0, 0, 0, 0 };
 private static int[] Guess = new int[] { 0, 0, 0, 0 };
 private static int NextOrder = 1;

 public static void Initialize()
 {
  GenerateAnswers();
 }

 public static void Setup()
 {
  Statues.Add( new Statue() );
  Statues.Add( new Statue() );

  Statues[0].MoveToWorld( new Point3D( 319, 70, 17 ), Map.Malas );
  Statues[1].MoveToWorld( new Point3D( 329, 60, 17 ), Map.Malas );
  Statues[1].ItemID = 4825;

  for ( int i = 0; i < 4; ++i )
  {
   Pads.Add( new StandingPad() );
   Pads[i].MyLever.ID = i;
  }
  Pads.Add( new StandingPad() );
  Pads[4].IsCentralPad = true;
  Pads[4].MyLever.Delete();

  Pads[0].MoveToWorld( new Point3D( 324, 58, -1 ), Map.Malas );
  Pads[0].MyLever.MoveToWorld( new Point3D( 323, 58, 5 ), Map.Malas );
  Pads[1].MoveToWorld( new Point3D( 332, 64, -1 ), Map.Malas );
  Pads[1].MyLever.MoveToWorld( new Point3D( 332, 63, 5 ), Map.Malas );
  Pads[2].MoveToWorld( new Point3D( 323, 72, -1 ), Map.Malas );
  Pads[2].MyLever.MoveToWorld( new Point3D( 323, 71, 5 ), Map.Malas );
  Pads[3].MoveToWorld( new Point3D( 316, 65, -1 ), Map.Malas );
  Pads[3].MyLever.MoveToWorld( new Point3D( 316, 64, 5 ), Map.Malas );
  Pads[4].MoveToWorld( new Point3D( 324, 64, -1 ), Map.Malas );

  Static decoration = new Static( 6178 );
  decoration.MoveToWorld( new Point3D( 324, 64, -1 ), Map.Malas );
  decoration.Movable = false;
  decoration.Hue = 375;
 }

 private static void GenerateAnswers()
 {
  List<int> list = new List<int>();
  for ( int i = 1; i < 5; ++i )
   list.Add( i );

  for ( int i = 0; i < 4; ++i )
  {
   Answers[i] = list[ Utility.Random( 0, 3 - i ) ];
   list.Remove( Answers[i] );
  }
 }

 private static void MakeAttempt()
 {
  ConfirmCorrectPlacment();

  int Amount = 0;

  for ( int i = 0; i < 4; ++i )
  {
   if ( Answers[i] == Guess[i] )
    Amount++;
  }
  GenerateAnswers();
  StatuesTalk( Amount );

  if ( Amount == 4 )
  {
   Pads[4].MobileList[0].BoltEffect( 0 );
   TeleportTimer timer = new TeleportTimer( Pads[4].MobileList[0] );
   timer.Start();
  }
  else
  {
   StoneTimer stonetimer = new StoneTimer();
   stonetimer.Start();
  }

  foreach ( StandingPad pad in Pads )
   if ( pad.MyLever != null )
    pad.MyLever.ItemID = 4238;

  Guess = new int[] { 0, 0, 0, 0 };
  NextOrder = 1;
 }

 private static void StatuesTalk( int NumberCorrect )
 {
  foreach ( Statue s in Statues )
  {
   if ( s == null || s.Deleted )
    continue;
   if ( NumberCorrect == 4 )
    s.PublicOverheadMessage( 0, 0, false, "You may pass to the secret room" );
   else
    s.PublicOverheadMessage( 0, 0, false, "You only got " + NumberCorrect.ToString() + ". The gate remains Closed" );
  }
 }

 private static bool ConfirmCorrectPlacment()
 {
  foreach ( StandingPad pad in Pads )
   if ( pad.MobileList.Count == 0 )
    return false;
  return true;
 }

 private class StandingPad : Item
 {
  public bool IsCentralPad = false;
  public Lever MyLever;
  public List<Mobile> MobileList = new List<Mobile>();

  public StandingPad() : base( 0x1BC3 )
  {
   this.Visible = false;
   this.Name = "Doom Standing Pad";
   MyLever = new Lever( this );
   Movable = false;
  }

  public StandingPad( Serial serial ) : base( serial )
  {
  }

  public override void Serialize( GenericWriter writer )
  {
   base.Serialize( writer );

   writer.Write( (int)0 ); //Version

   writer.Write( IsCentralPad );

   if ( !IsCentralPad )
    writer.Write( MyLever );
  }

  public override void Deserialize( GenericReader reader )
  {
   base.Deserialize( reader );

   int Version = reader.ReadInt();

   IsCentralPad = reader.ReadBool();

   if ( !IsCentralPad )
    MyLever = (Lever)reader.ReadItem();

   Pads.Add( this );
  }

  public void LeverPulled( Mobile from )
  {
   if ( Guess[ MyLever.ID ] != 0 )
    return; // Already Pulled

   if ( from.Location != this.Location )
    return; //They arnt standing in the correct position

   MyLever.ItemID = 4236;
   Guess[ MyLever.ID ] = NextOrder++;

   MyLever.PublicOverheadMessage( 0, 0, false, "*Click*" );

   if ( NextOrder == 5 )
    MakeAttempt();
  }

  public override bool OnMoveOver( Mobile m )
  {
   bool result = base.OnMoveOver( m );

   if ( result && m.Player && !MobileList.Contains( m ) )
    MobileList.Add( m );

   return result;
  }

  public override bool OnMoveOff( Mobile m )
  {
   MobileList.Remove( m );
   return base.OnMoveOff( m );
  }

  public class Lever : Item
  {
   public int ID;
   public StandingPad DoomStandingPad;

   public Lever( StandingPad pad ) : base( 4238 )
   {
    DoomStandingPad = pad;
    Movable = false;
   }

   public Lever( Serial serial ) : base( serial )
   {
   }

   public override void Serialize( GenericWriter writer )
   {
    base.Serialize( writer );

    writer.Write( (int)0 ); //Version

    writer.Write( ID );
    writer.Write( DoomStandingPad );
   }

   public override void Deserialize( GenericReader reader )
   {
    base.Deserialize( reader );

    int Version = reader.ReadInt();

    ID = reader.ReadInt();
    DoomStandingPad = (StandingPad)reader.ReadItem();

    ItemID = 4238;
   }

   public override void OnDoubleClick( Mobile from )
   {
    DoomStandingPad.LeverPulled( from );
   }
  }
 }

 private class Statue : Item
 {
  public Statue() : base( 4824 )
  {
   Hue = 706;
   Movable = false;
  }

  public Statue( Serial serial ) : base( serial )
  {
  }

  public override void Serialize( GenericWriter writer )
  {
   base.Serialize( writer );

   writer.Write( (int)0 ); //Version
  }

  public override void Deserialize( GenericReader reader )
  {
   base.Deserialize( reader );

   int Version = reader.ReadInt();

   Statues.Add( this );
  }
 }

 private class TeleportTimer : Timer
 {
  private Mobile ToTele;
  public TeleportTimer( Mobile totele ) : base( TimeSpan.FromSeconds( 1.5 ) )
  {
   ToTele = totele;
  }

  protected override void OnTick()
  {
   ToTele.BoltEffect( 0 );
   ToTele.MoveToWorld( new Point3D( 470, 96, -1 ), Map.Malas );
  }
 }

 private class StoneTimer : Timer
 {
  public StoneTimer() : base( TimeSpan.FromSeconds( 0.8 ) )
  {
   foreach( StandingPad pad in Pads )
    Effects.SendMovingEffect( new Entity( Serial.Zero, new Point3D( pad.X, pad.Y, pad.Z + 80 ), Map.Malas ), new Entity( Serial.Zero, pad.Location, Map.Malas ), 0x11B8, 5, 16, false, false );
  }

  protected override void OnTick()
  {
   List<Mobile> list = new List<Mobile>();

   foreach( StandingPad pad in Pads )
   {
    Effects.SendLocationEffect( pad.Location, Map.Malas, 0x36B0, 16, 1, 0, 0 );
    Effects.PlaySound( pad.Location, Map.Malas, 0x307 );
    IPooledEnumerable ip = Map.Malas.GetMobilesInRange( pad.Location, 4 );

    foreach ( Mobile m in ip )
    {
     if ( m.AccessLevel == AccessLevel.Player && m.Player || ( m is BaseCreature && ((BaseCreature)m).Controlled ) && list.Contains( m ) )
      list.Add( m );
    }

    ip.Free();

   }
   foreach ( Mobile m in list )
   {
    m.Say( "OUCH!" );
    m.SendMessage( 437,"A speeding rock hits you in the head" );
    AOS.Damage( m, 250 - (int)( GetDistance( m ) * 30 ), 100, 0, 0, 0, 0 );
   }
  }

  private double GetDistance( Mobile m )
  {
   double result = 100;
   foreach ( StandingPad pad in Pads )
   {
    double distance = m.GetDistanceToSqrt( pad.Location );
    if ( distance < result )
     result = distance;
   }

   return result;
  }
 }
}
}
Any idea what i need changed Thanks.

ArteGordon- 01-08-2007
where do you call the Setup() method to initialize your Pads arrays?
The error indicates that you are trying to access elements beyond the allocated size of an array.

If you could get a -debug log it would help figure out what line was causing the crash.

Erica- 01-08-2007
hmm ok how do i do a debug mode cant remember what i type in .

ArteGordon- 01-08-2007
in a console window you can go to the runuo directory and run the command

Runuo.exe -debug

You can also make a shortcut for the Runuo server, go into the properties and set the 'Target' to
"RunUO.exe" -debug

Erica- 01-08-2007
Ok thanks now to figure out how did this person make server crash i am not sure yet but will mess with the lever.

Erica- 01-08-2007
Ok kept going to the levers and kept double clickining them one by one then boom lost connection game said and crashed heres the crash in debug mode
CODE
RunUO Version 2.0, Build 2564.7233
Operating System: Microsoft Windows NT 5.1.2600 Service Pack 2
.NET Framework: 2.0.50727.42
Time: 1/8/2007 9:09:39 PM
Mobiles: 5064
Items: 289106
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(ExceptionArgument argument, ExceptionResource resource)
  at System.ThrowHelper.ThrowArgumentOutOfRangeException()
  at System.Collections.Generic.List`1.get_Item(Int32 index)
  at Server.Misc.LeverPuzzle.MakeAttempt() in c:\Program Files\RunUO 2.0 SVN 132\Scripts\Custom Scripts 2.0\DoomLampPostandGuardianRooms\DoomLeverPuzzle.cs:line 85
  at Server.Misc.LeverPuzzle.StandingPad.LeverPulled(Mobile from) in c:\Program Files\RunUO 2.0 SVN 132\Scripts\Custom Scripts 2.0\DoomLampPostandGuardianRooms\DoomLeverPuzzle.cs:line 182
  at Server.Misc.LeverPuzzle.StandingPad.Lever.OnDoubleClick(Mobile from) in c:\Program Files\RunUO 2.0 SVN 132\Scripts\Custom Scripts 2.0\DoomLampPostandGuardianRooms\DoomLeverPuzzle.cs:line 240
  at Server.Mobile.Use(Item item)
  at Server.Network.PacketHandlers.UseReq(NetState state, PacketReader pvSrc)
  at Server.Network.MessagePump.HandleReceive(NetState ns)
  at Server.Network.MessagePump.Slice()
  at Server.Core.Main(String[] args)

Clients:
- Count: 1
+ 1xx.xxx.x.x: (account = xxxx) (mobile = 0x1 'Laura Croft The Owner')

ArteGordon- 01-09-2007
try changing this

CODE

           if (Amount == 4)
           {
               Pads[4].MobileList[0].BoltEffect(0);
               TeleportTimer timer = new TeleportTimer(Pads[4].MobileList[0]);
               timer.Start();
           }


to this

CODE

           if (Amount == 4 && Pads[4].MobileList.Count > 0)
           {
               Pads[4].MobileList[0].BoltEffect(0);
               TeleportTimer timer = new TeleportTimer(Pads[4].MobileList[0]);
               timer.Start();
           }

Erica- 01-09-2007
Thank You ArteGordon That took care of the crash.