RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Character Conversion

Omophorus

Wanderer
Character Conversion

I'm trying to put together a script that will read the POL accounts.txt and pcs.txt (account and player data) and convert these to RunUO data. The account handling was easy, but the character handling is less so. Is there a convenient way in which to create a character (without user interaction, naturally) to create a character with a certain name under a specific account, and thereafter make changes to its attributes?

It doesn't seem as if something like this has been done (only for items), but do tell if I missed something :)
 

Phantom

Knight
I would look at CharacterCreation.cs see if you can see when the character is added to the account.

It won't be easy.
 

Omophorus

Wanderer
At long last, here's some code. This has been inworking order for a while now, but some people have asked me about it, so here it is. Note that some properties of the characters it creates are set to rather simple defaults (i.e. generation of random hairdo and beards). I've considered things like that as less important since characters tend to customize those fairly quickly in-game. Some changes may apply if you use certain modified scripts, those are noted as comments in the source. Also, certain POL customizations (e.g. the addition of Necromancy as skill) may influence your code somewhat, Ive also indicated in the code where that may change. The paths to your POL accounts.txt and pcs.txt also needs to be set in the code.

Basic operation (what I've done - PLEASE backup your shard beforehand :) ):
Fire up your shard and connect as an admin user. Run [POLAccounting. It should (hopefully) show you individual account and character names as they are imported, and at the end give you an idea about the number of accounts and characters processed. After this, do a [save and restart the shard. Just intended as a sanity check :)

Some small things may need tweaking, you may for example look at the handling of the banned accounts on the POL side. It is of course only a line away to just stop those from being imported at all.

POLAccounting.cs

[code:1]// ****************************************************************
// by Omophorus, feel free to improve on this mostly messy code :)
// First release, 23 Jul 2003
// ****************************************************************
using System;
using System.IO;
using System.Globalization;
using Server.Accounting;
using Server.Misc;
using Server.Mobiles;
using Server.Items;
using Server.Network;

namespace Server.Scripts.Commands
{
public class POLAccounting
{
private static void Item2Container( Item item, Container container )
{
item.LootType = LootType.Newbied;

if ( container != null )
container.DropItem( item );
else
item.Delete();
}

private static void AddRandomHair( Mobile m, int hue )
{
Item item;

switch ( Utility.Random(10) )
{
case 0: item = new Mohawk( hue ); break;
case 1: item = new PageboyHair( hue ); break;
case 2: item = new BunsHair( hue ); break;
case 3: item = new Afro( hue ); break;
case 4: item = new ReceedingHair( hue ); break;
case 5: item = new TwoPigTails( hue ); break;
case 6: item = new KrisnaHair( hue ); break;
case 7: item = new ShortHair( hue ); break;
case 8: item = new LongHair( hue ); break;
case 9: item = new PonyTail( hue ); break;
default: return;
}

m.AddItem( item );
}

private static void AddRandomBeard( Mobile m, int hue )
{
if ( m.Female )
return;

Item item;

switch ( Utility.Random(7) )
{
case 0: item = new LongBeard( hue ); break;
case 1: item = new ShortBeard( hue ); break;
case 2: item = new Goatee( hue ); break;
case 3: item = new Mustache( hue ); break;
case 4: item = new MediumShortBeard( hue ); break;
case 5: item = new MediumLongBeard( hue ); break;
case 6: item = new Vandyke( hue ); break;
default: return;
}

m.AddItem( item );
}

private static int AccountVacancy(Account acct)
{
for ( int i = 0; i < 5; ++i )
if ( acct == null )
return (i);
return 0;

}
public static void Initialize()
{
Server.Commands.Register( "POLAccounting", AccessLevel.Administrator, new CommandEventHandler( POLAccounting_OnCommand ) );
}
private static void POLAccounting_OnCommand( CommandEventArgs e )
{
Mobile from = e.Mobile;
int accountCount = 0;
int characterCount = 0;
string text, text2;
string[] textArray, text2Array;
FileStream fsTime, fs2Time;
PlayerMobile newChar;
Account newCharAcct;

// Edit these to point to your POL data files
string filename = "C:/POL/Data/accounts.txt";
string pcsfilename = "C:/POL/Data/pcs.txt";

try
{
// Open the file and start to read
fsTime = new FileStream( filename, FileMode.Open );
fs2Time = new FileStream( pcsfilename, FileMode.Open );
}
catch
{
from.SendMessage( 63, "Couldn't find one of the required files. " );
return;
}

// READING ACCOUNTS:
StreamReader srTime = new StreamReader(fsTime);
from.SendMessage( 63, "Importing accounts ..." );
// Scan through the file and create the accounts
while( srTime.Peek() > -1 )
{
text = srTime.ReadLine().Trim();
string tmpAccountName = "";
string tmpAccountPassword = "";
string tmpAccountBanned = "0";
if( text == "{" )
{
// Read the account data that we need
while ( text != "}" )
{
text = srTime.ReadLine().Trim();
textArray = text.Split( '\t' );
switch (textArray[0]) {
case "Name":
tmpAccountName = textArray[1];
break;
case "Password":
tmpAccountPassword = textArray[1];
break;
case "Banned":
tmpAccountBanned = textArray[1];
break;
default:
break;
}
}

// create the account ...
// todo: check whether this account name exists already ...
if (tmpAccountBanned != "1") {
Accounts.AddAccount(tmpAccountName,tmpAccountPassword); // this may have to get another parameter (email address) if using Trammel/Felucca spawned word distro
accountCount++;
}
}
}
// Stop reading and close the file.
srTime.Close();
fsTime.Close();

from.SendMessage( 63, "Done importing " + accountCount + " accounts." );

// READING CHARACTERS:
from.SendMessage( 63, "Importing characters ..." );
StreamReader sr2Time = new StreamReader(fs2Time);

// Scan through the file and create the characters
while( sr2Time.Peek() > -1 )
{
text2 = sr2Time.ReadLine().Trim();

string tmpCharName = "";
string tmpCharAccountString = "";
string tmpCharCmdlevel = "0";
string tmpCharGender = "0"; // defaults as male
string tmpCharHue = "0x83ea"; // some arb default :)
string tmpCharStr = "30";
string tmpCharDex = "30";
string tmpCharInt = "30";
double[] tSkills = new double[52];
if( text2 == "{" )
{
// 1. Read the character data that we need
while ( text2 != "}" )
{
text2 = sr2Time.ReadLine().Trim();
text2Array = text2.Split( '\t' );
switch (text2Array[0]) {
case "Name":
tmpCharName = text2Array[1];
from.SendMessage( 63, "character="+tmpCharName );
break;
case "Account":
tmpCharAccountString = text2Array[1];
from.SendMessage( 63, "account="+tmpCharAccountString );
break;
case "CmdLevel":
tmpCharCmdlevel = text2Array[1];
break;
case "Gender":
tmpCharGender = text2Array[1];
break;
case "Color":
tmpCharHue = text2Array[1] ;
break;
// STATS
case "Strength":
tmpCharStr = text2Array[1];
break;
case "Dexterity":
tmpCharDex = text2Array[1];
break;
case "Intelligence":
tmpCharInt = text2Array[1];
break;
// END STATS
// SKILLS
case "Alchemy" : tSkills[0] = Convert.ToDouble(text2Array[1]); break;
case "Anatomy" : tSkills[1] = Convert.ToDouble(text2Array[1]); break;
case "AnimalLore" : tSkills[2] = Convert.ToDouble(text2Array[1]); break;
case "ItemId" : tSkills[3] = Convert.ToDouble(text2Array[1]); break;
case "ArmsLore" : tSkills[4] = Convert.ToDouble(text2Array[1]); break;
case "Parry" : tSkills[5] = Convert.ToDouble(text2Array[1]); break;
case "Begging" : tSkills[6] = Convert.ToDouble(text2Array[1]); break;
case "Blacksmithy" : tSkills[7] = Convert.ToDouble(text2Array[1]); break;
case "Bowcraft" : tSkills[8] = Convert.ToDouble(text2Array[1]); break;
case "Peacemaking" : tSkills[9] = Convert.ToDouble(text2Array[1]); break;
case "Camping" : tSkills[10] = Convert.ToDouble(text2Array[1]); break;
case "Carpentry" : tSkills[11] = Convert.ToDouble(text2Array[1]); break;
case "Cartography" : tSkills[12] = Convert.ToDouble(text2Array[1]); break;
case "Cooking" : tSkills[13] = Convert.ToDouble(text2Array[1]); break;
case "DetectingHidden" : tSkills[14] = Convert.ToDouble(text2Array[1]); break;
// Enticement -> Discordance
case "Enticement" : tSkills[15] = Convert.ToDouble(text2Array[1]); break;
case "EvaluatingIntelligence" : tSkills[16] = Convert.ToDouble(text2Array[1]); break;
case "Healing" : tSkills[17] = Convert.ToDouble(text2Array[1]); break;
case "Fishing" : tSkills[18] = Convert.ToDouble(text2Array[1]); break;
case "ForensicEvaluation" : tSkills[19] = Convert.ToDouble(text2Array[1]); break;
case "Herding" : tSkills[20] = Convert.ToDouble(text2Array[1]); break;
case "Hiding" : tSkills[21] = Convert.ToDouble(text2Array[1]); break;
case "Provocation" : tSkills[22] = Convert.ToDouble(text2Array[1]); break;
case "Inscription" : tSkills[23] = Convert.ToDouble(text2Array[1]); break;
case "Lockpicking" : tSkills[24] = Convert.ToDouble(text2Array[1]); break;
case "Magery" : tSkills[25] = Convert.ToDouble(text2Array[1]); break;
case "MagicResistance" : tSkills[26] = Convert.ToDouble(text2Array[1]); break;
case "Tactics" : tSkills[27] = Convert.ToDouble(text2Array[1]); break;
case "Snooping" : tSkills[28] = Convert.ToDouble(text2Array[1]); break;
case "Musicianship" : tSkills[29] = Convert.ToDouble(text2Array[1]); break;
case "Poisoning" : tSkills[30] = Convert.ToDouble(text2Array[1]); break;
case "Archery" : tSkills[31] = Convert.ToDouble(text2Array[1]); break;
case "SpiritSpeak" : tSkills[32] = Convert.ToDouble(text2Array[1]); break;
case "Stealing" : tSkills[33] = Convert.ToDouble(text2Array[1]); break;
case "Tailoring" : tSkills[34] = Convert.ToDouble(text2Array[1]); break;
case "AnimalTaming" : tSkills[35] = Convert.ToDouble(text2Array[1]); break;
case "TasteIdentification" : tSkills[36] = Convert.ToDouble(text2Array[1]); break;
case "Tinkering" : tSkills[37] = Convert.ToDouble(text2Array[1]); break;
case "Tracking" : tSkills[38] = Convert.ToDouble(text2Array[1]); break;
case "Veterinary" : tSkills[39] = Convert.ToDouble(text2Array[1]); break;
case "Swordsmanship" : tSkills[40] = Convert.ToDouble(text2Array[1]); break;
case "Macefighting" : tSkills[41] = Convert.ToDouble(text2Array[1]); break;
case "Fencing" : tSkills[42] = Convert.ToDouble(text2Array[1]); break;
case "Wrestling" : tSkills[43] = Convert.ToDouble(text2Array[1]); break;
case "Lumberjacking" : tSkills[44] = Convert.ToDouble(text2Array[1]); break;
case "Mining" : tSkills[45] = Convert.ToDouble(text2Array[1]); break;
case "Meditation" : tSkills[46] = Convert.ToDouble(text2Array[1]); break;
case "Stealth" : tSkills[47] = Convert.ToDouble(text2Array[1]); break;
case "RemoveTrap" : tSkills[48] = Convert.ToDouble(text2Array[1]); break;
// customize skills from here on - you may want to make some changes to this list
case "Necromancy" : tSkills[49] = Convert.ToDouble(text2Array[1]); break;
// END SKILLS
default:
break;
}
}

// 2. create the character
newChar = new PlayerMobile();

// 3. set up the character's specific properties
newCharAcct = Accounts.GetAccount(tmpCharAccountString);
newChar.Name = tmpCharName;
newChar.Player = true;

newchar.Female = (tempCharGender == "0") ? false : true;

newChar.Body = newChar.Female ? 0x191 : 0x190;
newChar.Hue = int.Parse(tmpCharHue.Substring(2),NumberStyles.HexNumber);
newChar.Hunger = 20;
CityInfo city = new CityInfo( "Britain", "Sweet Dreams Inn", 1496, 1628, 10 );
newChar.Location = city.Location;
newChar.Map = Map.Trammel;

// stats
newChar.InitStats((int)Math.Round(Convert.ToDecimal(tmpCharStr)),
(int)Math.Round(Convert.ToDecimal(tmpCharDex)),
(int)Math.Round(Convert.ToDecimal(tmpCharInt)));

// skills
newChar.Skills[SkillName.Alchemy].Base = tSkills[0];
newChar.Skills[SkillName.Anatomy].Base = tSkills[1];
newChar.Skills[SkillName.AnimalLore].Base = tSkills[2];
newChar.Skills[SkillName.ItemID].Base = tSkills[3];
newChar.Skills[SkillName.ArmsLore].Base = tSkills[4];
newChar.Skills[SkillName.Parry].Base = tSkills[5];
newChar.Skills[SkillName.Begging].Base = tSkills[6];
newChar.Skills[SkillName.Blacksmith].Base = tSkills[7];
newChar.Skills[SkillName.Fletching].Base = tSkills[8];
newChar.Skills[SkillName.Peacemaking].Base = tSkills[9];
newChar.Skills[SkillName.Camping].Base = tSkills[10];
newChar.Skills[SkillName.Carpentry].Base = tSkills[11];
newChar.Skills[SkillName.Cartography].Base = tSkills[12];
newChar.Skills[SkillName.Cooking].Base = tSkills[13];
newChar.Skills[SkillName.DetectHidden].Base = tSkills[14];
newChar.Skills[SkillName.Discordance].Base = tSkills[15];
newChar.Skills[SkillName.EvalInt].Base = tSkills[16];
newChar.Skills[SkillName.Healing].Base = tSkills[17];
newChar.Skills[SkillName.Fishing].Base = tSkills[18];
newChar.Skills[SkillName.Forensics].Base = tSkills[19];
newChar.Skills[SkillName.Herding].Base = tSkills[20];
newChar.Skills[SkillName.Hiding].Base = tSkills[21];
newChar.Skills[SkillName.Provocation].Base = tSkills[22];
newChar.Skills[SkillName.Inscribe].Base = tSkills[23];
newChar.Skills[SkillName.Lockpicking].Base = tSkills[24];
newChar.Skills[SkillName.Magery].Base = tSkills[25];
newChar.Skills[SkillName.MagicResist].Base = tSkills[26];
newChar.Skills[SkillName.Tactics].Base = tSkills[27];
newChar.Skills[SkillName.Snooping].Base = tSkills[28];
newChar.Skills[SkillName.Musicianship].Base = tSkills[29];
newChar.Skills[SkillName.Poisoning].Base = tSkills[30];
newChar.Skills[SkillName.Archery].Base = tSkills[31];
newChar.Skills[SkillName.SpiritSpeak].Base = tSkills[32];
newChar.Skills[SkillName.Stealing].Base = tSkills[33];
newChar.Skills[SkillName.Tailoring].Base = tSkills[34];
newChar.Skills[SkillName.AnimalTaming].Base = tSkills[35];
newChar.Skills[SkillName.TasteID].Base = tSkills[36];
newChar.Skills[SkillName.Tinkering].Base = tSkills[37];
newChar.Skills[SkillName.Tracking].Base = tSkills[38];
newChar.Skills[SkillName.Veterinary].Base = tSkills[39];
newChar.Skills[SkillName.Swords].Base = tSkills[40];
newChar.Skills[SkillName.Macing].Base = tSkills[41];
newChar.Skills[SkillName.Fencing].Base = tSkills[42];
newChar.Skills[SkillName.Wrestling].Base = tSkills[43];
newChar.Skills[SkillName.Lumberjacking].Base = tSkills[44];
newChar.Skills[SkillName.Mining].Base = tSkills[45];
newChar.Skills[SkillName.Meditation].Base = tSkills[46];
newChar.Skills[SkillName.Stealth].Base = tSkills[47];
newChar.Skills[SkillName.RemoveTrap].Base = tSkills[48];
// (these last 3 does not neccessarily exist under default POL :
newChar.Skills[SkillName.Necromancy].Base = tSkills[49];
newChar.Skills[SkillName.Focus].Base = tSkills[50];
newChar.Skills[SkillName.Chivalry].Base = tSkills[51];

// access level
if ((tmpCharCmdlevel == "test") | (tmpCharCmdlevel == "admin"))
{
newCharAcct.AccessLevel = AccessLevel.Administrator;
newChar.AccessLevel = AccessLevel.Administrator;
}

// 4. Try to add character to account:
if ((tmpCharName != "") && (tmpCharAccountString != ""))
{
int i = 0;
while (i < 5)
{
if ( newCharAcct == null )
{
from.SendMessage( 63, "Adding character " + tmpCharName + " to account "+tmpCharAccountString+"["+i+"]" );
newCharAcct = newChar;
i = 5;
characterCount++;
// create a backpack & some items for the character:
Container pack = newChar.Backpack;
if ( pack == null )
{
pack = new Backpack();
pack.Movable = false;
newChar.AddItem( pack );
}
Item2Container( new RedBook( "a book", newChar.Name, 20, true ), pack );
Item2Container( new Gold( 1000 ), pack ); // Starting gold can be customized here
Item2Container( new Dagger(), pack );
Item2Container( new Candle(), pack );
// creation successful : give the character some items ...
BankBox bank = newChar.BankBox;
bank.DropItem( new BankCheck( 1000 ) );

// hair & beard
AddRandomHair(newChar, 0x455); // some arb colour ...
AddRandomBeard(newChar, 0x455);
}
i++;
}
}
}
}
// Stop reading and close the file.
sr2Time.Close();
fs2Time.Close();

from.SendMessage( 63, "Done importing " + characterCount + " characters." );

}
}
}
[/code:1]

Feel free to make any suggestions and/or changes yourself, just keep the header of the file (mostly) unharmed.
 

lordsilence2

Wanderer
Nice script :)
Works good on standard distribution.
But on the Trammel / Felluca package I get compilation errors. I did as the comment said that it needed an email string aswell.
But then it complained about line 282
newchar.Female = (tempCharGender == "0") ? false : true;

Have no idea to fix it. :/ Got an clues?
 

Omophorus

Wanderer
Hmmm, I actually changed that without recompiling. Baaaaaad of me :)

