5165 robots ?

03/23/2010 22:57 .Kob#1
Sorry, i fixed that xD
#request close

I'm trying to run the robots so I have understood is simply to a character without the sequence of login, only with a command. And this is what came in the original source:

Code:
if (Cmd[0] == "@robot")
                        {
                            string Account = "";
                            string Name = Cmd[1];

                            if (Game.World.CharacterFromName(Name) == null)
                            {
                                Game.Robot R = Database.LoadAsRobot(Name, ref Account);
                                if (R != null)
                                    R.Init(Account);
                            }
                        }
And this one too but is the same...:

Code:
if (Cmd[0] == "@robot1")
                        {
                            string Account = "";
                            string Name = Cmd[1];

                            Game.Robot R = Database.LoadAsRobot(Name, ref Account);
                            if (R != null)
                                R.Init(Account);

                        }
Then, this give me errors in the console and no, not log the character. I tested changing the comand, deleting a few loading thinks but not work.. Here is the login for robots: (in Database.cs):

Code:
public static Game.Robot LoadAsRobot(string Name, ref string Account)
        
        {
            try
            {
                Game.Robot C = new NewestCOServer.Game.Robot();
                if (File.Exists(@"C:\OldCODB\Users\Characters\" + Name + ".chr"))
                {
                    FileStream FS = new FileStream(@"C:\OldCODB\Users\Characters\" + Name + ".chr", FileMode.Open);
                    BinaryReader BR = new BinaryReader(FS);
                    C.Name = Name;
                    Account = BR.ReadString();
                    C.EntityID = BR.ReadUInt32();
                    C.Avatar = BR.ReadUInt16();
                    C.Body = BR.ReadUInt16();
                    C.Hair = BR.ReadUInt16();

                    C.Loc = new NewestCOServer.Game.Location();
                    C.Loc.Map = BR.ReadUInt16();
                    C.Loc.X = BR.ReadUInt16();
                    C.Loc.Y = BR.ReadUInt16();
                    C.Loc.PreviousMap = BR.ReadUInt16();

                    C.Job = BR.ReadByte();
                    C.PreviousJob1 = BR.ReadByte();
                    C.PreviousJob2 = BR.ReadByte();
                    C.Level = BR.ReadByte();
                    C.Experience = BR.ReadUInt64();

                    C.Str = BR.ReadUInt16();
                    C.Agi = BR.ReadUInt16();
                    C.Vit = BR.ReadUInt16();
                    C.Spi = BR.ReadUInt16();
                    C.StatPoints = BR.ReadUInt16();
                    C.CurHP = BR.ReadUInt16();
                    C.CurMP = BR.ReadUInt16();
                    C.Donation = BR.ReadUInt32();
                    C.Silvers = BR.ReadUInt32();
                    C.CPs = BR.ReadUInt32();
                    C.WHSilvers = BR.ReadUInt32();
                    C.VP = BR.ReadUInt64();
                    C.PKPoints = BR.ReadUInt16();
                    ushort GID = BR.ReadUInt16();

                    if (Features.Guilds.AllTheGuilds.Contains(GID))
                    {
                        C.MyGuild = (Features.Guild)Features.Guilds.AllTheGuilds[GID];

                        uint Don = BR.ReadUInt32(); ;
                        byte GR = BR.ReadByte();
                        if (((Hashtable)C.MyGuild.Members[GR]).Contains(C.EntityID))
                        {
                            C.GuildDonation = Don;
                            C.GuildRank = (Features.GuildRank)GR;

                            C.MembInfo = (Features.MemberInfo)((Hashtable)C.MyGuild.Members[GR])[C.EntityID];
                            C.MembInfo.Level = C.Level;
                            C.GuildDonation = C.MembInfo.Donation;
                            C.GuildRank = C.MembInfo.Rank;
                        }
                        else
                            C.MyGuild = null;
                    }
                    else BR.ReadBytes(5);

                    C.Equips = new NewestCOServer.Game.Equipment();
                    C.Equips.ReadThis(BR);
                    C.Inventory = new ArrayList(40);
                    byte InventoryCount = BR.ReadByte();
                    for (byte i = 0; i < InventoryCount; i++)
                    {
                        Game.Item I = new NewestCOServer.Game.Item();
                        I.ReadThis(BR);
                        C.Inventory.Add(I);
                    }
                    C.Warehouses = new NewestCOServer.Game.Banks();
                    C.Warehouses.ReadThis(BR);

                    C.Skills = new Hashtable();
                    byte SkillCount = BR.ReadByte();
                    for (byte i = 0; i < SkillCount; i++)
                    {
                        Game.Skill S = new NewestCOServer.Game.Skill();
                        S.ReadThis(BR);
                        C.Skills.Add(S.ID, S);
                    }

                    C.Profs = new Hashtable();
                    byte ProfCount = BR.ReadByte();
                    for (byte i = 0; i < ProfCount; i++)
                    {
                        Game.Prof P = new NewestCOServer.Game.Prof();
                        P.ReadThis(BR);
                        if (!C.Profs.Contains(P.ID))
                            C.Profs.Add(P.ID, P);
                    }

                    C.Friends = new Hashtable();
                    byte FriendCount = BR.ReadByte();
                    for (byte i = 0; i < FriendCount; i++)
                    {
                        Game.Friend F = new NewestCOServer.Game.Friend();
                        F.ReadThis(BR);
                        if (!C.Friends.Contains(F.UID))
                            C.Friends.Add(F.UID, F);
                    }

                    C.Enemies = new Hashtable();
                    byte EnemyCount = BR.ReadByte();
                    for (byte i = 0; i < EnemyCount; i++)
                    {
                        Game.Enemy E = new NewestCOServer.Game.Enemy();
                        E.ReadThis(BR);
                        if (!C.Enemies.Contains(E.UID))
                            C.Enemies.Add(E.UID, E);
                    }
                   
                    try
                    {
                       
                        C.DoubleExp = BR.ReadBoolean();
                        C.DoubleExpLeft = BR.ReadInt32();
                        C.BlessingLasts = BR.ReadInt32();
                        C.BlessingStarted = DateTime.FromBinary(BR.ReadInt64());
                        C.PrayTimeLeft = BR.ReadInt32();
                        C.ExpBallsUsedToday = BR.ReadByte();
                        C.Reborns = BR.ReadByte();
                        C.Merchant = (NewestCOServer.Game.MerchantTypes)BR.ReadByte();
                        C.VipLevel = BR.ReadByte();
                        try
                        {
                            C.LastLogin = DateTime.FromBinary(BR.ReadInt64());
                        }
                        catch { C.LastLogin = DateTime.Now; }
                        C.TrainTimeLeft = BR.ReadUInt16();
                        C.InOTG = BR.ReadBoolean();
                        C.LotteryUsed = BR.ReadByte();

                        try
                        {
                            C.WHPassword = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte()));

                            if (!C.MyClient.ValidWHPass(C.WHPassword))
                                C.WHPassword = "0";
                            C.Spouse = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte()));
                            C.UniversityPoints = BR.ReadUInt32();
                            C.Top = BR.ReadInt32();
                        }
                        catch
                        {
                            C.VipLevel = 0;
                            C.ExpBallsUsedToday = 0;
                            C.LotteryUsed = 0;
                            C.TrainTimeLeft = 0;
                            C.InOTG = false;
                            C.LotteryUsed = 0;
                            C.WHPassword = "0";
                            C.Spouse = "None";
                        } 
                    }
                    catch { }
                    FS.Flush();
                    BR.Close();
                    FS.Close();
                    C.Loaded = true;
                    if (C.Top == 10)
                    {
                        C.StatEff.Add(StatusEffectEn.WeeklyPKChampion);
                    }
                }
                return C;
            }
            catch (Exception Exc) { Console.WriteLine(Exc); return null; }
        }
