Full Version : book
xmlspawner >>Scripting Support >>book
<< Prev | Next >>
darkwinters- 02-20-2006
this is my punishment book.its making players to click it about 200 times and then set their squelch and frozen false
but i give this book to them when they are squelched but in the script there is a random say section which enables them to auto type *i am very sory for my mistake* and cause of they are squelch its not appearing.how can i make it to say when they are still in squelch and i want the book to be destroyed when the m_clicks finished can anyone help me?

CODE
using System; using Server; using Server.Mobiles; using Server.Items; using Server.Gumps;
using Server.Network;
namespace Server.Items
{
[Flipable( 0xFBE, 0xFBD )]
public class JailBook : Item
{
public int m_Clicks;
public Map m_MapDest;
public Point3D m_PointDest;
[CommandProperty( AccessLevel.GameMaster )]
public int Clicks
{
get{ return m_Clicks; }
set{ m_Clicks = value; InvalidateProperties();}
}
[CommandProperty( AccessLevel.GameMaster )]
public Point3D PointDest
{
get { return m_PointDest; }
set { m_PointDest = value; InvalidateProperties(); }
}
[CommandProperty( AccessLevel.GameMaster )]
public Map MapDest
{
get { return m_MapDest; }
set { m_MapDest = value; InvalidateProperties(); }
}
[Constructable]
public JailBook() : base( 0xFBE )
{
m_Clicks = 200;
Movable = false;
Name = "ceza kitabı";
}
public override void OnDoubleClick( Mobile from )
{
if ( !from.InRange( GetWorldLocation(), 1 ) )
from.SendLocalizedMessage( 500446 ); // That is too far away.
else if (m_Clicks == 1)
{
m_Clicks = 200;
from.SendMessage("you are free now!");
from.Frozen = false;
from.Squelched = false;
}
else
{
if (Utility.Random(9) == 1)
from.Say("*i am very sorry for my mistake*");
from.SendGump(new JailGump(from, m_Clicks));
if (JailGump.pressed == true)
{
m_Clicks = m_Clicks - 1;
JailGump.pressed = false;
}
}
}
public JailBook( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 ); // version
writer.Write( (int) m_Clicks );
writer.Write( m_PointDest );
writer.Write( m_MapDest );
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
m_Clicks = reader.ReadInt();
m_PointDest = reader.ReadPoint3D();
m_MapDest = reader.ReadMap();
}
public class JailGump : Gump
{
private Mobile m_Owner;
private int m_Clicksleft;
public static bool pressed = true;
public Mobile Owner{ get{ return m_Owner; } set{ m_Owner = value; } }
public JailGump(Mobile owner, int clicksleft) : base( 10, 0 )
{
owner.CloseGump( typeof( JailGump ) );
int gumpX = 0; int gumpY = 0;
m_Clicksleft = clicksleft - 1;
m_Owner = owner;
int x = Utility.Random(120);
int y = Utility.Random(100);
Closable = false;
Disposable = false;
Dragable = false;
Resizable = false;
AddPage( 0 );
gumpX = 204 + x; gumpY = 52 + y;
AddBackground( gumpX, gumpY, 190, 267, 0x53 );
gumpX = 211 + x; gumpY = 183 + y;
AddImage( gumpX, gumpY, 0x2426 );
gumpX = 260 + x; gumpY = 183 + y;
AddImage( gumpX, gumpY, 0x2426 );
gumpX = 210 + x; gumpY = 108 + y;
AddHtml( gumpX, gumpY, 179, 175, "<center>*Ceza Aldınız!*</center>\nGenel Ahlak Kurallarını çiğnediniz.\n\nCezanızı bitirmeniz için bu kitabı " + m_Clicksleft + " defa okumanız gereklidir.", true, false );
if (Utility.Random(2) == 1)
{
gumpX = 267 + x; gumpY = 287 + y;
AddButton( gumpX, gumpY, 0xF7, 0xF8, 1, GumpButtonType.Reply, 0 );
}
else
{
gumpX = 285 + x; gumpY = 287 + y;
AddButton( gumpX, gumpY, 0xFB7, 0xFB9, 1, GumpButtonType.Reply, 0 );
}
gumpX = 210 + x; gumpY = 60 + y;
AddImage( gumpX, gumpY, 0x28D4 );
}
public override void OnResponse( NetState state, RelayInfo info )
{
Mobile from = state.Mobile;
switch( info.ButtonID )
{
case 1:
{
pressed = true;
break;
}
}
}
}
}
}

darkwinters- 02-20-2006
and for the say think i know i can do this with PublicOverheadMessage but i dont know how to use it so here is the clear list of what i want
1-using PublicOverheadMessage in the "im sorry for my mistakes" part
2-destroy (auto delete) the book when the m_click amount finished
Dian- 02-20-2006
well.. in the OnDoubleClick method, just add them in?

CODE
else if (m_Clicks == 1) { m_Clicks = 200; from.SendMessage("you are free now!"); from.Frozen = false;
from.Squelched = false;
this.Delete();
}
else
{
if (Utility.Random(9) == 1)
PublicOverheadMessage( MessageType.Regular, 0x3B2, false,"Im am sorry for my mistake." );
from.SendGump(new JailGump(from, m_Clicks));
if (JailGump.pressed == true)
{

darkwinters- 02-20-2006

CODE
PublicOverheadMessage( MessageType.Regular, 0x3B2, false,"Im am sorry for my mistake." );

shouldnt it be

CODE
from.PublicOverheadMessage( MessageType.Regular, 0x3B2, false,"Im am sorry for my mistake." );

or am i wrong?
Dian- 02-20-2006
oop.. sorry, yeah. was rushing from somthing happening afk..
remove the from. on PublicOverheadMessage.. and it should have the message over the book itself.
darkwinters- 02-20-2006
i make it

CODE
from.PublicOverheadMessage( MessageType.Regular, 0x3B2, false,"Im am sorry for my mistake." );

but the message is not showing up its not working
edit:oh ok its working.