Change that line to something like

[code:1]if (tempCharGender == "0")
newChar.Female = false
else
newChar.Female = true;[/code:1]

Not sure why the original didn't work, it just seemed like a nice compact way of doing things :p
 

lordsilence2

Wanderer
Now I got this error.
- Error: Scripts\Custom\Modified\Commands\POLAccounting.cs CS0103: (line 279, column 22) The Name tempCharGender does not exist in the class or namespace Server.Scripts.Commands.POLAccounting.

I translated this from swedish so might not be accurate :)
Any idea?

[code:1]

// ****************************************************************
// by Omophorus, feel free to improve on this mostly messy code :)
// First release, 23 Jul 2003
// Edited by Xan for Trammel / Felluca worldpackage distro. Still not fully functional. ****************************************************************
using System;
using System.IO;
using System.Globalization;
using Server.Accounting;
using Server.Misc;
using Server.Mobiles;
using Server.Items;
using Server.Network;

namespace Server.Scripts.Commands
{
public class POLAccounting
{
private static void Item2Container( Item item, Container container )
{
item.LootType = LootType.Newbied;

if ( container != null )
container.DropItem( item );
else
item.Delete();
}

private static void AddRandomHair( Mobile m, int hue )
{
Item item;

switch ( Utility.Random(10) )
{
case 0: item = new Mohawk( hue ); break;
case 1: item = new PageboyHair( hue ); break;
case 2: item = new BunsHair( hue ); break;
case 3: item = new Afro( hue ); break;
case 4: item = new ReceedingHair( hue ); break;
case 5: item = new TwoPigTails( hue ); break;
case 6: item = new KrisnaHair( hue ); break;
case 7: item = new ShortHair( hue ); break;
case 8: item = new LongHair( hue ); break;
case 9: item = new PonyTail( hue ); break;
default: return;
}

m.AddItem( item );
}

private static void AddRandomBeard( Mobile m, int hue )
{
if ( m.Female )
return;

Item item;

switch ( Utility.Random(7) )
{
case 0: item = new LongBeard( hue ); break;
case 1: item = new ShortBeard( hue ); break;
case 2: item = new Goatee( hue ); break;
case 3: item = new Mustache( hue ); break;
case 4: item = new MediumShortBeard( hue ); break;
case 5: item = new MediumLongBeard( hue ); break;
case 6: item = new Vandyke( hue ); break;
default: return;
}

m.AddItem( item );
}

private static int AccountVacancy(Account acct)
{
for ( int i = 0; i < 5; ++i )
if ( acct == null )
return (i);
return 0;

}
public static void Initialize()
{
Server.Commands.Register( "POLAccounting", AccessLevel.Administrator, new CommandEventHandler( POLAccounting_OnCommand ) );
}
private static void POLAccounting_OnCommand( CommandEventArgs e )
{
Mobile from = e.Mobile;
int accountCount = 0;
int characterCount = 0;
string text, text2;
string[] textArray, text2Array;
FileStream fsTime, fs2Time;
PlayerMobile newChar;
Account newCharAcct;

// Edit these to point to your POL data files
string filename = "C:/POL/Data/accounts.txt";
string pcsfilename = "C:/POL/Data/pcs.txt";

try
{
// Open the file and start to read
fsTime = new FileStream( filename, FileMode.Open );
fs2Time = new FileStream( pcsfilename, FileMode.Open );
}
catch
{
from.SendMessage( 63, "Couldn't find one of the required files. " );
return;
}

// READING ACCOUNTS:
StreamReader srTime = new StreamReader(fsTime);
from.SendMessage( 63, "Importing accounts ..." );
// Scan through the file and create the accounts
while( srTime.Peek() > -1 )
{
text = srTime.ReadLine().Trim();
string tmpAccountName = "";
string tmpAccountPassword = "";
string tmpAccountBanned = "0";
string tmpAccountEmail = "[email protected]";
if( text == "{" )
{
// Read the account data that we need
while ( text != "}" )
{
text = srTime.ReadLine().Trim();
textArray = text.Split( '\t' );
switch (textArray[0]) {
case "Name":
tmpAccountName = textArray[1];
break;
case "Password":
tmpAccountPassword = textArray[1];
break;
case "Banned":
tmpAccountBanned = textArray[1];
break;
default:
break;
}
}

// create the account ...
// todo: check whether this account name exists already ...
if (tmpAccountBanned != "1") {
Accounts.AddAccount(tmpAccountName,tmpAccountPassword,tmpAccountEmail); // this may have to get another parameter (email address) if using Trammel/Felucca spawned word distro
accountCount++;
}
}
}
// Stop reading and close the file.
srTime.Close();
fsTime.Close();

from.SendMessage( 63, "Done importing " + accountCount + " accounts." );

// READING CHARACTERS:
from.SendMessage( 63, "Importing characters ..." );
StreamReader sr2Time = new StreamReader(fs2Time);

// Scan through the file and create the characters
while( sr2Time.Peek() > -1 )
{
text2 = sr2Time.ReadLine().Trim();

string tmpCharName = "";
string tmpCharAccountString = "";
string tmpCharCmdlevel = "0";
string tmpCharGender = "0"; // defaults as male
string tmpCharHue = "0x83ea"; // some arb default :)
string tmpCharStr = "30";
string tmpCharDex = "30";
string tmpCharInt = "30";
double[] tSkills = new double[52];
if( text2 == "{" )
{
// 1. Read the character data that we need
while ( text2 != "}" )
{
text2 = sr2Time.ReadLine().Trim();
text2Array = text2.Split( '\t' );
switch (text2Array[0]) {
case "Name":
tmpCharName = text2Array[1];
from.SendMessage( 63, "character="+tmpCharName );
break;
case "Account":
tmpCharAccountString = text2Array[1];
from.SendMessage( 63, "account="+tmpCharAccountString );
break;
case "CmdLevel":
tmpCharCmdlevel = text2Array[1];
break;
case "Gender":
tmpCharGender = text2Array[1];
break;
case "Color":
tmpCharHue = text2Array[1] ;
break;
// STATS
case "Strength":
tmpCharStr = text2Array[1];
break;
case "Dexterity":
tmpCharDex = text2Array[1];
break;
case "Intelligence":
tmpCharInt = text2Array[1];
break;
// END STATS
// SKILLS
case "Alchemy" : tSkills[0] = Convert.ToDouble(text2Array[1]); break;
case "Anatomy" : tSkills[1] = Convert.ToDouble(text2Array[1]); break;
case "AnimalLore" : tSkills[2] = Convert.ToDouble(text2Array[1]); break;
case "ItemId" : tSkills[3] = Convert.ToDouble(text2Array[1]); break;
case "ArmsLore" : tSkills[4] = Convert.ToDouble(text2Array[1]); break;
case "Parry" : tSkills[5] = Convert.ToDouble(text2Array[1]); break;
case "Begging" : tSkills[6] = Convert.ToDouble(text2Array[1]); break;
case "Blacksmithy" : tSkills[7] = Convert.ToDouble(text2Array[1]); break;
case "Bowcraft" : tSkills[8] = Convert.ToDouble(text2Array[1]); break;
case "Peacemaking" : tSkills[9] = Convert.ToDouble(text2Array[1]); break;
case "Camping" : tSkills[10] = Convert.ToDouble(text2Array[1]); break;
case "Carpentry" : tSkills[11] = Convert.ToDouble(text2Array[1]); break;
case "Cartography" : tSkills[12] = Convert.ToDouble(text2Array[1]); break;
case "Cooking" : tSkills[13] = Convert.ToDouble(text2Array[1]); break;
case "DetectingHidden" : tSkills[14] = Convert.ToDouble(text2Array[1]); break;
// Enticement -> Discordance
case "Enticement" : tSkills[15] = Convert.ToDouble(text2Array[1]); break;
case "EvaluatingIntelligence" : tSkills[16] = Convert.ToDouble(text2Array[1]); break;
case "Healing" : tSkills[17] = Convert.ToDouble(text2Array[1]); break;
case "Fishing" : tSkills[18] = Convert.ToDouble(text2Array[1]); break;
case "ForensicEvaluation" : tSkills[19] = Convert.ToDouble(text2Array[1]); break;
case "Herding" : tSkills[20] = Convert.ToDouble(text2Array[1]); break;
case "Hiding" : tSkills[21] = Convert.ToDouble(text2Array[1]); break;
case "Provocation" : tSkills[22] = Convert.ToDouble(text2Array[1]); break;
case "Inscription" : tSkills[23] = Convert.ToDouble(text2Array[1]); break;
case "Lockpicking" : tSkills[24] = Convert.ToDouble(text2Array[1]); break;
case "Magery" : tSkills[25] = Convert.ToDouble(text2Array[1]); break;
case "MagicResistance" : tSkills[26] = Convert.ToDouble(text2Array[1]); break;
case "Tactics" : tSkills[27] = Convert.ToDouble(text2Array[1]); break;
case "Snooping" : tSkills[28] = Convert.ToDouble(text2Array[1]); break;
case "Musicianship" : tSkills[29] = Convert.ToDouble(text2Array[1]); break;
case "Poisoning" : tSkills[30] = Convert.ToDouble(text2Array[1]); break;
case "Archery" : tSkills[31] = Convert.ToDouble(text2Array[1]); break;
case "SpiritSpeak" : tSkills[32] = Convert.ToDouble(text2Array[1]); break;
case "Stealing" : tSkills[33] = Convert.ToDouble(text2Array[1]); break;
case "Tailoring" : tSkills[34] = Convert.ToDouble(text2Array[1]); break;
case "AnimalTaming" : tSkills[35] = Convert.ToDouble(text2Array[1]); break;
case "TasteIdentification" : tSkills[36] = Convert.ToDouble(text2Array[1]); break;
case "Tinkering" : tSkills[37] = Convert.ToDouble(text2Array[1]); break;
case "Tracking" : tSkills[38] = Convert.ToDouble(text2Array[1]); break;
case "Veterinary" : tSkills[39] = Convert.ToDouble(text2Array[1]); break;
case "Swordsmanship" : tSkills[40] = Convert.ToDouble(text2Array[1]); break;
case "Macefighting" : tSkills[41] = Convert.ToDouble(text2Array[1]); break;
case "Fencing" : tSkills[42] = Convert.ToDouble(text2Array[1]); break;
case "Wrestling" : tSkills[43] = Convert.ToDouble(text2Array[1]); break;
case "Lumberjacking" : tSkills[44] = Convert.ToDouble(text2Array[1]); break;
case "Mining" : tSkills[45] = Convert.ToDouble(text2Array[1]); break;
case "Meditation" : tSkills[46] = Convert.ToDouble(text2Array[1]); break;
case "Stealth" : tSkills[47] = Convert.ToDouble(text2Array[1]); break;
case "RemoveTrap" : tSkills[48] = Convert.ToDouble(text2Array[1]); break;
// customize skills from here on - you may want to make some changes to this list
case "Necromancy" : tSkills[49] = Convert.ToDouble(text2Array[1]); break;
// END SKILLS
default:
break;
}
}

// 2. create the character
newChar = new PlayerMobile();

// 3. set up the character's specific properties
newCharAcct = Accounts.GetAccount(tmpCharAccountString);
newChar.Name = tmpCharName;
newChar.Player = true;

if (tempCharGender == "0")
newChar.Female = false;
else
newChar.Female = true;

newChar.Body = newChar.Female ? 0x191 : 0x190;
newChar.Hue = int.Parse(tmpCharHue.Substring(2),NumberStyles.HexNumber);
newChar.Hunger = 20;
CityInfo city = new CityInfo( "Britain", "Sweet Dreams Inn", 1496, 1628, 10 );
newChar.Location = city.Location;
newChar.Map = Map.Trammel;

// stats
newChar.InitStats((int)Math.Round(Convert.ToDecimal(tmpCharStr)),
(int)Math.Round(Convert.ToDecimal(tmpCharDex)),
(int)Math.Round(Convert.ToDecimal(tmpCharInt)));

// skills
newChar.Skills[SkillName.Alchemy].Base = tSkills[0];
newChar.Skills[SkillName.Anatomy].Base = tSkills[1];
newChar.Skills[SkillName.AnimalLore].Base = tSkills[2];
newChar.Skills[SkillName.ItemID].Base = tSkills[3];
newChar.Skills[SkillName.ArmsLore].Base = tSkills[4];
newChar.Skills[SkillName.Parry].Base = tSkills[5];
newChar.Skills[SkillName.Begging].Base = tSkills[6];
newChar.Skills[SkillName.Blacksmith].Base = tSkills[7];
newChar.Skills[SkillName.Fletching].Base = tSkills[8];
newChar.Skills[SkillName.Peacemaking].Base = tSkills[9];
newChar.Skills[SkillName.Camping].Base = tSkills[10];
newChar.Skills[SkillName.Carpentry].Base = tSkills[11];
newChar.Skills[SkillName.Cartography].Base = tSkills[12];
newChar.Skills[SkillName.Cooking].Base = tSkills[13];
newChar.Skills[SkillName.DetectHidden].Base = tSkills[14];
newChar.Skills[SkillName.Discordance].Base = tSkills[15];
newChar.Skills[SkillName.EvalInt].Base = tSkills[16];
newChar.Skills[SkillName.Healing].Base = tSkills[17];
newChar.Skills[SkillName.Fishing].Base = tSkills[18];
newChar.Skills[SkillName.Forensics].Base = tSkills[19];
newChar.Skills[SkillName.Herding].Base = tSkills[20];
newChar.Skills[SkillName.Hiding].Base = tSkills[21];
newChar.Skills[SkillName.Provocation].Base = tSkills[22];
newChar.Skills[SkillName.Inscribe].Base = tSkills[23];
newChar.Skills[SkillName.Lockpicking].Base = tSkills[24];
newChar.Skills[SkillName.Magery].Base = tSkills[25];
newChar.Skills[SkillName.MagicResist].Base = tSkills[26];
newChar.Skills[SkillName.Tactics].Base = tSkills[27];
newChar.Skills[SkillName.Snooping].Base = tSkills[28];
newChar.Skills[SkillName.Musicianship].Base = tSkills[29];
newChar.Skills[SkillName.Poisoning].Base = tSkills[30];
newChar.Skills[SkillName.Archery].Base = tSkills[31];
newChar.Skills[SkillName.SpiritSpeak].Base = tSkills[32];
newChar.Skills[SkillName.Stealing].Base = tSkills[33];
newChar.Skills[SkillName.Tailoring].Base = tSkills[34];
newChar.Skills[SkillName.AnimalTaming].Base = tSkills[35];
newChar.Skills[SkillName.TasteID].Base = tSkills[36];
newChar.Skills[SkillName.Tinkering].Base = tSkills[37];
newChar.Skills[SkillName.Tracking].Base = tSkills[38];
newChar.Skills[SkillName.Veterinary].Base = tSkills[39];
newChar.Skills[SkillName.Swords].Base = tSkills[40];
newChar.Skills[SkillName.Macing].Base = tSkills[41];
newChar.Skills[SkillName.Fencing].Base = tSkills[42];
newChar.Skills[SkillName.Wrestling].Base = tSkills[43];
newChar.Skills[SkillName.Lumberjacking].Base = tSkills[44];
newChar.Skills[SkillName.Mining].Base = tSkills[45];
newChar.Skills[SkillName.Meditation].Base = tSkills[46];
newChar.Skills[SkillName.Stealth].Base = tSkills[47];
newChar.Skills[SkillName.RemoveTrap].Base = tSkills[48];
// (these last 3 does not neccessarily exist under default POL :
newChar.Skills[SkillName.Necromancy].Base = tSkills[49];
newChar.Skills[SkillName.Focus].Base = tSkills[50];
newChar.Skills[SkillName.Chivalry].Base = tSkills[51];

// access level
if ((tmpCharCmdlevel == "test") | (tmpCharCmdlevel == "admin"))
{
newCharAcct.AccessLevel = AccessLevel.Administrator;
newChar.AccessLevel = AccessLevel.Administrator;
}

// 4. Try to add character to account:
if ((tmpCharName != "") && (tmpCharAccountString != ""))
{
int i = 0;
while (i < 5)
{
if ( newCharAcct == null )
{
from.SendMessage( 63, "Adding character " + tmpCharName + " to account "+tmpCharAccountString+"["+i+"]" );
newCharAcct = newChar;
i = 5;
characterCount++;
// create a backpack & some items for the character:
Container pack = newChar.Backpack;
if ( pack == null )
{
pack = new Backpack();
pack.Movable = false;
newChar.AddItem( pack );
}
Item2Container( new RedBook( "a book", newChar.Name, 20, true ), pack );
Item2Container( new Gold( 1000 ), pack ); // Starting gold can be customized here
Item2Container( new Dagger(), pack );
Item2Container( new Candle(), pack );
// creation successful : give the character some items ...
BankBox bank = newChar.BankBox;
bank.DropItem( new BankCheck( 1000 ) );

// hair & beard
AddRandomHair(newChar, 0x455); // some arb colour ...
AddRandomBeard(newChar, 0x455);
}
i++;
}
}
}
}
// Stop reading and close the file.
sr2Time.Close();
fs2Time.Close();

from.SendMessage( 63, "Done importing " + characterCount + " characters." );

}
}
}
[/code:1]
 

