Full Version : Server crashing
xmlspawner >>Troubleshooting >>Server crashing


<< Prev | Next >>

Grimhawk- 01-19-2006
Was testing the quest samples on my test shard which is a dupe of the main and keep crashing. Its happening when I go up to or try to talk to the quest npc.
Heres a copy on my crash log.


CODE

Exception:
System.InvalidCastException: Specified cast is not valid.
  at Server.Mobiles.ArcMobile.EventSink_RPAppReq(SpeechEventArgs e)
  at Server.SpeechEventHandler.Invoke(SpeechEventArgs e)
  at Server.Mobile.DoSpeech(String text, Int32[] keywords, MessageType type, Int32 hue)
  at Server.Engines.XmlSpawner2.XmlDialog.DelayedSpeech(Object state)
  at Server.DelayStateCallTimer.OnTick()
  at Server.Timer.Slice()
  at Server.Core.Main(String[] args)


Hope you can help. Your system is great and want to use it for quests and other stuff but not a great scripter.

Thanks for any help.
Grim

godfood- 01-19-2006
Which Sample Quest are you trying to use? Is your shard "Stock" Or do you have lot's of custom script's?

ArteGordon- 01-19-2006
QUOTE

Server.Mobiles.ArcMobile.EventSink_RPAppReq(SpeechEventArgs e)


The issue is that you have a script that is assuming that when it receives speech that it is coming from a player and it is incorrectly casting its mobile argument to a playermobile without first checking.

The npcs in the xmlspawner system are able to generate actual speech which allows them to interact with each other the way that players do. Your ArcMobile script is being fooled by this.

If you post your ArcMobile script I can show you how to fix it.

Grimhawk- 01-19-2006
Thanks for the quick reply. The sample quest was the whosonfirst and the quest Arte put in for the quest contest. Below is my arcmobile.cs



Thanks again for the quick reply you two.

ArteGordon- 01-19-2006
CODE

 private static void EventSink_RPAppReq( SpeechEventArgs e )
{
 if ( ( (ArcMobile)e.Mobile ).RolePlayer == RPStatus.RolePlayer )
  return;

 if ( e.Speech.ToLower() == "i wish to become a role player" )
  e.Mobile.SendGump( new PlayerRPAppGump() );
}

private static void EventSink_GoBack( SpeechEventArgs e )
{
 ArcMobile from = (ArcMobile)e.Mobile;

 if ( e.Speech.ToLower() != "nos terasi" )
  return;
 else if ( from.Region is Regions.Jail )
  from.SendMessage( 38, "You cannot use this in jail." );
 else if ( from.Alive && from.Mana < from.ManaMax )
  from.SendMessage( 38, "Your magical force has to be at 100%." );
 else if ( from.GetRaceGroup() == RaceGroup.None )
  from.SendMessage( 38, "You do not belong to any race yet." );
 else
 {
  from.SendMessage( 6, "You begin casting..." );
  from.Frozen = true;
  from.Animate( 32, 7, 3, true, false, 0 );
  Timer.DelayCall( TimeSpan.FromSeconds( 10.0 ), new TimerStateCallback(
SendHome ), from );
 }
}

The problem is that you automatically assume that the e.Mobile args to these speech handlers are ArcMobiles and do a cast which causes the crash.
You need to add a check for this, like

QUOTE

private static void EventSink_GoBack( SpeechEventArgs e )
{
if(!(e.Mobile is ArcMobile)) return;

  ArcMobile from = (ArcMobile)e.Mobile;


and

QUOTE

  private static void EventSink_RPAppReq( SpeechEventArgs e )
{
  if ( !(e.Mobile is ArcMobile) || ( (ArcMobile)e.Mobile ).RolePlayer == RPStatus.RolePlayer )
  return;

godfood- 01-19-2006
QUOTE
Hobbits,
Viking,
DruidCelts,
Barbarians,
Behtler,
MixedHuman,
Vampire,
Zombies,
// Dwarves
SandDwarf,
Gnome,
StoneDwarf,
DarkDwarf,
MixedDwarfs,
// Elfs
WoodElf,
FrostElf,
HighElf,
Drow,
Sprite,
MixedElf,
// Mag creat
Wizard,
Sorceress,
Warlock,
Witch,
Lasher,
Enchantress,
Satyr,
Nymph,
// Beasts
Orc,
Daemon,
Savages,
Gargoyles


blink.gif Thas a lotta races. ohmy.gif

Grimhawk- 01-19-2006
Thanks Arte will do the checks and see if that fixes it and will let you know.

Hehe yeah godfood it is though have noticed the players like variety even if some aren't what you could call races.

Thanks again.

godfood- 01-19-2006
BTW Grimhawk, You may want to consider removing you ArcMobile from your post if you don't want other people grabbing it and using for themselves. I can do this for you if you're not sure how. smile.gif

Grimhawk- 01-19-2006
Thanks a bunch Arte that seems to of fixed it so far no other issues yet.

Now I can practice and try to make some quests of my own.Hoping to get good enough to do some will take atleast a few weeks to finish.

Thanks again.
Grim