This seems to do what it is suppose to do. The problem is when an NPC steps on the teleporter it crashes the server:

Unable to cast object of type 'Server.Mobiles.TavernKeeper' to type 'Server.Mobiles.PlayerMobile'.
at Server.Items.ThievesGuildTeleporter.OnMoveOver(Mobile m)
any suggestions?

Code:
using System;
using System.Collections;
using System.Collections.Generic;
using Server;
using Server.Gumps;
using Server.Misc;
using Server.Mobiles;
using Server.Network;
using Server.SkillHandlers;
using Server.Mobiles;
using Server.Guilds;
namespace Server.Items
{
public class ThievesGuildTeleporter : Teleporter
{
[Constructable]
public ThievesGuildTeleporter()
{
}
public ThievesGuildTeleporter(Serial serial)
: base(serial)
{
}
public override bool OnMoveOver(Mobile m)
{
PlayerMobile player = (PlayerMobile)m;
if (!m.Player)
{
return false;
}
if (m is PlayerMobile && ((PlayerMobile)m).NpcGuild == NpcGuild.ThievesGuild)
return base.OnMoveOver(m);
if (Stealing.SuspendOnMurder && m.Kills > 0)
{
// You are currently suspended from the thieves guild. They would frown upon your actions.
m.SendLocalizedMessage(501703);
return false;
}
else
{
m.SendMessage("Only active members of the Thieves Guild may enter.");
return false;
}
}
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();
}
}
}
 
You cannot cast the npc to a playermobile so you will have to add a check to see if the mobile is a playermobile or not.

Before PlayerMobile player =(PlayerMobile)m; add this

Code:
if (!(m is PlayerMobile))
{
	return false
}

There is other things you can do to clean up that code but I will leave that to you.

//Edit actually just move the cast to below the m.Player check.
 
Last edited:
Back