Omophorus

Wanderer
Hmmm, that's [code:1]tmpCharGender [/code:1] and not [code:1]tempCharGender [/code:1] :)

This is most probably why the original code didn't work anyways. The whole if-statement we added can therefore be replaced by[code:1]newchar.Female = (tmpCharGender == "0") ? false : true;[/code:1], I think. Not at my scripting PC now, do tell whether this does compile.
 

lordsilence2

Wanderer
Well. Now I'm working on importing the accounts and their characters.
First of all I'd like to work with a check which sees if there are duplicate accounts. Anyhow, I tried running it now without that check to see if it'd work.

It begins importing the characters but at the first character the server crashes and gives me in crash-log.

Exception:
System.FormatException: Indatastring had a wrong format.
at System.Number.ParseDouble(String s, NumberStyles style, NumberFormatInfo info)
at System.Double.Parse(String s, NumberStyles style, IFormatProvider provider)
at System.Convert.ToDouble(String value)
at Server.Scripts.Commands.POLAccounting.POLAccounting_OnCommand(CommandEventArgs e)
at Server.Commands.Handle(Mobile from, String text)
at Server.Mobile.DoSpeech(String text, Int32[] keywords, MessageType type, Int32 hue)
at Server.Network.PacketHandlers.UnicodeSpeech(NetState state, PacketReader pvSrc)
at Server.Network.MessagePump.HandleReceive(NetState ns)
at Server.Network.MessagePump.Slice()
at Server.Core.Main(String[] args)

