sahisahi
Member
I tried to add a backpack check to my moongate script
and server throw an out of range exception, whenever a summoned creature tried to enter the gate i understand the error
i want player to prevent use moongate if they are carrying a certain item, can anyone help me?
Exception:
System.InvalidCastException: Unable to cast object of type 'Server.Mobiles.SummonedDaemon' to type 'Server.Mobiles.PlayerMobile'.
at Server.Items.Moongate.UseGate(Mobile m) in c:\Users\\Items\Skill Items\Magical\Misc\Moongate.cs:line 175
at Server.Items.Moongate.EndConfirmation(Mobile from) in c:\Users\\Scripts\Items\Skill Items\Magical\Misc\Moongate.cs:line 298
at Server.Items.Moongate.DelayTimer.OnTick() in c:\Users\\Scripts\Items\Skill Items\Magical\Misc\Moongate.cs:line 337
at Server.Timer.Slice()
at Server.Core.Main(String[] args)
So i added a playermobile checking and now moongates DONT work
thanks!
and server throw an out of range exception, whenever a summoned creature tried to enter the gate i understand the error
i want player to prevent use moongate if they are carrying a certain item, can anyone help me?
Exception:
System.InvalidCastException: Unable to cast object of type 'Server.Mobiles.SummonedDaemon' to type 'Server.Mobiles.PlayerMobile'.
at Server.Items.Moongate.UseGate(Mobile m) in c:\Users\\Items\Skill Items\Magical\Misc\Moongate.cs:line 175
at Server.Items.Moongate.EndConfirmation(Mobile from) in c:\Users\\Scripts\Items\Skill Items\Magical\Misc\Moongate.cs:line 298
at Server.Items.Moongate.DelayTimer.OnTick() in c:\Users\\Scripts\Items\Skill Items\Magical\Misc\Moongate.cs:line 337
at Server.Timer.Slice()
at Server.Core.Main(String[] args)
So i added a playermobile checking and now moongates DONT work
thanks!
Code:
public virtual void UseGate( Mobile m )
{
ClientFlags flags = m.NetState == null ? ClientFlags.None : m.NetState.Flags;
bool hasstonewall = false;
bool hasgate = false;
Item paralyzeField = null;
IPooledEnumerable eable;
if (m_TargetMap != null)
{
eable = m_TargetMap.GetItemsInRange(m_Target, 0);
foreach (Item i in eable)
{
if (i.ItemID == 0x80) //Stonewall
hasstonewall = true;
if (i.ItemID == 0xF6C) //Gate
hasgate = true;
if (i.ItemID >= 14695 && i.ItemID <= 14730) //Paralyze field
paralyzeField = i;
}
eable.Free();
}
if ( Sigil.ExistsOn( m ) )
{
m.SendLocalizedMessage( 1061632 ); // You can't do that while carrying the sigil.
}
if (m is PlayerMobile) / ///my edit after the out of range exception error
{
PlayerMobile mobile = (PlayerMobile)m;
Container pack = m.Backpack;
Item am = m.Backpack.FindItemByType(typeof(myitem));
if (am != null)
{
m.LocalOverheadMessage(MessageType.Regular, 906, true, "You cannot enter while carrying that item!");
}
} ///my edit after the out of range exception error
else if ( m_TargetMap != null && m_TargetMap != Map.Internal)
{
if ( (hasgate || !Dispellable) && !hasstonewall )
{
BaseCreature.TeleportPets(m, m_Target, m_TargetMap);
m.MoveToWorld(m_Target, m_TargetMap);
if (m.AccessLevel == AccessLevel.Player || !m.Hidden)
{
//Iza - Teleport Poof
Effects.SendLocationParticles(EffectItem.Create(m.Location, m.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 2023);
Effects.SendLocationParticles(EffectItem.Create(m_Target, m.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 5023);
m.PlaySound(0x1FE);
}
if (paralyzeField != null)
paralyzeField.OnMoveOver(m); //Paralyze player if paralyze field exist
OnGateUsed(m);
}
else
m.SendAsciiMessage("You cannot teleport to that location.");
}
else
{
m.SendMessage( "This moongate does not seem to go anywhere." );
}
}