Anasayfa
UO Sunucular
Forumlar
Profilim
UO-Developer.COM
Lord Streamline 23-08-2009
using System;
using Server.Gumps;
using Server.Network;
using Server.Prompts;
using Server.Items;
using Server.Misc;


namespace Server.Items
{
public class NameChangeDeed : Item
{
[Constructable]
public NameChangeDeed() : base( 0x14F0 )
{
base.Weight = 1.0;
base.Name = "a name change deed";
}

public NameChangeDeed( Serial serial ) : base( serial )
{
}

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();
}

public override void OnDoubleClick( Mobile from )
{
// Do namechange
from.SendGump(new ChangeNameGump(from,this));
}
}
}



namespace Server.Gumps
{
public class ChangeNameGump : Gump
{
NameChangeDeed oDeed;

public ChangeNameGump(Mobile owner, NameChangeDeed deed):base(50,50)
{
string PromptMessage;

if (owner.Language == "CHT")
{
PromptMessage = "·s¦W¦r:";
}
else
{
PromptMessage = "Yeni Isim: ";
}

oDeed = deed;

AddPage(0);
AddBackground(  0,  0,300, 70,5054);
AddBackground( 65, 10,225, 25,3000);

AddLabel(  10,  10, 0x34, PromptMessage);
AddTextEntry( 71, 11, 223, 23, 0, 0, owner.Name);

AddButton(110, 40, 0xFB7, 0xFB8, 1, GumpButtonType.Reply, 0);
AddButton(160, 40, 0xFB1, 0xFB2, 0, GumpButtonType.Reply, 0);

}

public override void OnResponse(NetState state, RelayInfo info)
{
Mobile oMobile = (Mobile) state.Mobile;
int MinimumLength = 1;
int MaximumLength = 15;
bool AllowDigits = true;
string ErrorMessage;
string FinishedMessage;

// char[] Exception = NameVerfication.SpaceDashPeriodQuote; // If you don't allow some char in name, ummark this line and mark the following line.
char[] Exceptions = NameVerification.Empty;

if (oMobile.Language == "CHT")
{
ErrorMessage = "¿ù»~ ! ¦WºÙ¤£±oµu©ó " + MinimumLength.ToString() + " ¦r¤¸¤]¤£¯àªø©ó " + MaximumLength.ToString() + " ¦r¤¸";
if (!AllowDigits)
ErrorMessage = ErrorMessage + ", ¦WºÙ¤£±o¥]§t¼Æ¦r.";

FinishedMessage = "¦WºÙÅܧó¤w§¹¦¨ !";
}
else
{
ErrorMessage = "Error ! Length of name should between " + MinimumLength.ToString() + " to " + MaximumLength.ToString() + " byes long.";
if (!AllowDigits)
ErrorMessage = ErrorMessage + " Name can't include digits.";

FinishedMessage = "Yeni Isminiz Değiştirilmiştir. ";
}

if (info.ButtonID > 0)
{
TextRelay text = info.GetTextEntry(0);
if ((text != null) && (text.Text != oMobile.Name))
{
if (NameVerification.Validate(text.Text.Trim(), MinimumLength, MaximumLength, true, AllowDigits, true, 0, Exceptions ))
{
oMobile.Name = text.Text.Trim();

if (oDeed != null) // Should not null, but, still do the dumb check for safe reason.
oDeed.Delete();

oMobile.SendMessage(0xff, FinishedMessage);
}
else
{
oMobile.SendMessage(0xff, ErrorMessage);
}
}
}
}

}
}

UO-Dev SPONSOR

Paylaş

XFacebook

Faydalı mı?

Bu içerik size yardımcı oldu mu?

UO-Dev SPONSOR

Henüz yorum yapılmamış. Yorum yazabilmek için giriş yapmanız gerekir.

Üyelerin oylama ortalaması (10 dışında) :

Henüz Oylanmamış

Oylar: 0

Paylaş

XFacebook

Faydalı mı?

Bu içerik size yardımcı oldu mu?