The compilation didn't like [code:1]newchar.Female = (tmpCharGender == "0") ? false : true;"[/code:1] so I went with the [code:1]
if (tempCharGender == "0")
newChar.Female = false;
else
newChar.Female = true; [/code:1]

My current work-code is:
[code:1]
// ****************************************************************
// by Omophorus, feel free to improve on this mostly messy code :)
// First release, 23 Jul 2003
// Edited by Xan (www.icronticshard.org) for Trammel / Felluca worldpackage distro.
// ****************************************************************
using System;
using System.IO;
using System.Globalization;
using Server.Accounting;
using Server.Misc;
using Server.Mobiles;
using Server.Items;
using Server.Network;

namespace Server.Scripts.Commands
{
public class POLAccounting
{
private static void Item2Container( Item item, Container container )
{
item.LootType = LootType.Newbied;

if ( container != null )
container.DropItem( item );
else
item.Delete();
}

private static void AddRandomHair( Mobile m, int hue )
{
Item item;

switch ( Utility.Random(10) )
{
case 0: item = new Mohawk( hue ); break;
case 1: item = new PageboyHair( hue ); break;
case 2: item = new BunsHair( hue ); break;
case 3: item = new Afro( hue ); break;
case 4: item = new ReceedingHair( hue ); break;
case 5: item = new TwoPigTails( hue ); break;
case 6: item = new KrisnaHair( hue ); break;
case 7: item = new ShortHair( hue ); break;
case 8: item = new LongHair( hue ); break;
case 9: item = new PonyTail( hue ); break;
default: return;
}

m.AddItem( item );
}

private static void AddRandomBeard( Mobile m, int hue )
{
if ( m.Female )
return;

Item item;

switch ( Utility.Random(7) )
{
case 0: item = new LongBeard( hue ); break;
case 1: item = new ShortBeard( hue ); break;
case 2: item = new Goatee( hue ); break;
case 3: item = new Mustache( hue ); break;
case 4: item = new MediumShortBeard( hue ); break;
case 5: item = new MediumLongBeard( hue ); break;
case 6: item = new Vandyke( hue ); break;
default: return;
}

m.AddItem( item );
}

private static int AccountVacancy(Account acct)
{
for ( int i = 0; i < 5; ++i )
if ( acct == null )
return (i);
return 0;

}
public static void Initialize()
{
Server.Commands.Register( "POLAccounting", AccessLevel.Administrator, new CommandEventHandler( POLAccounting_OnCommand ) );
}
private static void POLAccounting_OnCommand( CommandEventArgs e )
{
Mobile from = e.Mobile;
int accountCount = 0;
int characterCount = 0;
string text, text2;
string[] textArray, text2Array;
FileStream fsTime, fs2Time;
PlayerMobile newChar;
Account newCharAcct;

// Edit these to point to your POL data files
string filename = "C:/shard/accounts.txt";
string pcsfilename = "C:/shard/pcs.txt";

try
{
// Open the file and start to read
fsTime = new FileStream( filename, FileMode.Open );
fs2Time = new FileStream( pcsfilename, FileMode.Open );
}
catch
{
from.SendMessage( 63, "Couldn't find one of the required files. " );
return;
}

// READING ACCOUNTS:
StreamReader srTime = new StreamReader(fsTime);
from.SendMessage( 63, "Importing accounts ..." );
// Scan through the file and create the accounts
while( srTime.Peek() > -1 )
{
text = srTime.ReadLine().Trim();
string tmpAccountName = "";
string tmpAccountPassword = "";
string tmpAccountBanned = "0";
string tmpAccountEmail = "[email protected]";
if( text == "{" )
{
// Read the account data that we need
while ( text != "}" )
{
text = srTime.ReadLine().Trim();
textArray = text.Split( '\t' );
switch (textArray[0]) {
case "Name":
tmpAccountName = textArray[1];
break;
case "Password":
tmpAccountPassword = textArray[1];
break;
case "Banned":
tmpAccountBanned = textArray[1];
break;
default:
break;
}
}

// create the account ...
// todo: check whether this account name exists already ...
if (tmpAccountBanned != "1") {
Accounts.AddAccount(tmpAccountName,tmpAccountPassword,tmpAccountEmail); // tmpAccountEmail added for Trammel/Felucca spawned word distro
accountCount++;
}
}
}
// Stop reading and close the file.
srTime.Close();
fsTime.Close();

from.SendMessage( 63, "Done importing " + accountCount + " accounts." );

// READING CHARACTERS:
from.SendMessage( 63, "Importing characters ..." );
StreamReader sr2Time = new StreamReader(fs2Time);

// Scan through the file and create the characters
while( sr2Time.Peek() > -1 )
{
text2 = sr2Time.ReadLine().Trim();

string tmpCharName = "";
string tmpCharAccountString = "";
string tmpCharCmdlevel = "0";
string tmpCharGender = "0"; // defaults as male
string tmpCharHue = "0x83ea"; // some arb default :)
string tmpCharStr = "30";
string tmpCharDex = "30";
string tmpCharInt = "30";
double[] tSkills = new double[52];
if( text2 == "{" )
{
// 1. Read the character data that we need
while ( text2 != "}" )
{
text2 = sr2Time.ReadLine().Trim();
text2Array = text2.Split( '\t' );
switch (text2Array[0]) {
case "Name":
tmpCharName = text2Array[1];
from.SendMessage( 63, "character="+tmpCharName );
break;
case "Account":
tmpCharAccountString = text2Array[1];
from.SendMessage( 63, "account="+tmpCharAccountString );
break;
case "CmdLevel":
tmpCharCmdlevel = text2Array[1];
break;
case "Gender":
tmpCharGender = text2Array[1];
break;
case "Color":
tmpCharHue = text2Array[1] ;
break;
// STATS
case "Strength":
tmpCharStr = text2Array[1];
break;
case "Dexterity":
tmpCharDex = text2Array[1];
break;
case "Intelligence":
tmpCharInt = text2Array[1];
break;
// END STATS
// SKILLS
case "Alchemy" : tSkills[0] = Convert.ToDouble(text2Array[1]); break;
case "Anatomy" : tSkills[1] = Convert.ToDouble(text2Array[1]); break;
case "AnimalLore" : tSkills[2] = Convert.ToDouble(text2Array[1]); break;
case "ItemId" : tSkills[3] = Convert.ToDouble(text2Array[1]); break;
case "ArmsLore" : tSkills[4] = Convert.ToDouble(text2Array[1]); break;
case "Parry" : tSkills[5] = Convert.ToDouble(text2Array[1]); break;
case "Begging" : tSkills[6] = Convert.ToDouble(text2Array[1]); break;
case "Blacksmithy" : tSkills[7] = Convert.ToDouble(text2Array[1]); break;
case "Bowcraft" : tSkills[8] = Convert.ToDouble(text2Array[1]); break;
case "Peacemaking" : tSkills[9] = Convert.ToDouble(text2Array[1]); break;
case "Camping" : tSkills[10] = Convert.ToDouble(text2Array[1]); break;
case "Carpentry" : tSkills[11] = Convert.ToDouble(text2Array[1]); break;
case "Cartography" : tSkills[12] = Convert.ToDouble(text2Array[1]); break;
case "Cooking" : tSkills[13] = Convert.ToDouble(text2Array[1]); break;
case "DetectingHidden" : tSkills[14] = Convert.ToDouble(text2Array[1]); break;
// Enticement -> Discordance
case "Enticement" : tSkills[15] = Convert.ToDouble(text2Array[1]); break;
case "EvaluatingIntelligence" : tSkills[16] = Convert.ToDouble(text2Array[1]); break;
case "Healing" : tSkills[17] = Convert.ToDouble(text2Array[1]); break;
case "Fishing" : tSkills[18] = Convert.ToDouble(text2Array[1]); break;
case "ForensicEvaluation" : tSkills[19] = Convert.ToDouble(text2Array[1]); break;
case "Herding" : tSkills[20] = Convert.ToDouble(text2Array[1]); break;
case "Hiding" : tSkills[21] = Convert.ToDouble(text2Array[1]); break;
case "Provocation" : tSkills[22] = Convert.ToDouble(text2Array[1]); break;
case "Inscription" : tSkills[23] = Convert.ToDouble(text2Array[1]); break;
case "Lockpicking" : tSkills[24] = Convert.ToDouble(text2Array[1]); break;
case "Magery" : tSkills[25] = Convert.ToDouble(text2Array[1]); break;
case "MagicResistance" : tSkills[26] = Convert.ToDouble(text2Array[1]); break;
case "Tactics" : tSkills[27] = Convert.ToDouble(text2Array[1]); break;
case "Snooping" : tSkills[28] = Convert.ToDouble(text2Array[1]); break;
case "Musicianship" : tSkills[29] = Convert.ToDouble(text2Array[1]); break;
case "Poisoning" : tSkills[30] = Convert.ToDouble(text2Array[1]); break;
case "Archery" : tSkills[31] = Convert.ToDouble(text2Array[1]); break;
case "SpiritSpeak" : tSkills[32] = Convert.ToDouble(text2Array[1]); break;
case "Stealing" : tSkills[33] = Convert.ToDouble(text2Array[1]); break;
case "Tailoring" : tSkills[34] = Convert.ToDouble(text2Array[1]); break;
case "AnimalTaming" : tSkills[35] = Convert.ToDouble(text2Array[1]); break;
case "TasteIdentification" : tSkills[36] = Convert.ToDouble(text2Array[1]); break;
case "Tinkering" : tSkills[37] = Convert.ToDouble(text2Array[1]); break;
case "Tracking" : tSkills[38] = Convert.ToDouble(text2Array[1]); break;
case "Veterinary" : tSkills[39] = Convert.ToDouble(text2Array[1]); break;
case "Swordsmanship" : tSkills[40] = Convert.ToDouble(text2Array[1]); break;
case "Macefighting" : tSkills[41] = Convert.ToDouble(text2Array[1]); break;
case "Fencing" : tSkills[42] = Convert.ToDouble(text2Array[1]); break;
case "Wrestling" : tSkills[43] = Convert.ToDouble(text2Array[1]); break;
case "Lumberjacking" : tSkills[44] = Convert.ToDouble(text2Array[1]); break;
case "Mining" : tSkills[45] = Convert.ToDouble(text2Array[1]); break;
case "Meditation" : tSkills[46] = Convert.ToDouble(text2Array[1]); break;
case "Stealth" : tSkills[47] = Convert.ToDouble(text2Array[1]); break;
case "RemoveTrap" : tSkills[48] = Convert.ToDouble(text2Array[1]); break;
// customize skills from here on - you may want to make some changes to this list
case "Necromancy" : tSkills[49] = Convert.ToDouble(text2Array[1]); break;
// END SKILLS
default:
break;
}
}

// 2. create the character
newChar = new PlayerMobile();

// 3. set up the character's specific properties
newCharAcct = Accounts.GetAccount(tmpCharAccountString);
newChar.Name = tmpCharName;
newChar.Player = true;

// newchar.Female = (tmpCharGender == "0") ? false : true;
if (tmpCharGender == "0")
newChar.Female = false;
else
newChar.Female = true;

newChar.Body = newChar.Female ? 0x191 : 0x190;
newChar.Hue = int.Parse(tmpCharHue.Substring(2),NumberStyles.HexNumber);
newChar.Hunger = 20;
CityInfo city = new CityInfo( "Britain", "Sweet Dreams Inn", 1496, 1628, 10 );
newChar.Location = city.Location;
newChar.Map = Map.Trammel;

// stats
newChar.InitStats((int)Math.Round(Convert.ToDecimal(tmpCharStr)),
(int)Math.Round(Convert.ToDecimal(tmpCharDex)),
(int)Math.Round(Convert.ToDecimal(tmpCharInt)));

// skills
newChar.Skills[SkillName.Alchemy].Base = tSkills[0];
newChar.Skills[SkillName.Anatomy].Base = tSkills[1];
newChar.Skills[SkillName.AnimalLore].Base = tSkills[2];
newChar.Skills[SkillName.ItemID].Base = tSkills[3];
newChar.Skills[SkillName.ArmsLore].Base = tSkills[4];
newChar.Skills[SkillName.Parry].Base = tSkills[5];
newChar.Skills[SkillName.Begging].Base = tSkills[6];
newChar.Skills[SkillName.Blacksmith].Base = tSkills[7];
newChar.Skills[SkillName.Fletching].Base = tSkills[8];
newChar.Skills[SkillName.Peacemaking].Base = tSkills[9];
newChar.Skills[SkillName.Camping].Base = tSkills[10];
newChar.Skills[SkillName.Carpentry].Base = tSkills[11];
newChar.Skills[SkillName.Cartography].Base = tSkills[12];
newChar.Skills[SkillName.Cooking].Base = tSkills[13];
newChar.Skills[SkillName.DetectHidden].Base = tSkills[14];
newChar.Skills[SkillName.Discordance].Base = tSkills[15];
newChar.Skills[SkillName.EvalInt].Base = tSkills[16];
newChar.Skills[SkillName.Healing].Base = tSkills[17];
newChar.Skills[SkillName.Fishing].Base = tSkills[18];
newChar.Skills[SkillName.Forensics].Base = tSkills[19];
newChar.Skills[SkillName.Herding].Base = tSkills[20];
newChar.Skills[SkillName.Hiding].Base = tSkills[21];
newChar.Skills[SkillName.Provocation].Base = tSkills[22];
newChar.Skills[SkillName.Inscribe].Base = tSkills[23];
newChar.Skills[SkillName.Lockpicking].Base = tSkills[24];
newChar.Skills[SkillName.Magery].Base = tSkills[25];
newChar.Skills[SkillName.MagicResist].Base = tSkills[26];
newChar.Skills[SkillName.Tactics].Base = tSkills[27];
newChar.Skills[SkillName.Snooping].Base = tSkills[28];
newChar.Skills[SkillName.Musicianship].Base = tSkills[29];
newChar.Skills[SkillName.Poisoning].Base = tSkills[30];
newChar.Skills[SkillName.Archery].Base = tSkills[31];
newChar.Skills[SkillName.SpiritSpeak].Base = tSkills[32];
newChar.Skills[SkillName.Stealing].Base = tSkills[33];
newChar.Skills[SkillName.Tailoring].Base = tSkills[34];
newChar.Skills[SkillName.AnimalTaming].Base = tSkills[35];
newChar.Skills[SkillName.TasteID].Base = tSkills[36];
newChar.Skills[SkillName.Tinkering].Base = tSkills[37];
newChar.Skills[SkillName.Tracking].Base = tSkills[38];
newChar.Skills[SkillName.Veterinary].Base = tSkills[39];
newChar.Skills[SkillName.Swords].Base = tSkills[40];
newChar.Skills[SkillName.Macing].Base = tSkills[41];
newChar.Skills[SkillName.Fencing].Base = tSkills[42];
newChar.Skills[SkillName.Wrestling].Base = tSkills[43];
newChar.Skills[SkillName.Lumberjacking].Base = tSkills[44];
newChar.Skills[SkillName.Mining].Base = tSkills[45];
newChar.Skills[SkillName.Meditation].Base = tSkills[46];
newChar.Skills[SkillName.Stealth].Base = tSkills[47];
newChar.Skills[SkillName.RemoveTrap].Base = tSkills[48];
// (these last 3 does not neccessarily exist under default POL :
newChar.Skills[SkillName.Necromancy].Base = tSkills[49];
newChar.Skills[SkillName.Focus].Base = tSkills[50];
newChar.Skills[SkillName.Chivalry].Base = tSkills[51];

// access level
if ((tmpCharCmdlevel == "test") | (tmpCharCmdlevel == "admin"))
{
newCharAcct.AccessLevel = AccessLevel.Administrator;
newChar.AccessLevel = AccessLevel.Administrator;
}

// 4. Try to add character to account:
if ((tmpCharName != "") && (tmpCharAccountString != ""))
{
int i = 0;
while (i < 5)
{
if ( newCharAcct == null )
{
from.SendMessage( 63, "Adding character " + tmpCharName + " to account "+tmpCharAccountString+"["+i+"]" );
newCharAcct = newChar;
i = 5;
characterCount++;
// create a backpack & some items for the character:
Container pack = newChar.Backpack;
if ( pack == null )
{
pack = new Backpack();
pack.Movable = false;
newChar.AddItem( pack );
}
Item2Container( new RedBook( "a book", newChar.Name, 20, true ), pack );
Item2Container( new Gold( 1000 ), pack ); // Starting gold can be customized here
Item2Container( new Dagger(), pack );
Item2Container( new Candle(), pack );
// creation successful : give the character some items ...
BankBox bank = newChar.BankBox;
bank.DropItem( new BankCheck( 1000 ) );

// hair & beard
AddRandomHair(newChar, 0x455); // some arb colour ...
AddRandomBeard(newChar, 0x455);
}
i++;
}
}
}
}
// Stop reading and close the file.
sr2Time.Close();
fs2Time.Close();

from.SendMessage( 63, "Done importing " + characterCount + " characters." );

}
}
}
[/code:1]

