- Kumbara Sistemi
Zamanında yazdıgım bir script. Uzun zaman C# a ara verdikten sonra tekrar yazdığımdan dolayı bazı hataları olabilir. Ancak hatırladıgım kadarıyla Debug modda hiçbir kritik bugı yoktu. Eğer bir hataya rastlarsanız buradan hataları düzeltebiliriz.
Güle Güle kullanın.
/*
Scripted By Lord Nyctinus
20 Şubat 2008 Çarşamba
Hatalarimizi Iletin ([email protected])
*/
using System;
using Server;
using Server.Network;
using Server.Targeting;
using Server.Mobiles;
using Server.Items;
using Server.Gumps;
namespace Server.Items
{
public class Kumbara : Item
{
private int i_Owner, i_Gold;
[CommandProperty(AccessLevel.Administrator)]
public int Owner { get { return i_Owner; } set { i_Owner = value; InvalidateProperties(); } }
[CommandProperty(AccessLevel.Administrator)]
public int Gold { get { return i_Gold; } set { i_Gold = value; InvalidateProperties(); } }
[Constructable]
public Kumbara() : base( 2474 )
{
Stackable = false;
Name = "Yeni Kumbara";
Hue = 2217;
Weight = 1.0;
LootType = LootType.Blessed;
}
public override void OnDoubleClick(Mobile from)
{
if ( this.IsChildOf( from.Backpack ) )
{
if (i_Owner == 0)
{
i_Owner = from.Serial;
Name = from.Name + " Adli Kisinin Kumbarasi";
i_Gold = 0;
from.SendGump( new KumbaraGump( from, this ) );
}
else if (from.Serial == i_Owner)
{
from.SendGump( new KumbaraGump( from, this ) );
}
else if (from.AccessLevel >= AccessLevel.GameMaster)
{
from.SendMessage(1174, "Kumbaranin Yeni Sahibini Secin!");
BeginSetOwner( from );
}
else
{
from.PlaySound(1074); //play no!! sound
from.SendMessage(1174, "???");
}
}
else
from.SendMessage(1174, "Cantanizda Olmali");
}
public void BeginSetOwner( Mobile from )
{
from.Target = new SetOwnerTarget( this );
}
public class SetOwnerTarget : Target
{
private Kumbara m_TL;
public SetOwnerTarget( Kumbara tl ) : base( 18, false, TargetFlags.None )
{
m_TL = tl;
}
protected override void OnTarget( Mobile from, object targeted )
{
if ( m_TL.Deleted )
return;
m_TL.EndSetOwner( from, targeted );
}
}
public void EndSetOwner( Mobile from, object obj )
{
if ( obj is PlayerMobile )
{
PlayerMobile m = obj as PlayerMobile;
if ( m.Alive )
{
if (!(this.Deleted))
{
if (m.Name != null)
{
this.Owner = m.Serial;
this.Name = m.Name + " Adli Kisinin Kumbarasi";
from.SendMessage(1174, "Kumbaranin Yeni Sahibi {0}", m.Name);
m.SendMessage(1174, "Yeni Kumbaraniz Hayirli Olsun");
}
else
from.SendMessage(1174, "Bu Sizin Degil");
}
else
from.SendMessage(1174, "Secicek Bi Kumbara Yok!");
}
else
from.SendMessage(1174, "Oluken Kumbarayi Acamazsiniz");
}
else
from.SendMessage(1174, "Sadece Insanlar Kutu Sahibi Olabilir");
}
public void BeginAddGold( Mobile from )
{
from.Target = new AddGoldTarget( this );
}
public class AddGoldTarget : Target
{
private Kumbara m_TL;
public AddGoldTarget( Kumbara tl ) : base( 18, false, TargetFlags.None )
{
m_TL = tl;
}
protected override void OnTarget( Mobile from, object targeted )
{
if ( m_TL.Deleted )
return;
m_TL.EndAddGold( from, targeted );
}
}
public void EndAddGold( Mobile from, object obj )
{
from.CloseGump( typeof( KumbaraGump ) );
if ( obj is Item )
{
Item oldGold = obj as Item;
if ( oldGold.IsChildOf( from.Backpack ) )
{
if (oldGold.Name != null && oldGold.Stackable == true && oldGold.Amount > 0)
{
if ((oldGold.Name).ToLower().IndexOf("gold") != -1)
{
if (!(this.Deleted) && !(oldGold.Deleted))
{
this.Gold = (this.Gold + oldGold.Amount);
from.SendMessage(1174, "Kumbaraniza {0} Kadar Para Aktardiniz", oldGold.Amount);
oldGold.Delete();
}
else
{
from.PlaySound(1069); //play Hey!! sound
from.SendMessage(1174, "Hey, don't try to rob the bank!!!");
}
}
else
{
from.PlaySound(1074); //play no!! sound
from.SendMessage(1174, "Bu Parami? Kalpazanciligami Basladin?!");
}
}
else
this.Gold = (this.Gold + oldGold.Amount);
from.SendMessage(1174, "Kumbaraniza {0} Kadar Para Aktardiniz", oldGold.Amount);
oldGold.Delete();
}
else
from.SendMessage(1174, "Bu Sizin Cantanizda Degil!");
}
else
from.SendMessage(1174, "Bu Bir Esya Degil");
from.SendGump( new KumbaraGump( from, this ) );
}
public Kumbara( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 ); // version
writer.Write( i_Gold );
writer.Write( i_Owner );
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
switch (version)
{
case 0:
{
i_Gold = reader.ReadInt();
i_Owner = reader.ReadInt();
break;
}
}
}
}
}
namespace Server.Gumps
{
public class KumbaraGump : Gump
{
private Mobile m_From;
private Kumbara m_TL;
public KumbaraGump( Mobile from, Item item )
: base( 0, 0 )
{
from.CloseGump( typeof( KumbaraGump ) );
m_From = from;
if (!(item is Kumbara))
return;
Kumbara tl = item as Kumbara;
m_TL = tl;
this.Closable=true;
this.Disposable=true;
this.Dragable=true;
this.Resizable=false;
this.AddPage(0);
this.AddBackground(56, 45, 286, 228, 9270);
this.AddImage(71, 60, 4037);
this.AddImage(291, 60, 4037);
this.AddLabel(145, 74, 37, @"Kumbara Sistemi");
this.AddButton(70, 111, 2224, 2224, (int)Buttons.cikis1, GumpButtonType.Reply, 0);
this.AddLabel(91, 107, 1, @"Menuyu Kapat");
this.AddButton(70, 137, 2224, 2224, (int)Buttons.parayatir2, GumpButtonType.Reply, 0);
this.AddLabel(93, 134, 1, @"Para Yatir");
this.AddButton(70, 163, 2224, 2224, (int)Buttons.paracek, GumpButtonType.Reply, 0);
this.AddLabel(93, 159, 1, @"Para Cek");
this.AddLabel(93, 184, 1, @"Miktar:");
this.AddImage(265, 123, 9807);
this.AddImage(108, 216, 1122);
this.AddTextEntry(107, 217, 185, 14, 0, (int)Buttons.TextEntry1,@"" + ((Kumbara)tl).Gold + " ");
this.AddImage(70, 187, 2224);
this.AddLabel(95, 243, 37, "Su Anda " + ((Kumbara)tl).Gold + " Kadar Altininiz Var");
}
public enum Buttons
{
cikis1,
parayatir2,
paracek,
TextEntry1,
}
public override void OnResponse( NetState state, RelayInfo info )
{
switch (info.ButtonID)
{
case 0:
{
//Bu Iptal Eder
break;
}
case 1:
{
if ( m_TL.Deleted )
return;
else if ( info.ButtonID == 1 )
{
if (((Kumbara)m_TL).Gold <= 2000000000)
m_TL.BeginAddGold( m_From );
else
m_From.SendMessage(1174, "Kumbara Dolmus");
m_From.SendGump( new KumbaraGump( m_From, m_TL ) );
}
break;
}
case 2:
{
{
TextRelay tr_GoldAmount = info.GetTextEntry( 3 );
if(tr_GoldAmount != null)
{
int i_MaxAmount = 0;
try
{
i_MaxAmount = Convert.ToInt32(tr_GoldAmount.Text,10);
}
catch
{
m_From.SendMessage(1174, "Gecerli Bi Sayi Girin Lutfen");
}
if(i_MaxAmount > 0)
{
if (i_MaxAmount <= ((Kumbara)m_TL).Gold)
{
if (info.ButtonID == 4 )
{
if (i_MaxAmount <= 60000)
{
m_From.AddToBackpack(new Gold(i_MaxAmount));
m_From.SendMessage(1174, "Kumbaranizdan {0} Altin Cektiniz", i_MaxAmount);
((Kumbara)m_TL).Gold = (((Kumbara)m_TL).Gold - i_MaxAmount);
}
else
m_From.SendMessage(1174, "???");
}
else if (i_MaxAmount >= 1000)
{
m_From.AddToBackpack(new BankCheck(i_MaxAmount));
m_From.SendMessage(1174, "Cek Yaptiniz Miktari {0} Altin.", i_MaxAmount);
((Kumbara)m_TL).Gold = (((Kumbara)m_TL).Gold - i_MaxAmount);
}
else
m_From.SendMessage(1174, "1000 Altindan Kucuk Rakamlarda Cek Yapamazsiniz");
}
else
m_From.SendMessage(1174, "Kumbaranizda Para Yok!");
}
m_From.SendGump( new KumbaraGump( m_From, m_TL ) );
}
}
break;
}
}
}
}
}