And here the Init (in Robot.cs):

Code:
public void Init(string acc)
        {
            if (SearchingLevPlace == true)
            { }
            MyClient = new NewestCOServer.Main.GameClient(true);
            MyClient.Robot = true;
            MyClient.AuthInfo.Account = acc;
            MyClient.MyChar = this;

            if (Equips.RightHand.ID != 0)
            {
                if (ItemIDManipulation.Part(Equips.RightHand.ID, 0, 3) == 500)
                    AtkMem.AtkType = 28;
                else
                    AtkMem.AtkType = 2;
            }
            else
                AtkMem.AtkType = 2;
            Equips.Send(MyClient, true);

            LoggedOn = DateTime.Now;

            if (DoubleExp && DoubleExpLeft > 0)
                ExpPotionUsed = DateTime.Now;
            else
                DoubleExp = false;

            if (BlessingLasts > 0 && InOTG)
            {
                InOTG = false;
                ushort MinutesTrained = (ushort)((LoggedOn - LastLogin).TotalMinutes);
                uint ExpAdd = (uint)(ExpBallExp * ((double)MinutesTrained / 900));
                ExpAdd *= Game.World.ExperienceRate;
                IncreaseExp(ExpAdd, false);
                TrainTimeLeft -= MinutesTrained;
            }

            if (!Game.World.H_Chars.Contains(EntityID))
            {
                Game.World.H_Chars.Add(EntityID, this);
                Game.World.Spawns(this, false);
            }
        }

I need help for know how to repair this and can create robots =)

Thanks and sorry about my english, i'm spanish :facepalm:
03/24/2010 11:16 Huseby#2
#Closed