QUOTE (Grimhawk @ May 10, 2006 04:26 pm) |
Is it possible to remove a race system using a dov playermobile without it deleting the players chars? |
QUOTE (Grimhawk @ May 10, 2006 04:40 pm) |
Thanks Arte. Just wanted to be sure incase my race system isn't workable with the 2.0.0. update. So I might be asking for help removing it when the update is out. The only reference to the dovplayermobile is in the charcreation.cs so can you give me an idea of what all I might have to do to remove it? Thanks for the help. |
QUOTE (Grimhawk @ May 11, 2006 02:01 am) |
Thanks a bunch for the help Arte. I might have more questions if it comes to me having to do that since I've only been messing with scripts a short time off and on hopefully I won't have to. My brain sometimes just doesn't soak up knowledge as good as it used to one of the drawbacks to getting old lol. |
CODE |
using System; using System.Collections; using System.Reflection; using Server; using Server.Items; using Server.Mobiles; using Server.Network; namespace Server.Scripts.Commands { public class ConvertPlayers { public static void Initialize() { Server.Commands.Register( "ConvertPlayers", AccessLevel.Administrator, new CommandEventHandler( Convert_OnCommand ) ); } public static void Convert_OnCommand( CommandEventArgs e ) { e.Mobile.SendMessage( "Converting all players to PlayerMobile. You will be disconnected. Please Restart the server after the world has finished saving." ); ArrayList mobs = new ArrayList( World.Mobiles.Values ); int count = 0; foreach ( Mobile m in mobs ) { if ( m.Player && !(m is PlayerMobile ) ) { count++; if ( m.NetState != null ) m.NetState.Dispose(); ArcMobile pm = new PlayerMobile( m.Serial ); pm.DefaultMobileInit(); pm.DefaultPlayerMobileInit(); ArrayList copy = new ArrayList( m.Items ); for (int i=0;i<copy.Count;i++) pm.AddItem( (Item)copy[i] ); CopyProps( pm, m ); for (int i=0;i<m.Skills.Length;i++) { pm.Skills[i].Base = m.Skills[i].Base; pm.Skills[i].SetLockNoRelay( m.Skills[i].Lock ); } World.Mobiles[m.Serial] = pm; } } if ( count > 0 ) { NetState.ProcessDisposedQueue(); World.Save(); Console.WriteLine( "{0} players have been converted to PlayerMobile. Please restart the server.", count ); while ( true ) Console.ReadLine(); } else { e.Mobile.SendMessage( "Couldn't find any Players to convert." ); } } private static void CopyProps( ArcMobile to, PlayerMobile from ) { Type type = typeof( PlayerMobile ); PropertyInfo[] props = type.GetProperties( BindingFlags.Public | BindingFlags.Instance ); for (int p=0;p<props.Length;p++) { PropertyInfo prop = props[p]; if ( prop.CanRead && prop.CanWrite ) { try { prop.SetValue( to, prop.GetValue( from, null ), null ); } catch { } } } } } } |
CODE |
public void DefaultPlayerMobileInit() { m_VisList = new ArrayList(); m_PermaFlags = new ArrayList(); m_AntiMacroTable = new Hashtable(); m_BOBFilter = new Engines.BulkOrders.BOBFilter(); m_JusticeProtectors = new ArrayList(); } |
QUOTE |
public static void Convert_OnCommand( CommandEventArgs e ) { e.Mobile.SendMessage( "Converting all players to PlayerMobile. You will be disconnected. Please Restart the server after the world has finished saving." ); ArrayList mobs = new ArrayList( World.Mobiles.Values ); int count = 0; foreach ( Mobile m in mobs ) { if ( m.Player && !(m is PlayerMobile ) ) |
CODE |
public void DefaultPlayerMobileInit() { m_VisList = new ArrayList(); m_PermaFlags = new ArrayList(); m_AntiMacroTable = new Hashtable(); m_BOBFilter = new Engines.BulkOrders.BOBFilter(); m_JusticeProtectors = new ArrayList(); } |
CODE |
using System; using System.Collections; using System.Reflection; using Server; using Server.Items; using Server.Mobiles; using Server.Network; namespace Server.Scripts.Commands { public class ConvertPlayers { public static void Initialize() { Server.Commands.Register( "ConvertPlayers", AccessLevel.Administrator, new CommandEventHandler( Convert_OnCommand ) ); } public static void Convert_OnCommand( CommandEventArgs e ) { e.Mobile.SendMessage( "Converting all players to PlayerMobile. You will be disconnected. Please Restart the server after the world has finished saving." ); ArrayList mobs = new ArrayList( World.Mobiles.Values ); int count = 0; foreach ( Mobile m in mobs ) { if ( m.Player && !(m is ArcMobile ) ) { count++; if ( m.NetState != null ) m.NetState.Dispose(); PlayerMobile pm = new PlayerMobile( m.Serial ); pm.DefaultMobileInit(); pm.DefaultPlayerMobileInit(); ArrayList copy = new ArrayList( m.Items ); for (int i=0;i<copy.Count;i++) pm.AddItem( (Item)copy[i] ); CopyProps( pm,(PlayerMobile )m ); for (int i=0;i<m.Skills.Length;i++) { pm.Skills[i].Base = m.Skills[i].Base; pm.Skills[i].SetLockNoRelay( m.Skills[i].Lock ); } World.Mobiles[m.Serial] = pm; } } if ( count > 0 ) { NetState.ProcessDisposedQueue(); World.Save(); Console.WriteLine( "{0} players have been converted to PlayerMobile. Please restart the server.", count ); while ( true ) Console.ReadLine(); } else { e.Mobile.SendMessage( "Couldn't find any Players to convert." ); } } private static void CopyProps( PlayerMobile to, PlayerMobile from ) { Type type = typeof( PlayerMobile ); PropertyInfo[] props = type.GetProperties( BindingFlags.Public | BindingFlags.Instance ); for (int p=0;p<props.Length;p++) { PropertyInfo prop = props[p]; if ( prop.CanRead && prop.CanWrite ) { try { prop.SetValue( to, prop.GetValue( from, null ), null ); } catch { } } } } } } |