Full Version : server crashed
xmlspawner >>Scripting Support >>server crashed
<< Prev | Next >>
darkwinters- 02-04-2006
Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
at Server.Gumps.AccountInfo.OnResponse(NetState sender, RelayInfo info)
at Server.Network.PacketHandlers.DisplayGumpResponse(NetState state, PacketReader pvSrc)
at Server.Network.MessagePump.HandleReceive(NetState ns)
at Server.Network.MessagePump.Slice()
at Server.Core.Main(String[] args)
darkwinters- 02-04-2006
here is the accounfinfogump.cs

CODE
///************************************************///*********************/// /// Script: Account Info Gump /// ,dP""dMb, /// /// Version: 1.0 /// d" dMP"Tb /// /// Designed by: Packer898 /// (M YMbodM) /// /// Date: 11-13-05 /// `M, o )MMMP ///
/// Please do NOT remove this header. /// "b,,aMMP" ///
///************************************************************************///
/// Intallation: Place into your Custom directory and restart the server. ///
///************************************************************************///
/// Files Needed: ///
/// AccountInfoGump.cs ///
/// AccountMainGump.cs ///
/// PasswordMenuGump.cs ///
///**********************///
using System;
using Server;
using System.IO;
using Server.Gumps;
using Server.Accounting;
using System.Collections;
namespace Server.Gumps
{
public class AccountInfo : Gump
{
public enum Buttons
{
txt_Realname,
txt_Birthdate,
txt_Email1,
txt_Email2,
txt_Magicword,
txt_Magicwordhint,
btn_Okay,
btn_Cancel,
}
public const string adminemail = @"eurydice@carpediem.gen.tr";//Enter administrators email here
private const string apppath = @"Data/AccountInfo/";//Enter datapath for saved text file here
private string realname = null;
private string birthdate = null;
private string email1 = null;
private string email2 = null;
private string magicword = null;
private string magicwordhint = null;
public AccountInfo() : this( null )
{
}
public AccountInfo(ArrayList args) : base( 0, 0 )
{
if( args != null )
{
realname = args[0].ToString();
birthdate = args[1].ToString();
email1 = args[2].ToString();
email2 = args[3].ToString();
magicword = args[4].ToString();
magicwordhint = args[5].ToString();
}
Closable=false;
Disposable=true;
Dragable=true;
Resizable=false;
AddPage(0);
AddBackground(188, 151, 440, 290, 9200);
AddImage(595, 92, 10441);//Dragon
AddImage(138, 92, 10440);//Dragon
AddHtml(189, 152, 439, 289,@"<center>"+Server.Misc.ServerList.ServerName+" Hesap Güvenligi</center>", (bool)false, (bool)false);
AddLabel(332, 411, 0, @"Carpe Diem UO");
AddAlphaRegion(328, 205, 261, 20);//Full Name Alpha
AddAlphaRegion(328, 235, 261, 20);//Birthdate Alpha
AddAlphaRegion(328, 265, 261, 20);//Email 1 Alpha
AddAlphaRegion(328, 295, 261, 20);//Email 2 Alpha
AddAlphaRegion(328, 325, 261, 20);//Magic Word Alpha
AddAlphaRegion(328, 355, 261, 20);//Magic Word Hint Alpha
AddButton(232, 410, 247, 248, (int)Buttons.btn_Okay, GumpButtonType.Reply, 0);//Okay
AddButton(515, 410, 241, 242, (int)Buttons.btn_Cancel, GumpButtonType.Reply, 0);//Cancel
AddLabel(253, 206, 0, @"Isim Soyisim:");
AddTextEntry(329, 205, 261, 20, 0, (int)Buttons.txt_Realname, realname);
AddLabel(249, 236, 0, @"Dogum Tarihi:");
AddTextEntry(329, 235, 261, 20, 0, (int)Buttons.txt_Birthdate, birthdate);
AddLabel(224, 266, 0, @"Email Adresi:");
AddTextEntry(329, 265, 261, 20, 0, (int)Buttons.txt_Email1, email1);
AddLabel(224, 296, 0, @"Tekrar Email:");
AddTextEntry(329, 295, 261, 20, 0, (int)Buttons.txt_Email2, email2);
AddLabel(237, 326, 0, @"Anahtar Kelime:");
AddTextEntry(329, 325, 261, 20, 0, (int)Buttons.txt_Magicword, magicword);
AddLabel(208, 356, 0, @"Kelime Ipucu:");
AddTextEntry(329, 355, 261, 20, 0, (int)Buttons.txt_Magicwordhint, magicwordhint);
}
public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
{
Mobile from = sender.Mobile;
ArrayList textentries = new ArrayList();
realname = info.GetTextEntry((int)Buttons.txt_Realname).Text;
textentries.Add(realname);
birthdate = info.GetTextEntry((int)Buttons.txt_Birthdate).Text;
textentries.Add(birthdate);
email1 = info.GetTextEntry((int)Buttons.txt_Email1).Text;
textentries.Add(email1);
email2 = info.GetTextEntry((int)Buttons.txt_Email2).Text;
textentries.Add(email2);
magicword = info.GetTextEntry((int)Buttons.txt_Magicword).Text;
textentries.Add(magicword);
magicwordhint = info.GetTextEntry((int)Buttons.txt_Magicwordhint).Text;
textentries.Add(magicwordhint);
switch ( info.ButtonID )
{
case (int)Buttons.btn_Okay:
ParseResponses(from, textentries);
break;
case (int)Buttons.btn_Cancel:
from.CloseGump( typeof( AccountInfo ) );
from.Frozen = false;
from.Hidden = false;
from.Squelched = false;
break;
}
}
private void ParseResponses(Mobile from, ArrayList textentries)
{
bool completed = true;
if(email1.StartsWith(" ") || email1 == "" || email1.IndexOf("@") < 1 || email1.IndexOf(".") < 1 )
{
from.SendMessage("Ilk girdiginiz email adresi dogru degil");
completed = false;
from.SendGump( new AccountInfo());
}
if(email2.StartsWith(" ") || email2 == "" || email2.IndexOf("@") < 1 || email2.IndexOf(".") < 1 )
{
from.SendMessage("Ikinci girdiginiz email adresi dogru degil");
completed = false;
from.SendGump( new AccountInfo());
}
if ( email1 != email2 )
{
from.SendMessage("Email adresleri birbirini tutmuyor.");
completed = false;
from.SendGump( new AccountInfo());
}
if(realname.StartsWith(" ") || realname == "")
{
from.SendMessage("Gercek isminizi girmeniz gerekiyor.");
completed = false;
from.SendGump( new AccountInfo());
}
if(birthdate.StartsWith(" ") || birthdate == "")
{
from.SendMessage("Dogum tarihi girmeniz gerekiyor.");
completed = false;
from.SendGump( new AccountInfo());
}
if(magicword.StartsWith(" ") || magicword == "")
{
from.SendMessage("Lutfen anahtar bir kelime giriniz.Bu kelime sizin icin cok onlamli olsun.");
completed = false;
from.SendGump( new AccountInfo());
}
if(magicwordhint.StartsWith(" ") || magicwordhint == "")
{
from.SendMessage("Anahtar kelimeniz icin bir ipucu verin.");
completed = false;
from.SendGump( new AccountInfo());
}
if( !completed )
{
from.SendMessage("Lutfen tekrar deneyin. Unutmayin iki mailda ayni ve tum alanlar doldurulmus olmali.");
//from.SendGump( new AccountInfo());
}
else
{
from.SendMessage("Tebrikler, tum bilgileriniz tarafimiza ulasmistir.Iyi oyunlar dileriz");
SaveInfo(from); // Saves the information to a file.
from.CloseGump( typeof( AccountInfo ) );
from.Frozen = false;
from.Hidden = false;
from.Squelched = false;
Account a = (Account)from.Account;
a.SetTag("AccountInfo", "Complete");
}
}
private void SaveInfo( Mobile from )
{
Account a = (Account)from.Account;
string username = a.Username;
string filename = null;
char[] notsafe = new char[]
{
'~', '`', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '+', '=', ' ',
'{', '[', '}', ']', '|', '\\', ':', ';', '\"', '\'', '<', ',', '>', '.', '?', '/'
};
string[] usernamesplit = username.Split(notsafe);
for( int i = 0; i < usernamesplit.Length; ++i )
{
filename = filename + usernamesplit[i];
if(usernamesplit.Length > i + 1)
{
int j = Utility.Random(1, 2);
if( j == 1 )
filename = filename + "-";
else
filename = filename + "_";
}
}
string appfile = apppath + filename + ".txt";
if(!Directory.Exists(apppath))
Directory.CreateDirectory(apppath);
if(File.Exists(appfile))
{
File.Delete(appfile);
}
try
{
StreamWriter w = File.CreateText(appfile);
w.WriteLine("Account: " + username);
w.WriteLine("Created on: " + a.Created.ToShortDateString());
w.WriteLine("Real Name: " + realname );
w.WriteLine("Birthdate: " + birthdate );
w.WriteLine("Email: " + email1 );
w.WriteLine("Magic Word: " + magicword );
w.WriteLine("Magic Word Hint: " + magicwordhint );
w.Close();
Console.WriteLine("Hesap bilgisi kaydi yapildi: {0}", username);
}
catch(Exception e)
{
from.SendMessage(2, "there was an error processing your application, please Email {0} for instructions.", adminemail);
Console.WriteLine("Application file creation failure for account: {0}", username);
Console.WriteLine(e.Message);
}
}
}
}