Here's an example from my character-data which is also the first character it imports.
[code:1]
Character
{
Account mikef
CharIdx 1
Name Joe E Bastard
Serial 0x2a0248
ObjType 0x190
Graphic 0x190
Color 0x83ea
X 1503
Y 1875
Z 5
Facing 2
CProp Fixwipe syes
CProp HighSkill i45
CProp HungerTimer i23
CProp LastLog i41050483
CProp LastTinkerItem i3854
CProp Mstats a3:i3i3i3
CProp NewRegenRateForStamina i1200
CProp OnCreate i40992582
CProp SkillArray a3:i45i37i21
CProp SkillBonus i0
CProp autoTinker i1
CProp cap_pid i2751839
CProp hunger i4
CProp lockdex i10
CProp lockint i32
CProp lockstr i51
CProp logontime i41050183
CProp mining i1
CProp onlinetimer i8892
CProp skill a50:i1i1i1i1i1i1i1i1i1i1i1i1i1i1i1i1i1i1i1i1i1i1i1i1i1i1i1i1i1i1i1i1i1i1i1i1i1i1i1i1i1i1i1i1i1i1i1i1i1i1
TrueColor 0x83ea
TrueObjtype 0x190
Gender 0
Strength 56.9
Intelligence 43.4
Dexterity 10.3
Hiding 0.1
Tinkering 50
Mining 50.1
Life 56
Mana 43
Stamina 10
CreatedAt 40992582
TitleSuffix ", Apprentice Miner"
}

Item
{
Serial 0x6cab09a9
ObjType 0x203b
Graphic 0x203b
Color 0x44e
X 0
Y 0
Z 0
CProp faceloc i11
Layer 11
Container 0x2a0248
DecayAt 40993182
}

Item
{
Serial 0x6cab09aa
ObjType 0xe75
Graphic 0xe75
X 0
Y 0
Z 0
CProp Owner i2753096
Layer 21
Container 0x2a0248
DecayAt 40993182
}
[/code:1]
 

phoenix_zhs

Wanderer
OK, I have narrowed the cause for crash down. It took me a whole day to find something so damn simple (the cause not the fix). The cause is when the script tries to add a second character to an account. I ran this script about 10 times to test my theory and its true. The first account to attempt to add a second character is right when it crashes. For the fix i am still a little clueless....maybe need to take a break and look at it again later. Any outside help would be greatly appreciated

*see code in posts above*
 
Top