Full Version : a bug with my script
xmlspawner >>Scripting Support >>a bug with my script
<< Prev | Next >>
ambak- 01-26-2006
this is my send script.i use this to easily send players to a specific area like luna bank brit bank doom gaunlet.it works fine.but i found a bug in it today
the bug is when my counselors use it and target themselves.it teleports them too ok this is no problem but when it teleports them their immortal be mortal
how can i fix that?
here is the script

CODE
using System; using System.Collections; using Server; using Server.Items; using Server.Mobiles;
using Server.Targeting;
using Server.Gumps;
using Server.Network;
namespace Server.AdminCommands
{
public class AdminCommand
{
public static void Initialize()
{
Server.Commands.Register( "Send", AccessLevel.Counselor, new CommandEventHandler( SendCommand ) );
}
[Usage( "SendTo" )]
public static void SendCommand( CommandEventArgs e )
{
Mobile from = e.Mobile;
from.Target = new SendToTarget();
from.SendMessage(1150,"Gönderilecek kişiyi seçin...");
}
public class SendToGump : Gump
{
private Mobile giden;
public SendToGump( Mobile from ) : base( 50, 50 )
{
giden = from;
Closable=true;
Disposable=true;
Dragable=true;
Resizable=false;
AddPage(0);
AddBackground(50, 50, 238, 310, 5150);
AddImage(199, 84, 5548);
AddLabel(117, 102, 1160, @"Send");
AddButton(83, 156, 4005, 4007, 1, GumpButtonType.Reply, 0);
AddLabel(123, 158, 0, @"Britain Otel");
AddButton(83, 180, 4005, 4007, 2, GumpButtonType.Reply, 0);
AddLabel(123, 181, 0, @"Britain Bank");
AddButton(83, 204, 4005, 4007, 3, GumpButtonType.Reply, 0);
AddLabel(123, 204, 0, @"Minoc Bank");
AddButton(83, 228, 4005, 4007, 4, GumpButtonType.Reply, 0);
AddLabel(123, 229, 0, @"Luna Bank");
AddButton(83, 252, 4005, 4007, 5, GumpButtonType.Reply, 0);
AddLabel(123, 253, 0, @"Bucs Bank");
AddButton(83, 276, 4005, 4007, 6, GumpButtonType.Reply, 0);
AddLabel(123, 277, 0, @"Dark Father");
AddButton(83, 300, 4005, 4007, 7, GumpButtonType.Reply, 0);
AddLabel(123, 301, 0, @"Jail");
}
public override void OnResponse( NetState state, RelayInfo info )
{
Mobile from = state.Mobile;
if ( info.ButtonID == 0)
return;
giden.Frozen = false;
giden.CantWalk = false;
giden.Blessed = false;
if ( info.ButtonID == 1)
giden.MoveToWorld( new Point3D( 1496, 1628, 10 ), Map.Felucca );
if ( info.ButtonID == 2)
giden.MoveToWorld( new Point3D( 1430, 1700, 2 ), Map.Felucca );
if ( info.ButtonID == 3)
giden.MoveToWorld( new Point3D( 2526, 583, 0 ), Map.Felucca );
if ( info.ButtonID == 4)
giden.MoveToWorld( new Point3D( 991, 519, -50 ), Map.Malas );
if ( info.ButtonID == 5)
giden.MoveToWorld( new Point3D( 2736, 2166, 0 ), Map.Felucca );
if ( info.ButtonID == 6)
giden.MoveToWorld( new Point3D( 433, 334, -2 ), Map.Malas );
if ( info.ButtonID == 7)
giden.MoveToWorld( new Point3D( 5275, 1163, 0 ), Map.Felucca );
}
}
public class SendToTarget : Target
{
public SendToTarget() : base( -1, true, TargetFlags.None )
{
}
protected override void OnTarget( Mobile from, object o )
{
if (o is PlayerMobile)
{
Mobile pm_from = (Mobile)o;
from.CloseGump(typeof(SendToGump));
from.SendGump(new SendToGump(pm_from));
from.SendMessage(1150, "Bu player'ın gönderileceği yeri seçin...");
}
}
}
}
}

ambak- 01-26-2006
if i remove giden.Blessed = false;
is it ok?
DrussRob- 01-26-2006
Yes. Or change to:
giden.Blessed = true;
ambak- 01-26-2006
ok i corrected this little mistake
by the way you can feel free to use it this is my first submission
DrussRob- 01-26-2006
This is a good example for people on how to add functionality to a simple gump. good work