please help
ArteGordon- 02-04-2006
when you do things like this

CODE
realname = info.GetTextEntry((int)Buttons.txt_Realname).Text; textentries.Add(realname);

it is possible for the results of
info.GetTextEntry((int)Buttons.txt_Realname).
to be null. You should do it like this instead.

CODE
TextRelay tr = info.GetTextEntry( (int)Buttons.txt_Realname); if(tr != null) { realname= tr.Text; textentries.Add(realname);
}
tr = info.GetTextEntry( (int)Buttons.txt_Birthdate);
if(tr != null)
{
birthdate = tr.Text;
textentries.Add(birthdate);
}

it is also a good idea to check on the validity of the mobile argument

QUOTE
public override void OnResponse(Server.Network.NetState sender, RelayInfo info) { Mobile from = sender.Mobile; if(from == null) return;

I dont know which of those problems is causing your crash, but I would guess that it is the nul text entry info.
darkwinters- 02-04-2006
ok i ll try them and here is the other file
accountmaingump.cs

CODE
///************************************************///*********************/// /// Script: Account Main Gump /// ,dP""dMb, /// /// Version: 1.0 /// d" dMP"Tb /// /// Designed by: Packer898 /// (M YMbodM) /// /// Date: 11-13-05 /// `M, o )MMMP ///
/// Please do NOT remove this header. /// "b,,aMMP" ///
///************************************************************************///
/// Intallation: Place into your Custom directory and restart the server. ///
///************************************************************************///
/// Files Needed: ///
/// AccountInfoGump.cs ///
/// AccountMainGump.cs ///
/// PasswordMenuGump.cs ///
///**********************///
using System;
using Server;
using System.IO;
using Server.Misc;
using Server.Gumps;
using Server.Items;
using Server.Mobiles;
using Server.Network;
using Server.Accounting;
using System.Collections;
using Server.Scripts.Commands;
namespace Server.Gumps
{
public class AccountMain : Gump
{
public static void Initialize()
{
EventSink.Login += new LoginEventHandler( AccountNew_OnCommand );
Server.Commands.Register( "AccountInfo", AccessLevel.Player, new CommandEventHandler( AccountInfo_OnCommand ) );
}
[Usage( "AccountInfo" )]
[Description( "Guvenliginiz için tüm hesap bilgilerinizi girin." )]
private static void AccountInfo_OnCommand( CommandEventArgs e )
{
if ( !Factions.Sigil.ExistsOn( e.Mobile ) )
{
if ( e.Mobile.Spell == null )
{
if ( !Server.Spells.SpellHelper.CheckCombat( e.Mobile ) )
{
e.Mobile.SendGump( new AccountMain( e.Mobile ) );
e.Mobile.SendMessage( 53, "Lutfen,oynayabilmek için hesap bilgilerinizi girin." );
e.Mobile.Frozen = true;
e.Mobile.Hidden = true;
e.Mobile.Squelched = true;
}
else
{
e.Mobile.SendMessage("Savas esnasinda bunu kullanamazsiniz.");
}
}
else
{
e.Mobile.SendMessage("Bunu kullanmak için çok mesgulsünüz.");
}
}
else
{
e.Mobile.SendMessage("You cant use this command while holding a faction sigil.");
}
}
private static void AccountNew_OnCommand( LoginEventArgs e )
{
if(((Account)e.Mobile.Account).GetTag("AccountInfo") == null)
{
e.Mobile.SendGump( new AccountMain( e.Mobile ) );
e.Mobile.SendMessage( 53, "Lutfen,oynayabilmek için hesap bilgilerinizi girin." );
e.Mobile.Frozen = true;
e.Mobile.Hidden = true;
e.Mobile.Squelched = true;
}
}
public enum Buttons
{
btn_Password,
btn_Cancel,
btn_Account,
}
public AccountMain( Mobile from ) : base( 0, 0 )
{
Closable=false;
Disposable=true;
Dragable=true;
Resizable=false;
AddPage(0);
AddBackground(188, 151, 440, 290, 9200);
AddImage(595, 92, 10441);//Dragon
AddImage(138, 92, 10440);//Dragon
AddHtml(189, 152, 439, 289,@"<center>"+Server.Misc.ServerList.ServerName+" Hesap Güvenligi</center>", (bool)false, (bool)false);
AddHtml( 209, 180, 397, 204, @"<center>Bilgi</center><br>Hesap güvenlik sistemi hesabinizi hack durumlarina karsi korumak için tasarlanmistir.<br> <p>Guvenliginiz için dogru bilgileri girmeniz çok önemlidir. <br> <p>Girdiginiz hesap bilgileri sadece ownera ulasir. Hiçbir sekilde baska bir staff üyesine yada oyuncuya iletilmez.<br><p>Unutmayin bu bilgileri sadece bir kez gireceksiniz.<br><p> Sifre Degistirme - Bu bölüm sifrenizi degistirmeniz içindir.<br> <p> Hesap Bilgileri - Cevaplamaniz gereken birkaç soru bulunuyor. Sadece kendi bildiginiz bilgiler olmasi önemlidir. Böylece ileride eger hacklenirseniz bu bilgilere bakarak hesabin orjinal sahibi kimdir kolayca anlayabilecegiz.<br> <p>Ilginiz için tesekkürler.", (bool)false, (bool)true);
AddLabel(210, 390, 0, @"Sifre Degistirme");
AddButton(233, 413, 2074, 2075, (int)Buttons.btn_Password, GumpButtonType.Reply, 0);
AddLabel(397, 390, 0, @"Çikis");
AddButton(381, 414, 2071, 2072, (int)Buttons.btn_Cancel, GumpButtonType.Reply, 0);
if(((Account)from.Account).GetTag("AccountInfo") == null)
{
AddLabel(516, 390, 0, @"Hesap Bilgileri");
AddButton(535, 413, 2074, 2075, (int)Buttons.btn_Account, GumpButtonType.Reply, 0);
}
}
public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
{
Mobile from = sender.Mobile;
switch ( info.ButtonID )
{
case (int)Buttons.btn_Password:
from.CloseGump( typeof( AccountMain ) );
from.SendGump( new PasswordMenu());
break;
case (int)Buttons.btn_Cancel:
from.CloseGump( typeof( AccountMain ) );
from.Frozen = false;
from.Hidden = false;
from.Squelched = false;
break;
case (int)Buttons.btn_Account:
from.CloseGump( typeof( AccountMain ) );
from.SendGump( new AccountInfo());
break;
}
}
}
}

darkwinters- 02-04-2006
ok arte i chanced the first script like this.am i right?

CODE
public override void OnResponse(Server.Network.NetState sender, RelayInfo info) { Mobile from = sender.Mobile; if(from == null) return; ArrayList textentries = new ArrayList();
TextRelay tr = info.GetTextEntry( (int)Buttons.txt_Realname);
if(tr != null)
{
realname= tr.Text;
textentries.Add(realname);
}
tr = info.GetTextEntry( (int)Buttons.txt_Birthdate);
if(tr != null)
{
birthdate = tr.Text;
textentries.Add(birthdate);
}
tr = info.GetTextEntry( (int)Buttons.txt_Email1);
if(tr != null)
{
birthdate = tr.Text;
textentries.Add(email1);
}
tr = info.GetTextEntry( (int)Buttons.txt_Email2);
if(tr != null)
{
birthdate = tr.Text;
textentries.Add(email2);
}
tr = info.GetTextEntry( (int)Buttons.txt_Magicword);
if(tr != null)
{
birthdate = tr.Text;
textentries.Add(magicword);
}
tr = info.GetTextEntry( (int)Buttons.txt_Magicwordhint);
if(tr != null)
{
birthdate = tr.Text;
textentries.Add(magicwordhint);
}
switch ( info.ButtonID )

ArteGordon- 02-04-2006
yes, that will work, but you want to change these, to the correct strings that you are trying to assign I assume.
change

QUOTE
if(tr != null) { birthdate = tr.Text; textentries.Add(email2); }

to

QUOTE
if(tr != null) { email2= tr.Text; textentries.Add(email2); }

darkwinters- 02-04-2006
did you look at my accountmaingump.cs i posted?
are there any error in there?
ArteGordon- 02-04-2006
I didnt really look through it. Your crash was only from the first script that you posted.