| CODE |
| using System; using System.Reflection; using Server.Items; using Server.Targeting; using Server.Accounting; using System.IO; //By Delfos //Gustavo aka Gzy namespace Server.Scripts.Commands { public class scpTOxml { public static void Initialize() { Server.Commands.Register( "scpTOxml", AccessLevel.GameMaster, new CommandEventHandler( scpTOxml_OnCommand ) ); } [Description( "Transfiere cuentas de sphereaccu.scp a accounts.xml" )] private static void scpTOxml_OnCommand( CommandEventArgs e ) { MiLector (); e.Mobile.SendMessage( "Accounts.xml has been created" ); //Account a = Accounts.AddAccount( uname, password ); //a.AccessLevel = AccessLevel.Player; } private const string FILE_NAME = "sphereaccu.scp"; private const string SUB_PASS = "PASSWORD="; public static void MiLector() { if (!File.Exists(FILE_NAME)) { Console.WriteLine("{0} does not exist!", FILE_NAME); return; } StreamReader sr = File.OpenText(FILE_NAME); String input; String[] datosacco = new String[2]; int comienzo; int comienzoPass; int cantidad; while ((input=sr.ReadLine())!=null) { if ((input.IndexOf('[')) >= 0) { comienzo = input.IndexOf('[') + 1; cantidad = input.IndexOf(']') - 1; datosacco[0] = input.Substring(comienzo, cantidad); } else if ((input.LastIndexOf(SUB_PASS)) >= 0) { comienzoPass = input.LastIndexOf(SUB_PASS) + 9; datosacco[1] = input.Substring(comienzoPass); //Console.WriteLine(datosacco[0]); //Console.WriteLine(datosacco[1]); Account a = Accounts.AddAccount(datosacco[0], datosacco[1]); //a.AccessLevel = AccessLevel.Player; } } Console.WriteLine ("The end of the stream has been reached."); sr.Close(); } } } |