Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Private Server
You last visited: Today at 14:40

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



could any one tell me how to fix this error in Program.cs ?

Discussion on could any one tell me how to fix this error in Program.cs ? within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
alielmasry's Avatar
 
elite*gold: 0
Join Date: Mar 2009
Posts: 49
Received Thanks: 15
could any one tell me how to fix this error in Program.cs ?

could any one tell me how to fix this error in Program.cs ?

PHP Code:
using System.Threading;
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using NewestCOServer.Game;
namespace 
NewestCOServer
{
    class 
Program
    
{

        public static 
void WriteLine(Exception Exc)
        {
            
Console.WriteLine(Exc.ToString());

            try
            {
                if (!
System.IO.File.Exists("debug." DateTime.Now.Month.ToString() + "." DateTime.Now.Day.ToString() + ".txt"))
                    
System.IO.File.Create("debug." DateTime.Now.Month.ToString() + "." DateTime.Now.Day.ToString() + ".txt").Close();
                
string Text System.IO.File.ReadAllText("debug." DateTime.Now.Month.ToString() + "." DateTime.Now.Day.ToString() + ".txt");
                
Text += Exc.ToString() + "\r\n";
                
System.IO.File.WriteAllText("debug." DateTime.Now.Month.ToString() + "." DateTime.Now.Day.ToString() + ".txt"Text);
            }
            catch { }
        }
        public static 
void WriteLine(string Line)
        {
            try
            {
                
Console.WriteLine(Line);
                if (!
System.IO.File.Exists("debug." DateTime.Now.Month.ToString() + "." DateTime.Now.Day.ToString() + ".txt"))
                    
System.IO.File.Create("debug." DateTime.Now.Month.ToString() + "." DateTime.Now.Day.ToString() + ".txt").Close();
                
string Text System.IO.File.ReadAllText("debug." DateTime.Now.Month.ToString() + "." DateTime.Now.Day.ToString() + ".txt");
                
Text += Line "\r\n";
                
System.IO.File.WriteAllText("debug." DateTime.Now.Month.ToString() + "." DateTime.Now.Day.ToString() + ".txt"Text);
            }
            catch { }
        }
        public static 
void WriteLine()
        {
            try
            {
                
Console.WriteLine();
                if (!
System.IO.File.Exists("debug." DateTime.Now.Month.ToString() + "." DateTime.Now.Day.ToString() + ".txt"))
                    
System.IO.File.Create("debug." DateTime.Now.Month.ToString() + "." DateTime.Now.Day.ToString() + ".txt").Close();
                
string Text System.IO.File.ReadAllText("debug." DateTime.Now.Month.ToString() + "." DateTime.Now.Day.ToString() + ".txt");
                
Text += "\r\n";
                
System.IO.File.WriteAllText("debug." DateTime.Now.Month.ToString() + "." DateTime.Now.Day.ToString() + ".txt"Text);
            }
            catch { }
        }
        public static 
bool EndSession false;
        public static 
double SaveOldRate 0;
        public static 
string DropEventType "";
        public static 
System.Timers.Timer DropEventTimer null;
        public static 
DateTime SystemMsgTime = new DateTime();
        public static 
Random Rnd = new Random();
        public static 
string ConquerPath;
        public static 
Features.QuizShow.MainInfo MainQuizShowInfo;
        static 
void Main(string[] args)

        {
            
Console.Title "Newest CO Server";
            if (
System.IO.Directory.Exists(@"C:\OldCODB"))
            {
                
IniFile I = new IniFile(@"C:\OldCODB\Config.ini");
                
ConquerPath I.ReadString("Database""ConquerPath");
                
Database.DefaultCoords.Add((ushort)1002, new Game.Vector2() { 430380 });
                
Database.DefaultCoords.Add((ushort)1015, new Game.Vector2() { 717571 });
                
Database.DefaultCoords.Add((ushort)1000, new Game.Vector2() { 500650 });
                
Database.DefaultCoords.Add((ushort)1011, new Game.Vector2() { 188264 });
                
Database.DefaultCoords.Add((ushort)1020, new Game.Vector2() { 565562 });
                
Database.AddSkills();
                
Database.LoadItems();                
                
Database.LoadPlusInfo();
                
Database.LoadRevPoints();
                
Database.LoadProfExp();
                
Database.LoadPortals();
                
Database.LoadLevelExp();
                
Database.LoadNPCs();
                
Database.LoadShops();
                
DropRates.Load();
                
Database.ReadAllCharacterStats();
                
Database.LoadKOs();
                
Features.SkillsClass.Load();
                
Features.Guilds.LoadGuilds();
                
DMaps.Load();
                
Database.LoadMobs();
                
Database.LoadCompanions();
                
Features.GuildWars.Init();
                
MainQuizShowInfo = new Features.QuizShow.MainInfo();
                
#region Spawns for robot
                
Game.World.MapDetails = new System.Collections.Hashtable();
                
Game.MapInfo M = new NewestCOServer.Game.MapInfo();
                
M.Spawns = new NewestCOServer.Game.Vector2[5];
                
M.Spawns[0].465;
                
M.Spawns[0].462;
                
M.Spawns[1].604;
                
M.Spawns[1].537;
                
M.Spawns[2].527;
                
M.Spawns[2].701;
                
M.Spawns[3].373;
                
M.Spawns[3].634;
                
M.Spawns[4].141;
                
M.Spawns[4].436;
                
Game.World.MapDetails.Add((ushort)1002M);

                
= new NewestCOServer.Game.MapInfo();
                
M.Spawns = new NewestCOServer.Game.Vector2[4];
                
M.Spawns[0].390;
                
M.Spawns[0].118;
                
M.Spawns[1].359;
                
M.Spawns[1].284;
                
M.Spawns[2].590;
                
M.Spawns[2].337;
                
M.Spawns[3].620;
                
M.Spawns[3].776;
                
Game.World.MapDetails.Add((ushort)1011M);

                
= new NewestCOServer.Game.MapInfo();
                
M.Spawns = new NewestCOServer.Game.Vector2[4];
                
M.Spawns[0].656;
                
M.Spawns[0].635;
                
M.Spawns[1].500;
                
M.Spawns[1].279;
                
M.Spawns[2].289;
                
M.Spawns[2].209;
                
M.Spawns[3].188;
                
M.Spawns[3].457;
                
Game.World.MapDetails.Add((ushort)1020M);

                
= new NewestCOServer.Game.MapInfo();
                
M.Spawns = new NewestCOServer.Game.Vector2[4];
                
M.Spawns[0].606;
                
M.Spawns[0].637;
                
M.Spawns[1].607;
                
M.Spawns[1].500;
                
M.Spawns[2].451;
                
M.Spawns[2].358;
                
M.Spawns[3].186;
                
M.Spawns[3].352;
                
Game.World.MapDetails.Add((ushort)1000M);

                
= new NewestCOServer.Game.MapInfo();
                
M.Spawns = new NewestCOServer.Game.Vector2[4];
                
M.Spawns[0].722;
                
M.Spawns[0].669;
                
M.Spawns[1].519;
                
M.Spawns[1].710;
                
M.Spawns[2].514;
                
M.Spawns[2].539;
                
M.Spawns[3].312;
                
M.Spawns[3].572;
                
Game.World.MapDetails.Add((ushort)1015M);

                
= new NewestCOServer.Game.MapInfo();
                
M.Spawns = new NewestCOServer.Game.Vector2[4];
                
M.Spawns[0].328;
                
M.Spawns[0].616;
                
M.Spawns[1].338;
                
M.Spawns[1].438;
                
M.Spawns[2].102;
                
M.Spawns[2].297;
                
M.Spawns[3].352;
                
M.Spawns[3].286;
                
Game.World.MapDetails.Add((ushort)1001M); 
                
#endregion

                
NewestCOServer.Main.AuthWorker.StartServer(I.ReadString("Database""GameServerIP"));
                
NewestCOServer.Main.GameWorker.StartServer();
                
Database.LoadLottoItems();
                
Program.WriteLine();
                
Program.WriteLine("The server is ready for connections.");
                
Program.WriteLine("Always close the server by pressing Enter, or the important data wont't save.");
                
Database.LoadQuestions();
                
Database.CreateEquipsDrops();
                
Database.LoadEmpire();
                
MyThread CompanionThread = new MyThread();
                
CompanionThread.Execute += new Execute(CompanionThread_Execute);
                
CompanionThread.Start(100);
                
MyThread ServerStuff = new MyThread();
                
ServerStuff.Execute += new Execute(ServerStuff_Execute);
                
ServerStuff.Start(100);
                
MyThread MobThread = new MyThread();
                
MobThread.Execute += new Execute(MobThread_Execute);
                
MobThread.Start(100);
                
World.MobsStart true;
                while (
true)
                {
                    
string Command Console.ReadLine();
                    
string[] Cmd Command.Split(' ');

                    if (
Command == "")
                    {
                        
Console.ReadLine();
                    }
                    if (
Cmd[0] == "/restart")
                    {
                        
Game.Character[] BaseCharacters = new Character[World.H_Chars.Count];
                        
World.H_Chars.Values.CopyTo(BaseCharacters0);

                        
NewestCOServer.Main.AuthWorker.Listener.Close();
                        
NewestCOServer.Main.GameWorker.Listener.Close();
                        
EndSession true;
                        try
                        {
                            foreach (
Game.Character C in BaseCharacters)
                            {
                                try
                                {
                                    
C.MyClient.Disconnect();
                                    
Console.WriteLine(C.Name " has logged off successfuly.");
                                }
                                catch { continue; }
                            }
                        }
                        catch { }
                        
Database.SaveKOs();
                        
Console.WriteLine("KOs saved.");
                        
Database.SaveEmpire();
                        
Console.WriteLine("Empire saved.");
                        
Features.Guilds.SaveGuilds();
                        
Console.WriteLine("Guilds saved.");
                        
Features.SkillsClass.Save();
                        
Console.WriteLine("Skills saved.");
                        
                        
MobThread.Close();
                        
ServerStuff.Close();
                        
CompanionThread.Close();
                        
Database.Dispose();
                        
Console.WriteLine("Database disposed.");
                        
Console.WriteLine("Write /exit or click X to close the window.");
                        
System.Diagnostics.Process.Start("NewestCOServer.exe");
                    }
                    if (
Cmd[0] == "/exit")
                    {
                        
Game.Character[] BaseCharacters = new Character[World.H_Chars.Count];
                        
World.H_Chars.Values.CopyTo(BaseCharacters0);
                        
NewestCOServer.Main.AuthWorker.Listener.Close();
                        
NewestCOServer.Main.GameWorker.Listener.Close();
                        
EndSession true;
                        try
                        {
                            foreach (
Game.Character C in BaseCharacters)
                            {
                                try
                                {
                                    
C.MyClient.Disconnect();
                                    
Console.WriteLine(C.Name " has logged off successfuly.");
                                }
                                catch { continue; }
                            }
                        }
                        catch { }
                        
Database.SaveKOs();
                        
Console.WriteLine("KOs saved.");
                        
Database.SaveEmpire();
                        
Console.WriteLine("Empire saved.");
                        
Features.Guilds.SaveGuilds();
                        
Console.WriteLine("Guilds saved.");
                        
Features.SkillsClass.Save();
                        
Console.WriteLine("Skills saved.");
                        
                        
MobThread.Close();
                        
ServerStuff.Close();
                        
CompanionThread.Close();
                        
Database.Dispose();
                        
Console.WriteLine("Database disposed.");
                        
Console.WriteLine("Click X to close the window.");
                    }
                    if (
Cmd[0] == "/expballs")
                        
Database.ExpBallReset();
                    if (
Cmd[0] == "/expballs2")
                        
Database.ExpBallReset();
                    if (
Cmd[0] == "/clear")
                        
Console.Clear();
                    if (
Cmd[0] == "/newacc" && Cmd.Length 2)
                    {
                        if (
Cmd.Length == 3)
                            
Database.CreateAccount(Cmd[1], Cmd[2], "");
                        else
                            
Database.CreateAccount(Cmd[1], Cmd[2], Cmd[3]);
                    }
                    if (
Cmd[0] == "/skilladder")
                    {
                        
Extra.SkillAdder E = new NewestCOServer.Extra.SkillAdder();
                        
System.Windows.Forms.Application.Run(E);
                    }
                    if (
Cmd[0] == "/characters")
                    {
                        
Form1 E = new Form1();
                        
System.Windows.Forms.Application.Run(E);
                    }
                    if (
Cmd[0] == "/accounts")
                    {
                        
Form2 E = new Form2();
                        
System.Windows.Forms.Application.Run(E);
                    }
                }
            }
            else
            {
                
Program.WriteLine("The database folder doesn't exist, cannot start the server.");
                
Console.ReadLine();
            }
        }
        static 
void MobThread_Execute()
        {
            try
            {
                if (
World.H_Chars.Count 0)
                {
                    try
                    {
                        foreach (
Hashtable H in Game.World.H_Mobs.Values)
                        {
                            foreach (
Mob M in H.Values)
                            {
                                
M.Step();

                                if (
M.PoisonedInfo != null)
                                {
                                    if (
DateTime.Now M.PoisonedInfo.LastAttack.AddSeconds(3))
                                    {
                                        if (
M.CurrentHP == 1)
                                        {
                                            
M.PoisonedInfo null;
                                            foreach (
Game.Character C in Game.World.H_Chars.Values)
                                                if (
M.Loc.Map == C.Loc.Map)
                                                    if (
MyMath.PointDistance(M.Loc.XM.Loc.YC.Loc.XC.Loc.Y) <= 20)
                                                        
C.MyClient.AddSend(Packets.Status(M.EntityIDNewestCOServer.Game.Status.Effect0));
                                            continue;
                                        }
                                        
M.PoisonedInfo.Times--;
                                        
M.PoisonedInfo.LastAttack DateTime.Now;
                                        
uint Dmg = (uint)(M.CurrentHP * (10 M.PoisonedInfo.SpellLevel 10) / 100);
                                        if (
Dmg == 1)
                                            continue;
                                        
M.TakeAttack(MDmgAttackType.Melee);
                                        if (
M.PoisonedInfo.Times == 0)
                                        {
                                            
M.PoisonedInfo null;
                                            foreach (
Game.Character C in Game.World.H_Chars.Values)
                                                if (
M.Loc.Map == C.Loc.Map)
                                                    if (
MyMath.PointDistance(M.Loc.XM.Loc.YC.Loc.XC.Loc.Y) <= 20)
                                                        
C.MyClient.AddSend(Packets.Status(M.EntityIDNewestCOServer.Game.Status.Effect0));
                                        }
                                    }
                                }
                            }
                        }
                    }
                    catch (
Exception Exc) { Program.WriteLine(Exc); }
                }
            }
            catch (
Exception Exc) { Program.WriteLine(Exc); }
        }
        static 
bool ExpBallClear false;
        static 
void ServerStuff_Execute()
        {
            try
            {
                if (
DateTime.Now SystemMsgTime.AddMinutes(1))
                {
                    
Handle_Events();
                    
SystemMsgTime DateTime.Now;
                }
                if (
World.BroadCastCount && DateTime.Now World.LastBroadCast.AddMinutes(1))
                {
                    
BroadCastMessage B World.BroadCasts[0];

                    for (
int i 0World.BroadCastCounti++)
                        
World.BroadCasts[i] = World.BroadCasts[1];

                    
World.BroadCastCount--;

                    
World.SendMsgToAll(B.NameB.Message25000);
                    
World.LastBroadCast DateTime.Now;
                    
World.CurrentBC B;
                }
            }
            catch { }
            try
            {
                foreach (
Hashtable H in World.H_Items.Values)
                {
                    
ArrayList Deleted = new ArrayList();
                    try
                    {
                        foreach (
DroppedItem I in H.Values)
                            if (
DateTime.Now I.DropTime.AddSeconds(60))
                                
Deleted.Add(I);
                        foreach (
DroppedItem I in Deleted)
                            
I.Dissappear();
                    }
                    catch { }
                }
            }
            catch { }
            try
            {
                
//if (!Features.GuildWars.War && DateTime.Now.Minute == 0 && Database.GWOn.Contains(DateTime.Now.Hour))
                //    Features.GuildWars.StartWar();
            
}
            catch { }
            try
            {
                
//if (Features.GuildWars.War && DateTime.Now > Features.GuildWars.LastScores.AddSeconds(5))
                //    Features.GuildWars.SendScores();
            
}
            catch { }
            try
            {
                if (
DateTime.Now.Hour == && !ExpBallClear)
                {
                    
Database.ExpBallReset();
                    
ExpBallClear true;
                }
                if (
ExpBallClear && DateTime.Now.Hour == 1)
                    
ExpBallClear false;
            }
            catch { }
        }
        static 
void Handle_Events()
        {
            switch (
DateTime.Now.Minute)
            {
                case 
7:
                case 
8:
                    
Game.World.SendMsgToAll("GM""GMs have [GM] or [PM] at the end of their names. Don`t trust anyone claiming to be a GM but not having [GM]/[PM] in their names."20110);
                    break;
                case 
19:
                case 
20:
                    
Game.World.SendMsgToAll("GM""File account problems and TQ Point Card purchase problems at SUPPORT on the official site."20110);
                    break;
                case 
31:
                case 
32:
                    
Game.World.SendMsgToAll("GM""Help UnknownMan at Market (212,204) to level up quickly."20110);
                    break;
                case 
43:
                case 
44:
                    
Game.World.SendMsgToAll("GM""Trading of game accounts is illegal and may result in the instant banning of the accounts involved in the trading."20110);
                    break;
                case 
55:
                case 
56:
                    
Game.World.SendMsgToAll("GM""co.91.com is the only official website of CO, which is also the only website where you can purchase Dragonballs."20110);
                    break;
                default:
                    break;
            }
        }
        
        static 
void CompanionThread_Execute()
        {
            try
            {
                if (
World.H_Chars.Count 0)
                {
                    foreach (
Companion C in World.H_Companions.Values)
                        try
                        {
                            
C.Step();
                        }
                        catch { }
                }
            }
            catch { }
        }
        public static 
void QuestDropDone(object sourceSystem.Timers.ElapsedEventArgs e)
        {
            try
            {
                if (
DropEventTimer != null)
                {
                    if (
DropEventType == "dragonball")
                        
DropRates.DragonBall SaveOldRate;
                    else if (
DropEventType == "meteor")
                        
DropRates.Meteor SaveOldRate;
                    else if (
DropEventType == "minicpbag")
                        
DropRates.CPMiniBag SaveOldRate;
                    else if (
DropEventType == "cpbag")
                        
DropRates.CPBag SaveOldRate;

                    
Game.World.SendMsgToAll("Server""Drop " DropEventType "s event ended."20010);
                    
DropEventType ""SaveOldRate 0;
                    
DropEventTimer.Stop();
                    
DropEventTimer.Close();
                    
DropEventTimer null;

            try 
            { 
                if (
DateTime.Now Features.DMScore.LastScores.AddSeconds(1)) 
                    
Features.DMScore.SendScores(); 
            }
            catch { }
        }
    }
}                   <<<<<<<<<<<<<  
im getting error here in this mark 
so what i need to change/edit ?

and here is da pic

alielmasry is offline  
Old 03/04/2010, 16:14   #2
 
elite*gold: 0
Join Date: Mar 2010
Posts: 42
Received Thanks: 3
What code did you add in order to get this error?
.Roach is offline  
Old 03/04/2010, 16:22   #3
 
alielmasry's Avatar
 
elite*gold: 0
Join Date: Mar 2009
Posts: 49
Received Thanks: 15
Quote:
Originally Posted by .Roach View Post
What code did you add in order to get this error?

this code in down of page : for DeathTeam Game
PHP Code:
            try  
            {  
                if (
DateTime.Now Features.DMScore.LastScores.AddSeconds(1))  
                    
Features.DMScore.SendScores();  
            }
            catch { }
        }
    }

alielmasry is offline  
Old 03/04/2010, 16:24   #4
 
ImFlamedCOD's Avatar
 
elite*gold: 0
Join Date: Jun 2009
Posts: 378
Received Thanks: 141
Delete the last 3 } and replace them, usually what the problem is that u need a 4th } and that seems to be the case here i believe.
Yea your missing some } that is all it is.
ImFlamedCOD is offline  
Old 03/04/2010, 16:33   #5
 
alielmasry's Avatar
 
elite*gold: 0
Join Date: Mar 2009
Posts: 49
Received Thanks: 15
Quote:
Originally Posted by ImFlamedCOD View Post
Delete the last 3 } and replace them, usually what the problem is that u need a 4th } and that seems to be the case here i believe.
Yea your missing some } that is all it is.

look at this pic and tell me what i need to add again O.o

alielmasry is offline  
Old 03/04/2010, 16:53   #6
 
elite*gold: 0
Join Date: Mar 2010
Posts: 42
Received Thanks: 3
Delete that code.

Search for:
Code:
public static void WriteLine(string Line)
        {
Add this under it:
Code:
try
            {
                if (DateTime.Now > Features.DMScore.LastScores.AddSeconds(1))
                    Features.DMScore.SendScores();
            }
            catch { }
That should work.
.Roach is offline  
Old 03/04/2010, 16:54   #7
 
ImFlamedCOD's Avatar
 
elite*gold: 0
Join Date: Jun 2009
Posts: 378
Received Thanks: 141
Code:
using System.Threading; 
using System; 
using System.Collections.Generic; 
using System.Collections; 
using System.Linq; 
using System.Text; 
using NewestCOServer.Game; 
namespace NewestCOServer 
{ 
    class Program 
    { 

        public static void WriteLine(Exception Exc) 
        { 
            Console.WriteLine(Exc.ToString()); 

            try 
            { 
                if (!System.IO.File.Exists("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt")) 
                    System.IO.File.Create("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt").Close(); 
                string Text = System.IO.File.ReadAllText("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt"); 
                Text += Exc.ToString() + "\r\n"; 
                System.IO.File.WriteAllText("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt", Text); 
            } 
            catch { } 
        } 
        public static void WriteLine(string Line) 
        { 
            try 
            { 
                Console.WriteLine(Line); 
                if (!System.IO.File.Exists("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt")) 
                    System.IO.File.Create("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt").Close(); 
                string Text = System.IO.File.ReadAllText("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt"); 
                Text += Line + "\r\n"; 
                System.IO.File.WriteAllText("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt", Text); 
            } 
            catch { } 
        } 
        public static void WriteLine() 
        { 
            try 
            { 
                Console.WriteLine(); 
                if (!System.IO.File.Exists("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt")) 
                    System.IO.File.Create("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt").Close(); 
                string Text = System.IO.File.ReadAllText("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt"); 
                Text += "\r\n"; 
                System.IO.File.WriteAllText("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt", Text); 
            } 
            catch { } 
        } 
        public static bool EndSession = false; 
        public static double SaveOldRate = 0; 
        public static string DropEventType = ""; 
        public static System.Timers.Timer DropEventTimer = null; 
        public static DateTime SystemMsgTime = new DateTime(); 
        public static Random Rnd = new Random(); 
        public static string ConquerPath; 
        public static Features.QuizShow.MainInfo MainQuizShowInfo; 
        static void Main(string[] args) 

        { 
            Console.Title = "Newest CO Server"; 
            if (System.IO.Directory.Exists(@"C:\OldCODB")) 
            { 
                IniFile I = new IniFile(@"C:\OldCODB\Config.ini"); 
                ConquerPath = I.ReadString("Database", "ConquerPath"); 
                Database.DefaultCoords.Add((ushort)1002, new Game.Vector2() { X = 430, Y = 380 }); 
                Database.DefaultCoords.Add((ushort)1015, new Game.Vector2() { X = 717, Y = 571 }); 
                Database.DefaultCoords.Add((ushort)1000, new Game.Vector2() { X = 500, Y = 650 }); 
                Database.DefaultCoords.Add((ushort)1011, new Game.Vector2() { X = 188, Y = 264 }); 
                Database.DefaultCoords.Add((ushort)1020, new Game.Vector2() { X = 565, Y = 562 }); 
                Database.AddSkills(); 
                Database.LoadItems();                 
                Database.LoadPlusInfo(); 
                Database.LoadRevPoints(); 
                Database.LoadProfExp(); 
                Database.LoadPortals(); 
                Database.LoadLevelExp(); 
                Database.LoadNPCs(); 
                Database.LoadShops(); 
                DropRates.Load(); 
                Database.ReadAllCharacterStats(); 
                Database.LoadKOs(); 
                Features.SkillsClass.Load(); 
                Features.Guilds.LoadGuilds(); 
                DMaps.Load(); 
                Database.LoadMobs(); 
                Database.LoadCompanions(); 
                Features.GuildWars.Init(); 
                MainQuizShowInfo = new Features.QuizShow.MainInfo(); 
                #region Spawns for robot 
                Game.World.MapDetails = new System.Collections.Hashtable(); 
                Game.MapInfo M = new NewestCOServer.Game.MapInfo(); 
                M.Spawns = new NewestCOServer.Game.Vector2[5]; 
                M.Spawns[0].X = 465; 
                M.Spawns[0].Y = 462; 
                M.Spawns[1].X = 604; 
                M.Spawns[1].Y = 537; 
                M.Spawns[2].X = 527; 
                M.Spawns[2].Y = 701; 
                M.Spawns[3].X = 373; 
                M.Spawns[3].Y = 634; 
                M.Spawns[4].X = 141; 
                M.Spawns[4].Y = 436; 
                Game.World.MapDetails.Add((ushort)1002, M); 

                M = new NewestCOServer.Game.MapInfo(); 
                M.Spawns = new NewestCOServer.Game.Vector2[4]; 
                M.Spawns[0].X = 390; 
                M.Spawns[0].Y = 118; 
                M.Spawns[1].X = 359; 
                M.Spawns[1].Y = 284; 
                M.Spawns[2].X = 590; 
                M.Spawns[2].Y = 337; 
                M.Spawns[3].X = 620; 
                M.Spawns[3].Y = 776; 
                Game.World.MapDetails.Add((ushort)1011, M); 

                M = new NewestCOServer.Game.MapInfo(); 
                M.Spawns = new NewestCOServer.Game.Vector2[4]; 
                M.Spawns[0].X = 656; 
                M.Spawns[0].Y = 635; 
                M.Spawns[1].X = 500; 
                M.Spawns[1].Y = 279; 
                M.Spawns[2].X = 289; 
                M.Spawns[2].Y = 209; 
                M.Spawns[3].X = 188; 
                M.Spawns[3].Y = 457; 
                Game.World.MapDetails.Add((ushort)1020, M); 

                M = new NewestCOServer.Game.MapInfo(); 
                M.Spawns = new NewestCOServer.Game.Vector2[4]; 
                M.Spawns[0].X = 606; 
                M.Spawns[0].Y = 637; 
                M.Spawns[1].X = 607; 
                M.Spawns[1].Y = 500; 
                M.Spawns[2].X = 451; 
                M.Spawns[2].Y = 358; 
                M.Spawns[3].X = 186; 
                M.Spawns[3].Y = 352; 
                Game.World.MapDetails.Add((ushort)1000, M); 

                M = new NewestCOServer.Game.MapInfo(); 
                M.Spawns = new NewestCOServer.Game.Vector2[4]; 
                M.Spawns[0].X = 722; 
                M.Spawns[0].Y = 669; 
                M.Spawns[1].X = 519; 
                M.Spawns[1].Y = 710; 
                M.Spawns[2].X = 514; 
                M.Spawns[2].Y = 539; 
                M.Spawns[3].X = 312; 
                M.Spawns[3].Y = 572; 
                Game.World.MapDetails.Add((ushort)1015, M); 

                M = new NewestCOServer.Game.MapInfo(); 
                M.Spawns = new NewestCOServer.Game.Vector2[4]; 
                M.Spawns[0].X = 328; 
                M.Spawns[0].Y = 616; 
                M.Spawns[1].X = 338; 
                M.Spawns[1].Y = 438; 
                M.Spawns[2].X = 102; 
                M.Spawns[2].Y = 297; 
                M.Spawns[3].X = 352; 
                M.Spawns[3].Y = 286; 
                Game.World.MapDetails.Add((ushort)1001, M);  
                #endregion 

                NewestCOServer.Main.AuthWorker.StartServer(I.ReadString("Database", "GameServerIP")); 
                NewestCOServer.Main.GameWorker.StartServer(); 
                Database.LoadLottoItems(); 
                Program.WriteLine(); 
                Program.WriteLine("The server is ready for connections."); 
                Program.WriteLine("Always close the server by pressing Enter, or the important data wont't save."); 
                Database.LoadQuestions(); 
                Database.CreateEquipsDrops(); 
                Database.LoadEmpire(); 
                MyThread CompanionThread = new MyThread(); 
                CompanionThread.Execute += new Execute(CompanionThread_Execute); 
                CompanionThread.Start(100); 
                MyThread ServerStuff = new MyThread(); 
                ServerStuff.Execute += new Execute(ServerStuff_Execute); 
                ServerStuff.Start(100); 
                MyThread MobThread = new MyThread(); 
                MobThread.Execute += new Execute(MobThread_Execute); 
                MobThread.Start(100); 
                World.MobsStart = true; 
                while (true) 
                { 
                    string Command = Console.ReadLine(); 
                    string[] Cmd = Command.Split(' '); 

                    if (Command == "") 
                    { 
                        Console.ReadLine(); 
                    } 
                    if (Cmd[0] == "/restart") 
                    { 
                        Game.Character[] BaseCharacters = new Character[World.H_Chars.Count]; 
                        World.H_Chars.Values.CopyTo(BaseCharacters, 0); 

                        NewestCOServer.Main.AuthWorker.Listener.Close(); 
                        NewestCOServer.Main.GameWorker.Listener.Close(); 
                        EndSession = true; 
                        try 
                        { 
                            foreach (Game.Character C in BaseCharacters) 
                            { 
                                try 
                                { 
                                    C.MyClient.Disconnect(); 
                                    Console.WriteLine(C.Name + " has logged off successfuly."); 
                                } 
                                catch { continue; } 
                            } 
                        } 
                        catch { } 
                        Database.SaveKOs(); 
                        Console.WriteLine("KOs saved."); 
                        Database.SaveEmpire(); 
                        Console.WriteLine("Empire saved."); 
                        Features.Guilds.SaveGuilds(); 
                        Console.WriteLine("Guilds saved."); 
                        Features.SkillsClass.Save(); 
                        Console.WriteLine("Skills saved."); 
                         
                        MobThread.Close(); 
                        ServerStuff.Close(); 
                        CompanionThread.Close(); 
                        Database.Dispose(); 
                        Console.WriteLine("Database disposed."); 
                        Console.WriteLine("Write /exit or click X to close the window."); 
                        System.Diagnostics.Process.Start("NewestCOServer.exe"); 
                    } 
                    if (Cmd[0] == "/exit") 
                    { 
                        Game.Character[] BaseCharacters = new Character[World.H_Chars.Count]; 
                        World.H_Chars.Values.CopyTo(BaseCharacters, 0); 
                        NewestCOServer.Main.AuthWorker.Listener.Close(); 
                        NewestCOServer.Main.GameWorker.Listener.Close(); 
                        EndSession = true; 
                        try 
                        { 
                            foreach (Game.Character C in BaseCharacters) 
                            { 
                                try 
                                { 
                                    C.MyClient.Disconnect(); 
                                    Console.WriteLine(C.Name + " has logged off successfuly."); 
                                } 
                                catch { continue; } 
                            } 
                        } 
                        catch { } 
                        Database.SaveKOs(); 
                        Console.WriteLine("KOs saved."); 
                        Database.SaveEmpire(); 
                        Console.WriteLine("Empire saved."); 
                        Features.Guilds.SaveGuilds(); 
                        Console.WriteLine("Guilds saved."); 
                        Features.SkillsClass.Save(); 
                        Console.WriteLine("Skills saved."); 
                         
                        MobThread.Close(); 
                        ServerStuff.Close(); 
                        CompanionThread.Close(); 
                        Database.Dispose(); 
                        Console.WriteLine("Database disposed."); 
                        Console.WriteLine("Click X to close the window."); 
                    } 
                    if (Cmd[0] == "/expballs") 
                        Database.ExpBallReset(); 
                    if (Cmd[0] == "/expballs2") 
                        Database.ExpBallReset(); 
                    if (Cmd[0] == "/clear") 
                        Console.Clear(); 
                    if (Cmd[0] == "/newacc" && Cmd.Length > 2) 
                    { 
                        if (Cmd.Length == 3) 
                            Database.CreateAccount(Cmd[1], Cmd[2], ""); 
                        else 
                            Database.CreateAccount(Cmd[1], Cmd[2], Cmd[3]); 
                    } 
                    if (Cmd[0] == "/skilladder") 
                    { 
                        Extra.SkillAdder E = new NewestCOServer.Extra.SkillAdder(); 
                        System.Windows.Forms.Application.Run(E); 
                    } 
                    if (Cmd[0] == "/characters") 
                    { 
                        Form1 E = new Form1(); 
                        System.Windows.Forms.Application.Run(E); 
                    } 
                    if (Cmd[0] == "/accounts") 
                    { 
                        Form2 E = new Form2(); 
                        System.Windows.Forms.Application.Run(E); 
                    } 
                } 
            } 
            else 
            { 
                Program.WriteLine("The database folder doesn't exist, cannot start the server."); 
                Console.ReadLine(); 
            } 
        } 
        static void MobThread_Execute() 
        { 
            try 
            { 
                if (World.H_Chars.Count > 0) 
                { 
                    try 
                    { 
                        foreach (Hashtable H in Game.World.H_Mobs.Values) 
                        { 
                            foreach (Mob M in H.Values) 
                            { 
                                M.Step(); 

                                if (M.PoisonedInfo != null) 
                                { 
                                    if (DateTime.Now > M.PoisonedInfo.LastAttack.AddSeconds(3)) 
                                    { 
                                        if (M.CurrentHP == 1) 
                                        { 
                                            M.PoisonedInfo = null; 
                                            foreach (Game.Character C in Game.World.H_Chars.Values) 
                                                if (M.Loc.Map == C.Loc.Map) 
                                                    if (MyMath.PointDistance(M.Loc.X, M.Loc.Y, C.Loc.X, C.Loc.Y) <= 20) 
                                                        C.MyClient.AddSend(Packets.Status(M.EntityID, NewestCOServer.Game.Status.Effect, 0)); 
                                            continue; 
                                        } 
                                        M.PoisonedInfo.Times--; 
                                        M.PoisonedInfo.LastAttack = DateTime.Now; 
                                        uint Dmg = (uint)(M.CurrentHP * (10 + M.PoisonedInfo.SpellLevel * 10) / 100); 
                                        if (Dmg == 1) 
                                            continue; 
                                        M.TakeAttack(M, Dmg, AttackType.Melee); 
                                        if (M.PoisonedInfo.Times == 0) 
                                        { 
                                            M.PoisonedInfo = null; 
                                            foreach (Game.Character C in Game.World.H_Chars.Values) 
                                                if (M.Loc.Map == C.Loc.Map) 
                                                    if (MyMath.PointDistance(M.Loc.X, M.Loc.Y, C.Loc.X, C.Loc.Y) <= 20) 
                                                        C.MyClient.AddSend(Packets.Status(M.EntityID, NewestCOServer.Game.Status.Effect, 0)); 
                                        } 
                                    } 
                                } 
                            } 
                        } 
                    } 
                    catch (Exception Exc) { Program.WriteLine(Exc); } 
                } 
            } 
            catch (Exception Exc) { Program.WriteLine(Exc); } 
        } 
        static bool ExpBallClear = false; 
        static void ServerStuff_Execute() 
        { 
            try 
            { 
                if (DateTime.Now > SystemMsgTime.AddMinutes(1)) 
                { 
                    Handle_Events(); 
                    SystemMsgTime = DateTime.Now; 
                } 
                if (World.BroadCastCount > 0 && DateTime.Now > World.LastBroadCast.AddMinutes(1)) 
                { 
                    BroadCastMessage B = World.BroadCasts[0]; 

                    for (int i = 0; i < World.BroadCastCount; i++) 
                        World.BroadCasts[i] = World.BroadCasts[i + 1]; 

                    World.BroadCastCount--; 

                    World.SendMsgToAll(B.Name, B.Message, 2500, 0); 
                    World.LastBroadCast = DateTime.Now; 
                    World.CurrentBC = B; 
                } 
            } 
            catch { } 
            try 
            { 
                foreach (Hashtable H in World.H_Items.Values) 
                { 
                    ArrayList Deleted = new ArrayList(); 
                    try 
                    { 
                        foreach (DroppedItem I in H.Values) 
                            if (DateTime.Now > I.DropTime.AddSeconds(60)) 
                                Deleted.Add(I); 
                        foreach (DroppedItem I in Deleted) 
                            I.Dissappear(); 
                    } 
                    catch { } 
                } 
            } 
            catch { } 
            try 
            { 
                //if (!Features.GuildWars.War && DateTime.Now.Minute == 0 && Database.GWOn.Contains(DateTime.Now.Hour)) 
                //    Features.GuildWars.StartWar(); 
            } 
            catch { } 
            try 
            { 
                //if (Features.GuildWars.War && DateTime.Now > Features.GuildWars.LastScores.AddSeconds(5)) 
                //    Features.GuildWars.SendScores(); 
            } 
            catch { } 
            try 
            { 
                if (DateTime.Now.Hour == 0 && !ExpBallClear) 
                { 
                    Database.ExpBallReset(); 
                    ExpBallClear = true; 
                } 
                if (ExpBallClear && DateTime.Now.Hour == 1) 
                    ExpBallClear = false; 
            } 
            catch { } 
        } 
        static void Handle_Events() 
        { 
            switch (DateTime.Now.Minute) 
            { 
                case 7: 
                case 8: 
                    Game.World.SendMsgToAll("GM", "GMs have [GM] or [PM] at the end of their names. Don`t trust anyone claiming to be a GM but not having [GM]/[PM] in their names.", 2011, 0); 
                    break; 
                case 19: 
                case 20: 
                    Game.World.SendMsgToAll("GM", "File account problems and TQ Point Card purchase problems at SUPPORT on the official site.", 2011, 0); 
                    break; 
                case 31: 
                case 32: 
                    Game.World.SendMsgToAll("GM", "Help UnknownMan at Market (212,204) to level up quickly.", 2011, 0); 
                    break; 
                case 43: 
                case 44: 
                    Game.World.SendMsgToAll("GM", "Trading of game accounts is illegal and may result in the instant banning of the accounts involved in the trading.", 2011, 0); 
                    break; 
                case 55: 
                case 56: 
                    Game.World.SendMsgToAll("GM", "co.91.com is the only official website of CO, which is also the only website where you can purchase Dragonballs.", 2011, 0); 
                    break; 
                default: 
                    break; 
            } 
        } 
         
        static void CompanionThread_Execute() 
        { 
            try 
            { 
                if (World.H_Chars.Count > 0) 
                { 
                    foreach (Companion C in World.H_Companions.Values) 
                        try 
                        { 
                            C.Step(); 
                        } 
                        catch { } 
                } 
            } 
            catch { } 
        } 
        public static void QuestDropDone(object source, System.Timers.ElapsedEventArgs e) 
        { 
            try 
            { 
                if (DropEventTimer != null) 
                { 
                    if (DropEventType == "dragonball") 
                        DropRates.DragonBall = SaveOldRate; 
                    else if (DropEventType == "meteor") 
                        DropRates.Meteor = SaveOldRate; 
                    else if (DropEventType == "minicpbag") 
                        DropRates.CPMiniBag = SaveOldRate; 
                    else if (DropEventType == "cpbag") 
                        DropRates.CPBag = SaveOldRate; 

                    Game.World.SendMsgToAll("Server", "Drop " + DropEventType + "s event ended.", 2001, 0); 
                    DropEventType = ""; SaveOldRate = 0; 
                    DropEventTimer.Stop(); 
                    DropEventTimer.Close(); 
                    DropEventTimer = null; 
                }
            }
            catch { } 

            try  
            {  
                if (DateTime.Now > Features.DMScore.LastScores.AddSeconds(1))  
                    Features.DMScore.SendScores();  
            } 
            catch { } 
        } 
    } 
}
ImFlamedCOD is offline  
Thanks
1 User
Old 03/04/2010, 16:55   #8
 
elite*gold: 0
Join Date: Mar 2010
Posts: 42
Received Thanks: 3
My code is alot easier.
.Roach is offline  
Old 03/04/2010, 17:04   #9
 
alielmasry's Avatar
 
elite*gold: 0
Join Date: Mar 2009
Posts: 49
Received Thanks: 15
Quote:
Originally Posted by .Roach View Post
Delete that code.

Search for:
Code:
public static void WriteLine(string Line)
        {
Add this under it:
Code:
try
            {
                if (DateTime.Now > Features.DMScore.LastScores.AddSeconds(1))
                    Features.DMScore.SendScores();
            }
            catch { }
That should work.

could you post here your Program.cs file ? without errors
Quote:
Originally Posted by ImFlamedCOD View Post
Code:
using System.Threading; 
using System; 
using System.Collections.Generic; 
using System.Collections; 
using System.Linq; 
using System.Text; 
using NewestCOServer.Game; 
namespace NewestCOServer 
{ 
    class Program 
    { 

        public static void WriteLine(Exception Exc) 
        { 
            Console.WriteLine(Exc.ToString()); 

            try 
            { 
                if (!System.IO.File.Exists("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt")) 
                    System.IO.File.Create("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt").Close(); 
                string Text = System.IO.File.ReadAllText("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt"); 
                Text += Exc.ToString() + "\r\n"; 
                System.IO.File.WriteAllText("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt", Text); 
            } 
            catch { } 
        } 
        public static void WriteLine(string Line) 
        { 
            try 
            { 
                Console.WriteLine(Line); 
                if (!System.IO.File.Exists("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt")) 
                    System.IO.File.Create("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt").Close(); 
                string Text = System.IO.File.ReadAllText("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt"); 
                Text += Line + "\r\n"; 
                System.IO.File.WriteAllText("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt", Text); 
            } 
            catch { } 
        } 
        public static void WriteLine() 
        { 
            try 
            { 
                Console.WriteLine(); 
                if (!System.IO.File.Exists("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt")) 
                    System.IO.File.Create("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt").Close(); 
                string Text = System.IO.File.ReadAllText("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt"); 
                Text += "\r\n"; 
                System.IO.File.WriteAllText("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt", Text); 
            } 
            catch { } 
        } 
        public static bool EndSession = false; 
        public static double SaveOldRate = 0; 
        public static string DropEventType = ""; 
        public static System.Timers.Timer DropEventTimer = null; 
        public static DateTime SystemMsgTime = new DateTime(); 
        public static Random Rnd = new Random(); 
        public static string ConquerPath; 
        public static Features.QuizShow.MainInfo MainQuizShowInfo; 
        static void Main(string[] args) 

        { 
            Console.Title = "Newest CO Server"; 
            if (System.IO.Directory.Exists(@"C:\OldCODB")) 
            { 
                IniFile I = new IniFile(@"C:\OldCODB\Config.ini"); 
                ConquerPath = I.ReadString("Database", "ConquerPath"); 
                Database.DefaultCoords.Add((ushort)1002, new Game.Vector2() { X = 430, Y = 380 }); 
                Database.DefaultCoords.Add((ushort)1015, new Game.Vector2() { X = 717, Y = 571 }); 
                Database.DefaultCoords.Add((ushort)1000, new Game.Vector2() { X = 500, Y = 650 }); 
                Database.DefaultCoords.Add((ushort)1011, new Game.Vector2() { X = 188, Y = 264 }); 
                Database.DefaultCoords.Add((ushort)1020, new Game.Vector2() { X = 565, Y = 562 }); 
                Database.AddSkills(); 
                Database.LoadItems();                 
                Database.LoadPlusInfo(); 
                Database.LoadRevPoints(); 
                Database.LoadProfExp(); 
                Database.LoadPortals(); 
                Database.LoadLevelExp(); 
                Database.LoadNPCs(); 
                Database.LoadShops(); 
                DropRates.Load(); 
                Database.ReadAllCharacterStats(); 
                Database.LoadKOs(); 
                Features.SkillsClass.Load(); 
                Features.Guilds.LoadGuilds(); 
                DMaps.Load(); 
                Database.LoadMobs(); 
                Database.LoadCompanions(); 
                Features.GuildWars.Init(); 
                MainQuizShowInfo = new Features.QuizShow.MainInfo(); 
                #region Spawns for robot 
                Game.World.MapDetails = new System.Collections.Hashtable(); 
                Game.MapInfo M = new NewestCOServer.Game.MapInfo(); 
                M.Spawns = new NewestCOServer.Game.Vector2[5]; 
                M.Spawns[0].X = 465; 
                M.Spawns[0].Y = 462; 
                M.Spawns[1].X = 604; 
                M.Spawns[1].Y = 537; 
                M.Spawns[2].X = 527; 
                M.Spawns[2].Y = 701; 
                M.Spawns[3].X = 373; 
                M.Spawns[3].Y = 634; 
                M.Spawns[4].X = 141; 
                M.Spawns[4].Y = 436; 
                Game.World.MapDetails.Add((ushort)1002, M); 

                M = new NewestCOServer.Game.MapInfo(); 
                M.Spawns = new NewestCOServer.Game.Vector2[4]; 
                M.Spawns[0].X = 390; 
                M.Spawns[0].Y = 118; 
                M.Spawns[1].X = 359; 
                M.Spawns[1].Y = 284; 
                M.Spawns[2].X = 590; 
                M.Spawns[2].Y = 337; 
                M.Spawns[3].X = 620; 
                M.Spawns[3].Y = 776; 
                Game.World.MapDetails.Add((ushort)1011, M); 

                M = new NewestCOServer.Game.MapInfo(); 
                M.Spawns = new NewestCOServer.Game.Vector2[4]; 
                M.Spawns[0].X = 656; 
                M.Spawns[0].Y = 635; 
                M.Spawns[1].X = 500; 
                M.Spawns[1].Y = 279; 
                M.Spawns[2].X = 289; 
                M.Spawns[2].Y = 209; 
                M.Spawns[3].X = 188; 
                M.Spawns[3].Y = 457; 
                Game.World.MapDetails.Add((ushort)1020, M); 

                M = new NewestCOServer.Game.MapInfo(); 
                M.Spawns = new NewestCOServer.Game.Vector2[4]; 
                M.Spawns[0].X = 606; 
                M.Spawns[0].Y = 637; 
                M.Spawns[1].X = 607; 
                M.Spawns[1].Y = 500; 
                M.Spawns[2].X = 451; 
                M.Spawns[2].Y = 358; 
                M.Spawns[3].X = 186; 
                M.Spawns[3].Y = 352; 
                Game.World.MapDetails.Add((ushort)1000, M); 

                M = new NewestCOServer.Game.MapInfo(); 
                M.Spawns = new NewestCOServer.Game.Vector2[4]; 
                M.Spawns[0].X = 722; 
                M.Spawns[0].Y = 669; 
                M.Spawns[1].X = 519; 
                M.Spawns[1].Y = 710; 
                M.Spawns[2].X = 514; 
                M.Spawns[2].Y = 539; 
                M.Spawns[3].X = 312; 
                M.Spawns[3].Y = 572; 
                Game.World.MapDetails.Add((ushort)1015, M); 

                M = new NewestCOServer.Game.MapInfo(); 
                M.Spawns = new NewestCOServer.Game.Vector2[4]; 
                M.Spawns[0].X = 328; 
                M.Spawns[0].Y = 616; 
                M.Spawns[1].X = 338; 
                M.Spawns[1].Y = 438; 
                M.Spawns[2].X = 102; 
                M.Spawns[2].Y = 297; 
                M.Spawns[3].X = 352; 
                M.Spawns[3].Y = 286; 
                Game.World.MapDetails.Add((ushort)1001, M);  
                #endregion 

                NewestCOServer.Main.AuthWorker.StartServer(I.ReadString("Database", "GameServerIP")); 
                NewestCOServer.Main.GameWorker.StartServer(); 
                Database.LoadLottoItems(); 
                Program.WriteLine(); 
                Program.WriteLine("The server is ready for connections."); 
                Program.WriteLine("Always close the server by pressing Enter, or the important data wont't save."); 
                Database.LoadQuestions(); 
                Database.CreateEquipsDrops(); 
                Database.LoadEmpire(); 
                MyThread CompanionThread = new MyThread(); 
                CompanionThread.Execute += new Execute(CompanionThread_Execute); 
                CompanionThread.Start(100); 
                MyThread ServerStuff = new MyThread(); 
                ServerStuff.Execute += new Execute(ServerStuff_Execute); 
                ServerStuff.Start(100); 
                MyThread MobThread = new MyThread(); 
                MobThread.Execute += new Execute(MobThread_Execute); 
                MobThread.Start(100); 
                World.MobsStart = true; 
                while (true) 
                { 
                    string Command = Console.ReadLine(); 
                    string[] Cmd = Command.Split(' '); 

                    if (Command == "") 
                    { 
                        Console.ReadLine(); 
                    } 
                    if (Cmd[0] == "/restart") 
                    { 
                        Game.Character[] BaseCharacters = new Character[World.H_Chars.Count]; 
                        World.H_Chars.Values.CopyTo(BaseCharacters, 0); 

                        NewestCOServer.Main.AuthWorker.Listener.Close(); 
                        NewestCOServer.Main.GameWorker.Listener.Close(); 
                        EndSession = true; 
                        try 
                        { 
                            foreach (Game.Character C in BaseCharacters) 
                            { 
                                try 
                                { 
                                    C.MyClient.Disconnect(); 
                                    Console.WriteLine(C.Name + " has logged off successfuly."); 
                                } 
                                catch { continue; } 
                            } 
                        } 
                        catch { } 
                        Database.SaveKOs(); 
                        Console.WriteLine("KOs saved."); 
                        Database.SaveEmpire(); 
                        Console.WriteLine("Empire saved."); 
                        Features.Guilds.SaveGuilds(); 
                        Console.WriteLine("Guilds saved."); 
                        Features.SkillsClass.Save(); 
                        Console.WriteLine("Skills saved."); 
                         
                        MobThread.Close(); 
                        ServerStuff.Close(); 
                        CompanionThread.Close(); 
                        Database.Dispose(); 
                        Console.WriteLine("Database disposed."); 
                        Console.WriteLine("Write /exit or click X to close the window."); 
                        System.Diagnostics.Process.Start("NewestCOServer.exe"); 
                    } 
                    if (Cmd[0] == "/exit") 
                    { 
                        Game.Character[] BaseCharacters = new Character[World.H_Chars.Count]; 
                        World.H_Chars.Values.CopyTo(BaseCharacters, 0); 
                        NewestCOServer.Main.AuthWorker.Listener.Close(); 
                        NewestCOServer.Main.GameWorker.Listener.Close(); 
                        EndSession = true; 
                        try 
                        { 
                            foreach (Game.Character C in BaseCharacters) 
                            { 
                                try 
                                { 
                                    C.MyClient.Disconnect(); 
                                    Console.WriteLine(C.Name + " has logged off successfuly."); 
                                } 
                                catch { continue; } 
                            } 
                        } 
                        catch { } 
                        Database.SaveKOs(); 
                        Console.WriteLine("KOs saved."); 
                        Database.SaveEmpire(); 
                        Console.WriteLine("Empire saved."); 
                        Features.Guilds.SaveGuilds(); 
                        Console.WriteLine("Guilds saved."); 
                        Features.SkillsClass.Save(); 
                        Console.WriteLine("Skills saved."); 
                         
                        MobThread.Close(); 
                        ServerStuff.Close(); 
                        CompanionThread.Close(); 
                        Database.Dispose(); 
                        Console.WriteLine("Database disposed."); 
                        Console.WriteLine("Click X to close the window."); 
                    } 
                    if (Cmd[0] == "/expballs") 
                        Database.ExpBallReset(); 
                    if (Cmd[0] == "/expballs2") 
                        Database.ExpBallReset(); 
                    if (Cmd[0] == "/clear") 
                        Console.Clear(); 
                    if (Cmd[0] == "/newacc" && Cmd.Length > 2) 
                    { 
                        if (Cmd.Length == 3) 
                            Database.CreateAccount(Cmd[1], Cmd[2], ""); 
                        else 
                            Database.CreateAccount(Cmd[1], Cmd[2], Cmd[3]); 
                    } 
                    if (Cmd[0] == "/skilladder") 
                    { 
                        Extra.SkillAdder E = new NewestCOServer.Extra.SkillAdder(); 
                        System.Windows.Forms.Application.Run(E); 
                    } 
                    if (Cmd[0] == "/characters") 
                    { 
                        Form1 E = new Form1(); 
                        System.Windows.Forms.Application.Run(E); 
                    } 
                    if (Cmd[0] == "/accounts") 
                    { 
                        Form2 E = new Form2(); 
                        System.Windows.Forms.Application.Run(E); 
                    } 
                } 
            } 
            else 
            { 
                Program.WriteLine("The database folder doesn't exist, cannot start the server."); 
                Console.ReadLine(); 
            } 
        } 
        static void MobThread_Execute() 
        { 
            try 
            { 
                if (World.H_Chars.Count > 0) 
                { 
                    try 
                    { 
                        foreach (Hashtable H in Game.World.H_Mobs.Values) 
                        { 
                            foreach (Mob M in H.Values) 
                            { 
                                M.Step(); 

                                if (M.PoisonedInfo != null) 
                                { 
                                    if (DateTime.Now > M.PoisonedInfo.LastAttack.AddSeconds(3)) 
                                    { 
                                        if (M.CurrentHP == 1) 
                                        { 
                                            M.PoisonedInfo = null; 
                                            foreach (Game.Character C in Game.World.H_Chars.Values) 
                                                if (M.Loc.Map == C.Loc.Map) 
                                                    if (MyMath.PointDistance(M.Loc.X, M.Loc.Y, C.Loc.X, C.Loc.Y) <= 20) 
                                                        C.MyClient.AddSend(Packets.Status(M.EntityID, NewestCOServer.Game.Status.Effect, 0)); 
                                            continue; 
                                        } 
                                        M.PoisonedInfo.Times--; 
                                        M.PoisonedInfo.LastAttack = DateTime.Now; 
                                        uint Dmg = (uint)(M.CurrentHP * (10 + M.PoisonedInfo.SpellLevel * 10) / 100); 
                                        if (Dmg == 1) 
                                            continue; 
                                        M.TakeAttack(M, Dmg, AttackType.Melee); 
                                        if (M.PoisonedInfo.Times == 0) 
                                        { 
                                            M.PoisonedInfo = null; 
                                            foreach (Game.Character C in Game.World.H_Chars.Values) 
                                                if (M.Loc.Map == C.Loc.Map) 
                                                    if (MyMath.PointDistance(M.Loc.X, M.Loc.Y, C.Loc.X, C.Loc.Y) <= 20) 
                                                        C.MyClient.AddSend(Packets.Status(M.EntityID, NewestCOServer.Game.Status.Effect, 0)); 
                                        } 
                                    } 
                                } 
                            } 
                        } 
                    } 
                    catch (Exception Exc) { Program.WriteLine(Exc); } 
                } 
            } 
            catch (Exception Exc) { Program.WriteLine(Exc); } 
        } 
        static bool ExpBallClear = false; 
        static void ServerStuff_Execute() 
        { 
            try 
            { 
                if (DateTime.Now > SystemMsgTime.AddMinutes(1)) 
                { 
                    Handle_Events(); 
                    SystemMsgTime = DateTime.Now; 
                } 
                if (World.BroadCastCount > 0 && DateTime.Now > World.LastBroadCast.AddMinutes(1)) 
                { 
                    BroadCastMessage B = World.BroadCasts[0]; 

                    for (int i = 0; i < World.BroadCastCount; i++) 
                        World.BroadCasts[i] = World.BroadCasts[i + 1]; 

                    World.BroadCastCount--; 

                    World.SendMsgToAll(B.Name, B.Message, 2500, 0); 
                    World.LastBroadCast = DateTime.Now; 
                    World.CurrentBC = B; 
                } 
            } 
            catch { } 
            try 
            { 
                foreach (Hashtable H in World.H_Items.Values) 
                { 
                    ArrayList Deleted = new ArrayList(); 
                    try 
                    { 
                        foreach (DroppedItem I in H.Values) 
                            if (DateTime.Now > I.DropTime.AddSeconds(60)) 
                                Deleted.Add(I); 
                        foreach (DroppedItem I in Deleted) 
                            I.Dissappear(); 
                    } 
                    catch { } 
                } 
            } 
            catch { } 
            try 
            { 
                //if (!Features.GuildWars.War && DateTime.Now.Minute == 0 && Database.GWOn.Contains(DateTime.Now.Hour)) 
                //    Features.GuildWars.StartWar(); 
            } 
            catch { } 
            try 
            { 
                //if (Features.GuildWars.War && DateTime.Now > Features.GuildWars.LastScores.AddSeconds(5)) 
                //    Features.GuildWars.SendScores(); 
            } 
            catch { } 
            try 
            { 
                if (DateTime.Now.Hour == 0 && !ExpBallClear) 
                { 
                    Database.ExpBallReset(); 
                    ExpBallClear = true; 
                } 
                if (ExpBallClear && DateTime.Now.Hour == 1) 
                    ExpBallClear = false; 
            } 
            catch { } 
        } 
        static void Handle_Events() 
        { 
            switch (DateTime.Now.Minute) 
            { 
                case 7: 
                case 8: 
                    Game.World.SendMsgToAll("GM", "GMs have [GM] or [PM] at the end of their names. Don`t trust anyone claiming to be a GM but not having [GM]/[PM] in their names.", 2011, 0); 
                    break; 
                case 19: 
                case 20: 
                    Game.World.SendMsgToAll("GM", "File account problems and TQ Point Card purchase problems at SUPPORT on the official site.", 2011, 0); 
                    break; 
                case 31: 
                case 32: 
                    Game.World.SendMsgToAll("GM", "Help UnknownMan at Market (212,204) to level up quickly.", 2011, 0); 
                    break; 
                case 43: 
                case 44: 
                    Game.World.SendMsgToAll("GM", "Trading of game accounts is illegal and may result in the instant banning of the accounts involved in the trading.", 2011, 0); 
                    break; 
                case 55: 
                case 56: 
                    Game.World.SendMsgToAll("GM", "co.91.com is the only official website of CO, which is also the only website where you can purchase Dragonballs.", 2011, 0); 
                    break; 
                default: 
                    break; 
            } 
        } 
         
        static void CompanionThread_Execute() 
        { 
            try 
            { 
                if (World.H_Chars.Count > 0) 
                { 
                    foreach (Companion C in World.H_Companions.Values) 
                        try 
                        { 
                            C.Step(); 
                        } 
                        catch { } 
                } 
            } 
            catch { } 
        } 
        public static void QuestDropDone(object source, System.Timers.ElapsedEventArgs e) 
        { 
            try 
            { 
                if (DropEventTimer != null) 
                { 
                    if (DropEventType == "dragonball") 
                        DropRates.DragonBall = SaveOldRate; 
                    else if (DropEventType == "meteor") 
                        DropRates.Meteor = SaveOldRate; 
                    else if (DropEventType == "minicpbag") 
                        DropRates.CPMiniBag = SaveOldRate; 
                    else if (DropEventType == "cpbag") 
                        DropRates.CPBag = SaveOldRate; 

                    Game.World.SendMsgToAll("Server", "Drop " + DropEventType + "s event ended.", 2001, 0); 
                    DropEventType = ""; SaveOldRate = 0; 
                    DropEventTimer.Stop(); 
                    DropEventTimer.Close(); 
                    DropEventTimer = null; 
                }
            }
            catch { } 

            try  
            {  
                if (DateTime.Now > Features.DMScore.LastScores.AddSeconds(1))  
                    Features.DMScore.SendScores();  
            } 
            catch { } 
        } 
    } 
}

its sending : this pic

alielmasry is offline  
Old 03/04/2010, 17:10   #10
 
elite*gold: 0
Join Date: Mar 2010
Posts: 42
Received Thanks: 3
Here is my Program.cs, just delete everything in yours and paste mine in.
I hope you press thanks
Code:
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using NewestCOServer.Game;
namespace NewestCOServer
{
    class Program
    {

        public static void WriteLine(Exception Exc)
        {
            Console.WriteLine(Exc.ToString());

            try
            {
                if (!System.IO.File.Exists("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt"))
                    System.IO.File.Create("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt").Close();
                string Text = System.IO.File.ReadAllText("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt");
                Text += Exc.ToString() + "\r\n";
                System.IO.File.WriteAllText("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt", Text);
            }
            catch { }
        }
        public static void WriteLine(string Line)
        {
            try
            {
                if (DateTime.Now > Features.DMScore.LastScores.AddSeconds(1))
                    Features.DMScore.SendScores();
            }
            catch { }
            try
            {
                Console.WriteLine(Line);
                if (!System.IO.File.Exists("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt"))
                    System.IO.File.Create("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt").Close();
                string Text = System.IO.File.ReadAllText("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt");
                Text += Line + "\r\n";
                System.IO.File.WriteAllText("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt", Text);
            }
            catch { }
        }
        public static void WriteLine()
        {
            try
            {
                Console.WriteLine();
                if (!System.IO.File.Exists("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt"))
                    System.IO.File.Create("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt").Close();
                string Text = System.IO.File.ReadAllText("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt");
                Text += "\r\n";
                System.IO.File.WriteAllText("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt", Text);
            }
            catch { }
        }
        public static bool EndSession = false;
        public static double SaveOldRate = 0;
        public static string DropEventType = "";
        public static System.Timers.Timer DropEventTimer = null;
        public static Random Rnd = new Random();
        public static string ConquerPath;
        public static Features.QuizShow.MainInfo MainQuizShowInfo;
        static void Main(string[] args)

        {
            Console.Title = "Newest CO Server";
            if (System.IO.Directory.Exists(@"C:\OldCODB"))
            {
                IniFile I = new IniFile(@"C:\OldCODB\Config.ini");
                ConquerPath = I.ReadString("Database", "ConquerPath");
                Database.DefaultCoords.Add((ushort)1002, new Game.Vector2() { X = 430, Y = 380 });
                Database.DefaultCoords.Add((ushort)1015, new Game.Vector2() { X = 717, Y = 571 });
                Database.DefaultCoords.Add((ushort)1000, new Game.Vector2() { X = 500, Y = 650 });
                Database.DefaultCoords.Add((ushort)1011, new Game.Vector2() { X = 188, Y = 264 });
                Database.DefaultCoords.Add((ushort)1020, new Game.Vector2() { X = 565, Y = 562 });
                Database.AddSkills();
                Database.LoadItems();                
                Database.LoadPlusInfo();
                Database.LoadRevPoints();
                Database.LoadProfExp();
                Database.LoadPortals();
                Database.LoadLevelExp();
                Database.LoadNPCs();
                Database.LoadShops();
                DropRates.Load();
                Database.ReadAllCharacterStats();
                Database.LoadKOs();
                Features.SkillsClass.Load();
                Features.Guilds.LoadGuilds();
                DMaps.Load();
                DMaps.LoadHouses();
                Database.LoadMobs();
                Database.LoadCompanions();
                Features.GuildWars.Init();
                MainQuizShowInfo = new Features.QuizShow.MainInfo();
                #region Spawns for robot
                Game.World.MapDetails = new System.Collections.Hashtable();
                Game.MapInfo M = new NewestCOServer.Game.MapInfo();
                M.Spawns = new NewestCOServer.Game.Vector2[5];
                M.Spawns[0].X = 465;
                M.Spawns[0].Y = 462;
                M.Spawns[1].X = 604;
                M.Spawns[1].Y = 537;
                M.Spawns[2].X = 527;
                M.Spawns[2].Y = 701;
                M.Spawns[3].X = 373;
                M.Spawns[3].Y = 634;
                M.Spawns[4].X = 141;
                M.Spawns[4].Y = 436;
                Game.World.MapDetails.Add((ushort)1002, M);

                M = new NewestCOServer.Game.MapInfo();
                M.Spawns = new NewestCOServer.Game.Vector2[4];
                M.Spawns[0].X = 390;
                M.Spawns[0].Y = 118;
                M.Spawns[1].X = 359;
                M.Spawns[1].Y = 284;
                M.Spawns[2].X = 590;
                M.Spawns[2].Y = 337;
                M.Spawns[3].X = 620;
                M.Spawns[3].Y = 776;
                Game.World.MapDetails.Add((ushort)1011, M);

                M = new NewestCOServer.Game.MapInfo();
                M.Spawns = new NewestCOServer.Game.Vector2[4];
                M.Spawns[0].X = 656;
                M.Spawns[0].Y = 635;
                M.Spawns[1].X = 500;
                M.Spawns[1].Y = 279;
                M.Spawns[2].X = 289;
                M.Spawns[2].Y = 209;
                M.Spawns[3].X = 188;
                M.Spawns[3].Y = 457;
                Game.World.MapDetails.Add((ushort)1020, M);

                M = new NewestCOServer.Game.MapInfo();
                M.Spawns = new NewestCOServer.Game.Vector2[4];
                M.Spawns[0].X = 606;
                M.Spawns[0].Y = 637;
                M.Spawns[1].X = 607;
                M.Spawns[1].Y = 500;
                M.Spawns[2].X = 451;
                M.Spawns[2].Y = 358;
                M.Spawns[3].X = 186;
                M.Spawns[3].Y = 352;
                Game.World.MapDetails.Add((ushort)1000, M);

                M = new NewestCOServer.Game.MapInfo();
                M.Spawns = new NewestCOServer.Game.Vector2[4];
                M.Spawns[0].X = 722;
                M.Spawns[0].Y = 669;
                M.Spawns[1].X = 519;
                M.Spawns[1].Y = 710;
                M.Spawns[2].X = 514;
                M.Spawns[2].Y = 539;
                M.Spawns[3].X = 312;
                M.Spawns[3].Y = 572;
                Game.World.MapDetails.Add((ushort)1015, M);

                M = new NewestCOServer.Game.MapInfo();
                M.Spawns = new NewestCOServer.Game.Vector2[4];
                M.Spawns[0].X = 328;
                M.Spawns[0].Y = 616;
                M.Spawns[1].X = 338;
                M.Spawns[1].Y = 438;
                M.Spawns[2].X = 102;
                M.Spawns[2].Y = 297;
                M.Spawns[3].X = 352;
                M.Spawns[3].Y = 286;
                Game.World.MapDetails.Add((ushort)1001, M); 
                #endregion

                NewestCOServer.Main.AuthWorker.StartServer(I.ReadString("Database", "GameServerIP"));
                NewestCOServer.Main.GameWorker.StartServer();
                Database.LoadLottoItems();
                Program.WriteLine();
                Program.WriteLine("The server is ready for connections.");
                Program.WriteLine("Always close the server by pressing Enter, or the important data wont't save.");
                Database.LoadQuestions();
                Database.CreateEquipsDrops();
                Database.LoadEmpire();
                MyThread CompanionThread = new MyThread();
                CompanionThread.Execute += new Execute(CompanionThread_Execute);
                CompanionThread.Start(100);
                MyThread ServerStuff = new MyThread();
                ServerStuff.Execute += new Execute(ServerStuff_Execute);
                ServerStuff.Start(100);
                MyThread MobThread = new MyThread();
                MobThread.Execute += new Execute(MobThread_Execute);
                MobThread.Start(100);
                World.MobsStart = true;
                while (true)
                {
                    string Command = Console.ReadLine();
                    string[] Cmd = Command.Split(' ');

                    if (Command == "")
                    {
                        Console.ReadLine();
                    }

                    if (Cmd[0] == "/restart")
                    {
                        Game.Character[] BaseCharacters = new Character[World.H_Chars.Count];
                        World.H_Chars.Values.CopyTo(BaseCharacters, 0);

                        NewestCOServer.Main.AuthWorker.Listener.Close();
                        NewestCOServer.Main.GameWorker.Listener.Close();
                        EndSession = true;
                        try
                        {
                            foreach (Game.Character C in BaseCharacters)
                            {
                                try
                                {
                                    C.MyClient.Disconnect();
                                    Console.WriteLine(C.Name + " has logged off successfuly.");
                                }
                                catch { continue; }
                            }
                        }
                        catch { }
                        Database.SaveKOs();
                        Console.WriteLine("KOs saved.");
                        Database.SaveEmpire();
                        Console.WriteLine("Empire saved.");
                        Features.Guilds.SaveGuilds();
                        Console.WriteLine("Guilds saved.");
                        DMaps.Save();
                        Features.SkillsClass.Save();
                        Console.WriteLine("Skills saved.");
                        
                        MobThread.Close();
                        ServerStuff.Close();
                        CompanionThread.Close();
                        Database.Dispose();
                        Console.WriteLine("Database disposed.");
                        Console.WriteLine("Write /exit or click X to close the window.");
                        System.Diagnostics.Process.Start("NewestCOServer.exe");
                    }
                    if (Cmd[0] == "/exit")
                    {
                        Game.Character[] BaseCharacters = new Character[World.H_Chars.Count];
                        World.H_Chars.Values.CopyTo(BaseCharacters, 0);
                        NewestCOServer.Main.AuthWorker.Listener.Close();
                        NewestCOServer.Main.GameWorker.Listener.Close();
                        EndSession = true;
                        try
                        {
                            foreach (Game.Character C in BaseCharacters)
                            {
                                try
                                {
                                    C.MyClient.Disconnect();
                                    Console.WriteLine(C.Name + " has logged off successfuly.");
                                }
                                catch { continue; }
                            }
                        }
                        catch { }
                        Database.SaveKOs();
                        Console.WriteLine("KOs saved.");
                        Database.SaveEmpire();
                        Console.WriteLine("Empire saved.");
                        Features.Guilds.SaveGuilds();
                        Console.WriteLine("Guilds saved.");
                        DMaps.Save();
                        Features.SkillsClass.Save();
                        Console.WriteLine("Skills saved.");
                        
                        MobThread.Close();
                        ServerStuff.Close();
                        CompanionThread.Close();
                        Database.Dispose();
                        Console.WriteLine("Database disposed.");
                        Console.WriteLine("Click X to close the window.");
                    }
                    if (Cmd[0] == "/expballs")
                        Database.ExpBallReset();
                    if (Cmd[0] == "/expballs2")
                        Database.ExpBallReset();
                    if (Cmd[0] == "/clear")
                        Console.Clear();
                    if (Cmd[0] == "/newacc" && Cmd.Length > 2)
                    {
                        if (Cmd.Length == 3)
                            Database.CreateAccount(Cmd[1], Cmd[2], "");
                        else
                            Database.CreateAccount(Cmd[1], Cmd[2], Cmd[3]);
                    }
                    if (Cmd[0] == "/skilladder")
                    {
                        Extra.SkillAdder E = new NewestCOServer.Extra.SkillAdder();
                        System.Windows.Forms.Application.Run(E);
                    }
                    if (Cmd[0] == "/characters")
                    {
                        Form1 E = new Form1();
                        System.Windows.Forms.Application.Run(E);
                    }
                    if (Cmd[0] == "/accounts")
                    {
                        Form2 E = new Form2();
                        System.Windows.Forms.Application.Run(E);
                    }
                }
            }
            else
            {
                Program.WriteLine("The database folder doesn't exist, cannot start the server.");
                Console.ReadLine();
            }
        }
        static void MobThread_Execute()
        {
            
            try
            {
                if (World.H_Chars.Count > 0)
                {
                    try
                    {
                        foreach (Hashtable H in Game.World.H_Mobs.Values)
                        {
                            foreach (Mob M in H.Values)
                            {
                                M.Step();

                                if (M.PoisonedInfo != null)
                                {
                                    if (DateTime.Now > M.PoisonedInfo.LastAttack.AddSeconds(3))
                                    {
                                        if (M.CurrentHP == 1)
                                        {
                                            M.PoisonedInfo = null;
                                            foreach (Game.Character C in Game.World.H_Chars.Values)
                                                if (M.Loc.Map == C.Loc.Map)
                                                    if (MyMath.PointDistance(M.Loc.X, M.Loc.Y, C.Loc.X, C.Loc.Y) <= 20)
                                                        C.MyClient.AddSend(Packets.Status(M.EntityID, NewestCOServer.Game.Status.Effect, 0));
                                            continue;
                                        }
                                        M.PoisonedInfo.Times--;
                                        M.PoisonedInfo.LastAttack = DateTime.Now;
                                        uint Dmg = (uint)(M.CurrentHP * (10 + M.PoisonedInfo.SpellLevel * 10) / 100);
                                        if (Dmg == 1)
                                            continue;
                                        M.TakeAttack(M, Dmg, AttackType.Melee);
                                        if (M.PoisonedInfo.Times == 0)
                                        {
                                            M.PoisonedInfo = null;
                                            foreach (Game.Character C in Game.World.H_Chars.Values)
                                                if (M.Loc.Map == C.Loc.Map)
                                                    if (MyMath.PointDistance(M.Loc.X, M.Loc.Y, C.Loc.X, C.Loc.Y) <= 20)
                                                        C.MyClient.AddSend(Packets.Status(M.EntityID, NewestCOServer.Game.Status.Effect, 0));
                                        }
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception Exc) { Program.WriteLine(Exc); }
                }
            }
            catch (Exception Exc) { Program.WriteLine(Exc); }
        }
        static bool ExpBallClear = false;
        static void ServerStuff_Execute()
        {
            try
            {
                if (World.BroadCastCount > 0 && DateTime.Now > World.LastBroadCast.AddMinutes(1))
                {
                    BroadCastMessage B = World.BroadCasts[0];

                    for (int i = 0; i < World.BroadCastCount; i++)
                        World.BroadCasts[i] = World.BroadCasts[i + 1];

                    World.BroadCastCount--;

                    World.SendMsgToAll(B.Name, B.Message, 2500, 0);
                    World.LastBroadCast = DateTime.Now;
                    World.CurrentBC = B;
                }
            }
            catch { }
            try
            {
                foreach (Hashtable H in World.H_Items.Values)
                {
                    ArrayList Deleted = new ArrayList();
                    try
                    {
                        foreach (DroppedItem I in H.Values)
                            if (DateTime.Now > I.DropTime.AddSeconds(60))
                                Deleted.Add(I);
                        foreach (DroppedItem I in Deleted)
                            I.Dissappear();
                    }
                    catch { }
                }
            }
            catch { }
            try
            {
                //if (!Features.GuildWars.War && DateTime.Now.Minute == 0 && Database.GWOn.Contains(DateTime.Now.Hour))
                //    Features.GuildWars.StartWar();
            }
            catch { }
            try
            {
                //if (Features.GuildWars.War && DateTime.Now > Features.GuildWars.LastScores.AddSeconds(5))
                //    Features.GuildWars.SendScores();
            }
            catch { }
            try
            {
                if (DateTime.Now.Hour == 0 && !ExpBallClear)
                {
                    Database.ExpBallReset();
                    ExpBallClear = true;
                }
                if (ExpBallClear && DateTime.Now.Hour == 1)
                    ExpBallClear = false;
            }
            catch { }
        }

        static void CompanionThread_Execute()
        {
            try
            {
                if (World.H_Chars.Count > 0)
                {
                    foreach (Companion C in World.H_Companions.Values)
                        try
                        {
                            C.Step();
                        }
                        catch { }
                }
            }
            catch { }
        }
        public static void QuestDropDone(object source, System.Timers.ElapsedEventArgs e)
        {
            try
            {
                if (DropEventTimer != null)
                {
                    if (DropEventType == "dragonball")
                        DropRates.DragonBall = SaveOldRate;
                    else if (DropEventType == "meteor")
                        DropRates.Meteor = SaveOldRate;
                    else if (DropEventType == "minicpbag")
                        DropRates.CPMiniBag = SaveOldRate;
                    else if (DropEventType == "cpbag")
                        DropRates.CPBag = SaveOldRate;

                    Game.World.SendMsgToAll("Server", "Drop " + DropEventType + "s event ended.", 2001, 0);
                    DropEventType = ""; SaveOldRate = 0;
                    DropEventTimer.Stop();
                    DropEventTimer.Close();
                    DropEventTimer = null;
                }
            }
            catch { }
        }
    }
}
.Roach is offline  
Thanks
1 User
Old 03/04/2010, 17:14   #11
 
alielmasry's Avatar
 
elite*gold: 0
Join Date: Mar 2009
Posts: 49
Received Thanks: 15
Quote:
Originally Posted by .Roach View Post
Here is my Program.cs, just delete everything in yours and paste mine in.
I hope you press thanks
Code:
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using NewestCOServer.Game;
namespace NewestCOServer
{
    class Program
    {

        public static void WriteLine(Exception Exc)
        {
            Console.WriteLine(Exc.ToString());

            try
            {
                if (!System.IO.File.Exists("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt"))
                    System.IO.File.Create("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt").Close();
                string Text = System.IO.File.ReadAllText("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt");
                Text += Exc.ToString() + "\r\n";
                System.IO.File.WriteAllText("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt", Text);
            }
            catch { }
        }
        public static void WriteLine(string Line)
        {
            try
            {
                if (DateTime.Now > Features.DMScore.LastScores.AddSeconds(1))
                    Features.DMScore.SendScores();
            }
            catch { }
            try
            {
                Console.WriteLine(Line);
                if (!System.IO.File.Exists("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt"))
                    System.IO.File.Create("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt").Close();
                string Text = System.IO.File.ReadAllText("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt");
                Text += Line + "\r\n";
                System.IO.File.WriteAllText("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt", Text);
            }
            catch { }
        }
        public static void WriteLine()
        {
            try
            {
                Console.WriteLine();
                if (!System.IO.File.Exists("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt"))
                    System.IO.File.Create("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt").Close();
                string Text = System.IO.File.ReadAllText("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt");
                Text += "\r\n";
                System.IO.File.WriteAllText("debug." + DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + ".txt", Text);
            }
            catch { }
        }
        public static bool EndSession = false;
        public static double SaveOldRate = 0;
        public static string DropEventType = "";
        public static System.Timers.Timer DropEventTimer = null;
        public static Random Rnd = new Random();
        public static string ConquerPath;
        public static Features.QuizShow.MainInfo MainQuizShowInfo;
        static void Main(string[] args)

        {
            Console.Title = "Newest CO Server";
            if (System.IO.Directory.Exists(@"C:\OldCODB"))
            {
                IniFile I = new IniFile(@"C:\OldCODB\Config.ini");
                ConquerPath = I.ReadString("Database", "ConquerPath");
                Database.DefaultCoords.Add((ushort)1002, new Game.Vector2() { X = 430, Y = 380 });
                Database.DefaultCoords.Add((ushort)1015, new Game.Vector2() { X = 717, Y = 571 });
                Database.DefaultCoords.Add((ushort)1000, new Game.Vector2() { X = 500, Y = 650 });
                Database.DefaultCoords.Add((ushort)1011, new Game.Vector2() { X = 188, Y = 264 });
                Database.DefaultCoords.Add((ushort)1020, new Game.Vector2() { X = 565, Y = 562 });
                Database.AddSkills();
                Database.LoadItems();                
                Database.LoadPlusInfo();
                Database.LoadRevPoints();
                Database.LoadProfExp();
                Database.LoadPortals();
                Database.LoadLevelExp();
                Database.LoadNPCs();
                Database.LoadShops();
                DropRates.Load();
                Database.ReadAllCharacterStats();
                Database.LoadKOs();
                Features.SkillsClass.Load();
                Features.Guilds.LoadGuilds();
                DMaps.Load();
                DMaps.LoadHouses();
                Database.LoadMobs();
                Database.LoadCompanions();
                Features.GuildWars.Init();
                MainQuizShowInfo = new Features.QuizShow.MainInfo();
                #region Spawns for robot
                Game.World.MapDetails = new System.Collections.Hashtable();
                Game.MapInfo M = new NewestCOServer.Game.MapInfo();
                M.Spawns = new NewestCOServer.Game.Vector2[5];
                M.Spawns[0].X = 465;
                M.Spawns[0].Y = 462;
                M.Spawns[1].X = 604;
                M.Spawns[1].Y = 537;
                M.Spawns[2].X = 527;
                M.Spawns[2].Y = 701;
                M.Spawns[3].X = 373;
                M.Spawns[3].Y = 634;
                M.Spawns[4].X = 141;
                M.Spawns[4].Y = 436;
                Game.World.MapDetails.Add((ushort)1002, M);

                M = new NewestCOServer.Game.MapInfo();
                M.Spawns = new NewestCOServer.Game.Vector2[4];
                M.Spawns[0].X = 390;
                M.Spawns[0].Y = 118;
                M.Spawns[1].X = 359;
                M.Spawns[1].Y = 284;
                M.Spawns[2].X = 590;
                M.Spawns[2].Y = 337;
                M.Spawns[3].X = 620;
                M.Spawns[3].Y = 776;
                Game.World.MapDetails.Add((ushort)1011, M);

                M = new NewestCOServer.Game.MapInfo();
                M.Spawns = new NewestCOServer.Game.Vector2[4];
                M.Spawns[0].X = 656;
                M.Spawns[0].Y = 635;
                M.Spawns[1].X = 500;
                M.Spawns[1].Y = 279;
                M.Spawns[2].X = 289;
                M.Spawns[2].Y = 209;
                M.Spawns[3].X = 188;
                M.Spawns[3].Y = 457;
                Game.World.MapDetails.Add((ushort)1020, M);

                M = new NewestCOServer.Game.MapInfo();
                M.Spawns = new NewestCOServer.Game.Vector2[4];
                M.Spawns[0].X = 606;
                M.Spawns[0].Y = 637;
                M.Spawns[1].X = 607;
                M.Spawns[1].Y = 500;
                M.Spawns[2].X = 451;
                M.Spawns[2].Y = 358;
                M.Spawns[3].X = 186;
                M.Spawns[3].Y = 352;
                Game.World.MapDetails.Add((ushort)1000, M);

                M = new NewestCOServer.Game.MapInfo();
                M.Spawns = new NewestCOServer.Game.Vector2[4];
                M.Spawns[0].X = 722;
                M.Spawns[0].Y = 669;
                M.Spawns[1].X = 519;
                M.Spawns[1].Y = 710;
                M.Spawns[2].X = 514;
                M.Spawns[2].Y = 539;
                M.Spawns[3].X = 312;
                M.Spawns[3].Y = 572;
                Game.World.MapDetails.Add((ushort)1015, M);

                M = new NewestCOServer.Game.MapInfo();
                M.Spawns = new NewestCOServer.Game.Vector2[4];
                M.Spawns[0].X = 328;
                M.Spawns[0].Y = 616;
                M.Spawns[1].X = 338;
                M.Spawns[1].Y = 438;
                M.Spawns[2].X = 102;
                M.Spawns[2].Y = 297;
                M.Spawns[3].X = 352;
                M.Spawns[3].Y = 286;
                Game.World.MapDetails.Add((ushort)1001, M); 
                #endregion

                NewestCOServer.Main.AuthWorker.StartServer(I.ReadString("Database", "GameServerIP"));
                NewestCOServer.Main.GameWorker.StartServer();
                Database.LoadLottoItems();
                Program.WriteLine();
                Program.WriteLine("The server is ready for connections.");
                Program.WriteLine("Always close the server by pressing Enter, or the important data wont't save.");
                Database.LoadQuestions();
                Database.CreateEquipsDrops();
                Database.LoadEmpire();
                MyThread CompanionThread = new MyThread();
                CompanionThread.Execute += new Execute(CompanionThread_Execute);
                CompanionThread.Start(100);
                MyThread ServerStuff = new MyThread();
                ServerStuff.Execute += new Execute(ServerStuff_Execute);
                ServerStuff.Start(100);
                MyThread MobThread = new MyThread();
                MobThread.Execute += new Execute(MobThread_Execute);
                MobThread.Start(100);
                World.MobsStart = true;
                while (true)
                {
                    string Command = Console.ReadLine();
                    string[] Cmd = Command.Split(' ');

                    if (Command == "")
                    {
                        Console.ReadLine();
                    }

                    if (Cmd[0] == "/restart")
                    {
                        Game.Character[] BaseCharacters = new Character[World.H_Chars.Count];
                        World.H_Chars.Values.CopyTo(BaseCharacters, 0);

                        NewestCOServer.Main.AuthWorker.Listener.Close();
                        NewestCOServer.Main.GameWorker.Listener.Close();
                        EndSession = true;
                        try
                        {
                            foreach (Game.Character C in BaseCharacters)
                            {
                                try
                                {
                                    C.MyClient.Disconnect();
                                    Console.WriteLine(C.Name + " has logged off successfuly.");
                                }
                                catch { continue; }
                            }
                        }
                        catch { }
                        Database.SaveKOs();
                        Console.WriteLine("KOs saved.");
                        Database.SaveEmpire();
                        Console.WriteLine("Empire saved.");
                        Features.Guilds.SaveGuilds();
                        Console.WriteLine("Guilds saved.");
                        DMaps.Save();
                        Features.SkillsClass.Save();
                        Console.WriteLine("Skills saved.");
                        
                        MobThread.Close();
                        ServerStuff.Close();
                        CompanionThread.Close();
                        Database.Dispose();
                        Console.WriteLine("Database disposed.");
                        Console.WriteLine("Write /exit or click X to close the window.");
                        System.Diagnostics.Process.Start("NewestCOServer.exe");
                    }
                    if (Cmd[0] == "/exit")
                    {
                        Game.Character[] BaseCharacters = new Character[World.H_Chars.Count];
                        World.H_Chars.Values.CopyTo(BaseCharacters, 0);
                        NewestCOServer.Main.AuthWorker.Listener.Close();
                        NewestCOServer.Main.GameWorker.Listener.Close();
                        EndSession = true;
                        try
                        {
                            foreach (Game.Character C in BaseCharacters)
                            {
                                try
                                {
                                    C.MyClient.Disconnect();
                                    Console.WriteLine(C.Name + " has logged off successfuly.");
                                }
                                catch { continue; }
                            }
                        }
                        catch { }
                        Database.SaveKOs();
                        Console.WriteLine("KOs saved.");
                        Database.SaveEmpire();
                        Console.WriteLine("Empire saved.");
                        Features.Guilds.SaveGuilds();
                        Console.WriteLine("Guilds saved.");
                        DMaps.Save();
                        Features.SkillsClass.Save();
                        Console.WriteLine("Skills saved.");
                        
                        MobThread.Close();
                        ServerStuff.Close();
                        CompanionThread.Close();
                        Database.Dispose();
                        Console.WriteLine("Database disposed.");
                        Console.WriteLine("Click X to close the window.");
                    }
                    if (Cmd[0] == "/expballs")
                        Database.ExpBallReset();
                    if (Cmd[0] == "/expballs2")
                        Database.ExpBallReset();
                    if (Cmd[0] == "/clear")
                        Console.Clear();
                    if (Cmd[0] == "/newacc" && Cmd.Length > 2)
                    {
                        if (Cmd.Length == 3)
                            Database.CreateAccount(Cmd[1], Cmd[2], "");
                        else
                            Database.CreateAccount(Cmd[1], Cmd[2], Cmd[3]);
                    }
                    if (Cmd[0] == "/skilladder")
                    {
                        Extra.SkillAdder E = new NewestCOServer.Extra.SkillAdder();
                        System.Windows.Forms.Application.Run(E);
                    }
                    if (Cmd[0] == "/characters")
                    {
                        Form1 E = new Form1();
                        System.Windows.Forms.Application.Run(E);
                    }
                    if (Cmd[0] == "/accounts")
                    {
                        Form2 E = new Form2();
                        System.Windows.Forms.Application.Run(E);
                    }
                }
            }
            else
            {
                Program.WriteLine("The database folder doesn't exist, cannot start the server.");
                Console.ReadLine();
            }
        }
        static void MobThread_Execute()
        {
            
            try
            {
                if (World.H_Chars.Count > 0)
                {
                    try
                    {
                        foreach (Hashtable H in Game.World.H_Mobs.Values)
                        {
                            foreach (Mob M in H.Values)
                            {
                                M.Step();

                                if (M.PoisonedInfo != null)
                                {
                                    if (DateTime.Now > M.PoisonedInfo.LastAttack.AddSeconds(3))
                                    {
                                        if (M.CurrentHP == 1)
                                        {
                                            M.PoisonedInfo = null;
                                            foreach (Game.Character C in Game.World.H_Chars.Values)
                                                if (M.Loc.Map == C.Loc.Map)
                                                    if (MyMath.PointDistance(M.Loc.X, M.Loc.Y, C.Loc.X, C.Loc.Y) <= 20)
                                                        C.MyClient.AddSend(Packets.Status(M.EntityID, NewestCOServer.Game.Status.Effect, 0));
                                            continue;
                                        }
                                        M.PoisonedInfo.Times--;
                                        M.PoisonedInfo.LastAttack = DateTime.Now;
                                        uint Dmg = (uint)(M.CurrentHP * (10 + M.PoisonedInfo.SpellLevel * 10) / 100);
                                        if (Dmg == 1)
                                            continue;
                                        M.TakeAttack(M, Dmg, AttackType.Melee);
                                        if (M.PoisonedInfo.Times == 0)
                                        {
                                            M.PoisonedInfo = null;
                                            foreach (Game.Character C in Game.World.H_Chars.Values)
                                                if (M.Loc.Map == C.Loc.Map)
                                                    if (MyMath.PointDistance(M.Loc.X, M.Loc.Y, C.Loc.X, C.Loc.Y) <= 20)
                                                        C.MyClient.AddSend(Packets.Status(M.EntityID, NewestCOServer.Game.Status.Effect, 0));
                                        }
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception Exc) { Program.WriteLine(Exc); }
                }
            }
            catch (Exception Exc) { Program.WriteLine(Exc); }
        }
        static bool ExpBallClear = false;
        static void ServerStuff_Execute()
        {
            try
            {
                if (World.BroadCastCount > 0 && DateTime.Now > World.LastBroadCast.AddMinutes(1))
                {
                    BroadCastMessage B = World.BroadCasts[0];

                    for (int i = 0; i < World.BroadCastCount; i++)
                        World.BroadCasts[i] = World.BroadCasts[i + 1];

                    World.BroadCastCount--;

                    World.SendMsgToAll(B.Name, B.Message, 2500, 0);
                    World.LastBroadCast = DateTime.Now;
                    World.CurrentBC = B;
                }
            }
            catch { }
            try
            {
                foreach (Hashtable H in World.H_Items.Values)
                {
                    ArrayList Deleted = new ArrayList();
                    try
                    {
                        foreach (DroppedItem I in H.Values)
                            if (DateTime.Now > I.DropTime.AddSeconds(60))
                                Deleted.Add(I);
                        foreach (DroppedItem I in Deleted)
                            I.Dissappear();
                    }
                    catch { }
                }
            }
            catch { }
            try
            {
                //if (!Features.GuildWars.War && DateTime.Now.Minute == 0 && Database.GWOn.Contains(DateTime.Now.Hour))
                //    Features.GuildWars.StartWar();
            }
            catch { }
            try
            {
                //if (Features.GuildWars.War && DateTime.Now > Features.GuildWars.LastScores.AddSeconds(5))
                //    Features.GuildWars.SendScores();
            }
            catch { }
            try
            {
                if (DateTime.Now.Hour == 0 && !ExpBallClear)
                {
                    Database.ExpBallReset();
                    ExpBallClear = true;
                }
                if (ExpBallClear && DateTime.Now.Hour == 1)
                    ExpBallClear = false;
            }
            catch { }
        }

        static void CompanionThread_Execute()
        {
            try
            {
                if (World.H_Chars.Count > 0)
                {
                    foreach (Companion C in World.H_Companions.Values)
                        try
                        {
                            C.Step();
                        }
                        catch { }
                }
            }
            catch { }
        }
        public static void QuestDropDone(object source, System.Timers.ElapsedEventArgs e)
        {
            try
            {
                if (DropEventTimer != null)
                {
                    if (DropEventType == "dragonball")
                        DropRates.DragonBall = SaveOldRate;
                    else if (DropEventType == "meteor")
                        DropRates.Meteor = SaveOldRate;
                    else if (DropEventType == "minicpbag")
                        DropRates.CPMiniBag = SaveOldRate;
                    else if (DropEventType == "cpbag")
                        DropRates.CPBag = SaveOldRate;

                    Game.World.SendMsgToAll("Server", "Drop " + DropEventType + "s event ended.", 2001, 0);
                    DropEventType = ""; SaveOldRate = 0;
                    DropEventTimer.Stop();
                    DropEventTimer.Close();
                    DropEventTimer = null;
                }
            }
            catch { }
        }
    }
}

its sending me this error (


i`m already press thanks
alielmasry is offline  
Old 03/04/2010, 18:22   #12
 
ImFlamedCOD's Avatar
 
elite*gold: 0
Join Date: Jun 2009
Posts: 378
Received Thanks: 141
There is already a AddItemPos in your source some where. There is a conflict between the 2 of them. Just delete one.
ImFlamedCOD is offline  
Old 03/04/2010, 23:41   #13
 
killersub's Avatar
 
elite*gold: 0
Join Date: May 2009
Posts: 884
Received Thanks: 211
Quote:
Originally Posted by alielmasry View Post
could any one tell me how to fix this error in Program.cs ?

PHP Code:
using System.Threading;
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using NewestCOServer.Game;
namespace 
NewestCOServer
{
    class 
Program
    
{

        public static 
void WriteLine(Exception Exc)
        {
            
Console.WriteLine(Exc.ToString());

            try
            {
                if (!
System.IO.File.Exists("debug." DateTime.Now.Month.ToString() + "." DateTime.Now.Day.ToString() + ".txt"))
                    
System.IO.File.Create("debug." DateTime.Now.Month.ToString() + "." DateTime.Now.Day.ToString() + ".txt").Close();
                
string Text System.IO.File.ReadAllText("debug." DateTime.Now.Month.ToString() + "." DateTime.Now.Day.ToString() + ".txt");
                
Text += Exc.ToString() + "\r\n";
                
System.IO.File.WriteAllText("debug." DateTime.Now.Month.ToString() + "." DateTime.Now.Day.ToString() + ".txt"Text);
            }
            catch { }
        }
        public static 
void WriteLine(string Line)
        {
            try
            {
                
Console.WriteLine(Line);
                if (!
System.IO.File.Exists("debug." DateTime.Now.Month.ToString() + "." DateTime.Now.Day.ToString() + ".txt"))
                    
System.IO.File.Create("debug." DateTime.Now.Month.ToString() + "." DateTime.Now.Day.ToString() + ".txt").Close();
                
string Text System.IO.File.ReadAllText("debug." DateTime.Now.Month.ToString() + "." DateTime.Now.Day.ToString() + ".txt");
                
Text += Line "\r\n";
                
System.IO.File.WriteAllText("debug." DateTime.Now.Month.ToString() + "." DateTime.Now.Day.ToString() + ".txt"Text);
            }
            catch { }
        }
        public static 
void WriteLine()
        {
            try
            {
                
Console.WriteLine();
                if (!
System.IO.File.Exists("debug." DateTime.Now.Month.ToString() + "." DateTime.Now.Day.ToString() + ".txt"))
                    
System.IO.File.Create("debug." DateTime.Now.Month.ToString() + "." DateTime.Now.Day.ToString() + ".txt").Close();
                
string Text System.IO.File.ReadAllText("debug." DateTime.Now.Month.ToString() + "." DateTime.Now.Day.ToString() + ".txt");
                
Text += "\r\n";
                
System.IO.File.WriteAllText("debug." DateTime.Now.Month.ToString() + "." DateTime.Now.Day.ToString() + ".txt"Text);
            }
            catch { }
        }
        public static 
bool EndSession false;
        public static 
double SaveOldRate 0;
        public static 
string DropEventType "";
        public static 
System.Timers.Timer DropEventTimer null;
        public static 
DateTime SystemMsgTime = new DateTime();
        public static 
Random Rnd = new Random();
        public static 
string ConquerPath;
        public static 
Features.QuizShow.MainInfo MainQuizShowInfo;
        static 
void Main(string[] args)

        {
            
Console.Title "Newest CO Server";
            if (
System.IO.Directory.Exists(@"C:\OldCODB"))
            {
                
IniFile I = new IniFile(@"C:\OldCODB\Config.ini");
                
ConquerPath I.ReadString("Database""ConquerPath");
                
Database.DefaultCoords.Add((ushort)1002, new Game.Vector2() { 430380 });
                
Database.DefaultCoords.Add((ushort)1015, new Game.Vector2() { 717571 });
                
Database.DefaultCoords.Add((ushort)1000, new Game.Vector2() { 500650 });
                
Database.DefaultCoords.Add((ushort)1011, new Game.Vector2() { 188264 });
                
Database.DefaultCoords.Add((ushort)1020, new Game.Vector2() { 565562 });
                
Database.AddSkills();
                
Database.LoadItems();                
                
Database.LoadPlusInfo();
                
Database.LoadRevPoints();
                
Database.LoadProfExp();
                
Database.LoadPortals();
                
Database.LoadLevelExp();
                
Database.LoadNPCs();
                
Database.LoadShops();
                
DropRates.Load();
                
Database.ReadAllCharacterStats();
                
Database.LoadKOs();
                
Features.SkillsClass.Load();
                
Features.Guilds.LoadGuilds();
                
DMaps.Load();
                
Database.LoadMobs();
                
Database.LoadCompanions();
                
Features.GuildWars.Init();
                
MainQuizShowInfo = new Features.QuizShow.MainInfo();
                
#region Spawns for robot
                
Game.World.MapDetails = new System.Collections.Hashtable();
                
Game.MapInfo M = new NewestCOServer.Game.MapInfo();
                
M.Spawns = new NewestCOServer.Game.Vector2[5];
                
M.Spawns[0].465;
                
M.Spawns[0].462;
                
M.Spawns[1].604;
                
M.Spawns[1].537;
                
M.Spawns[2].527;
                
M.Spawns[2].701;
                
M.Spawns[3].373;
                
M.Spawns[3].634;
                
M.Spawns[4].141;
                
M.Spawns[4].436;
                
Game.World.MapDetails.Add((ushort)1002M);

                
= new NewestCOServer.Game.MapInfo();
                
M.Spawns = new NewestCOServer.Game.Vector2[4];
                
M.Spawns[0].390;
                
M.Spawns[0].118;
                
M.Spawns[1].359;
                
M.Spawns[1].284;
                
M.Spawns[2].590;
                
M.Spawns[2].337;
                
M.Spawns[3].620;
                
M.Spawns[3].776;
                
Game.World.MapDetails.Add((ushort)1011M);

                
= new NewestCOServer.Game.MapInfo();
                
M.Spawns = new NewestCOServer.Game.Vector2[4];
                
M.Spawns[0].656;
                
M.Spawns[0].635;
                
M.Spawns[1].500;
                
M.Spawns[1].279;
                
M.Spawns[2].289;
                
M.Spawns[2].209;
                
M.Spawns[3].188;
                
M.Spawns[3].457;
                
Game.World.MapDetails.Add((ushort)1020M);

                
= new NewestCOServer.Game.MapInfo();
                
M.Spawns = new NewestCOServer.Game.Vector2[4];
                
M.Spawns[0].606;
                
M.Spawns[0].637;
                
M.Spawns[1].607;
                
M.Spawns[1].500;
                
M.Spawns[2].451;
                
M.Spawns[2].358;
                
M.Spawns[3].186;
                
M.Spawns[3].352;
                
Game.World.MapDetails.Add((ushort)1000M);

                
= new NewestCOServer.Game.MapInfo();
                
M.Spawns = new NewestCOServer.Game.Vector2[4];
                
M.Spawns[0].722;
                
M.Spawns[0].669;
                
M.Spawns[1].519;
                
M.Spawns[1].710;
                
M.Spawns[2].514;
                
M.Spawns[2].539;
                
M.Spawns[3].312;
                
M.Spawns[3].572;
                
Game.World.MapDetails.Add((ushort)1015M);

                
= new NewestCOServer.Game.MapInfo();
                
M.Spawns = new NewestCOServer.Game.Vector2[4];
                
M.Spawns[0].328;
                
M.Spawns[0].616;
                
M.Spawns[1].338;
                
M.Spawns[1].438;
                
M.Spawns[2].102;
                
M.Spawns[2].297;
                
M.Spawns[3].352;
                
M.Spawns[3].286;
                
Game.World.MapDetails.Add((ushort)1001M); 
                
#endregion

                
NewestCOServer.Main.AuthWorker.StartServer(I.ReadString("Database""GameServerIP"));
                
NewestCOServer.Main.GameWorker.StartServer();
                
Database.LoadLottoItems();
                
Program.WriteLine();
                
Program.WriteLine("The server is ready for connections.");
                
Program.WriteLine("Always close the server by pressing Enter, or the important data wont't save.");
                
Database.LoadQuestions();
                
Database.CreateEquipsDrops();
                
Database.LoadEmpire();
                
MyThread CompanionThread = new MyThread();
                
CompanionThread.Execute += new Execute(CompanionThread_Execute);
                
CompanionThread.Start(100);
                
MyThread ServerStuff = new MyThread();
                
ServerStuff.Execute += new Execute(ServerStuff_Execute);
                
ServerStuff.Start(100);
                
MyThread MobThread = new MyThread();
                
MobThread.Execute += new Execute(MobThread_Execute);
                
MobThread.Start(100);
                
World.MobsStart true;
                while (
true)
                {
                    
string Command Console.ReadLine();
                    
string[] Cmd Command.Split(' ');

                    if (
Command == "")
                    {
                        
Console.ReadLine();
                    }
                    if (
Cmd[0] == "/restart")
                    {
                        
Game.Character[] BaseCharacters = new Character[World.H_Chars.Count];
                        
World.H_Chars.Values.CopyTo(BaseCharacters0);

                        
NewestCOServer.Main.AuthWorker.Listener.Close();
                        
NewestCOServer.Main.GameWorker.Listener.Close();
                        
EndSession true;
                        try
                        {
                            foreach (
Game.Character C in BaseCharacters)
                            {
                                try
                                {
                                    
C.MyClient.Disconnect();
                                    
Console.WriteLine(C.Name " has logged off successfuly.");
                                }
                                catch { continue; }
                            }
                        }
                        catch { }
                        
Database.SaveKOs();
                        
Console.WriteLine("KOs saved.");
                        
Database.SaveEmpire();
                        
Console.WriteLine("Empire saved.");
                        
Features.Guilds.SaveGuilds();
                        
Console.WriteLine("Guilds saved.");
                        
Features.SkillsClass.Save();
                        
Console.WriteLine("Skills saved.");
                        
                        
MobThread.Close();
                        
ServerStuff.Close();
                        
CompanionThread.Close();
                        
Database.Dispose();
                        
Console.WriteLine("Database disposed.");
                        
Console.WriteLine("Write /exit or click X to close the window.");
                        
System.Diagnostics.Process.Start("NewestCOServer.exe");
                    }
                    if (
Cmd[0] == "/exit")
                    {
                        
Game.Character[] BaseCharacters = new Character[World.H_Chars.Count];
                        
World.H_Chars.Values.CopyTo(BaseCharacters0);
                        
NewestCOServer.Main.AuthWorker.Listener.Close();
                        
NewestCOServer.Main.GameWorker.Listener.Close();
                        
EndSession true;
                        try
                        {
                            foreach (
Game.Character C in BaseCharacters)
                            {
                                try
                                {
                                    
C.MyClient.Disconnect();
                                    
Console.WriteLine(C.Name " has logged off successfuly.");
                                }
                                catch { continue; }
                            }
                        }
                        catch { }
                        
Database.SaveKOs();
                        
Console.WriteLine("KOs saved.");
                        
Database.SaveEmpire();
                        
Console.WriteLine("Empire saved.");
                        
Features.Guilds.SaveGuilds();
                        
Console.WriteLine("Guilds saved.");
                        
Features.SkillsClass.Save();
                        
Console.WriteLine("Skills saved.");
                        
                        
MobThread.Close();
                        
ServerStuff.Close();
                        
CompanionThread.Close();
                        
Database.Dispose();
                        
Console.WriteLine("Database disposed.");
                        
Console.WriteLine("Click X to close the window.");
                    }
                    if (
Cmd[0] == "/expballs")
                        
Database.ExpBallReset();
                    if (
Cmd[0] == "/expballs2")
                        
Database.ExpBallReset();
                    if (
Cmd[0] == "/clear")
                        
Console.Clear();
                    if (
Cmd[0] == "/newacc" && Cmd.Length 2)
                    {
                        if (
Cmd.Length == 3)
                            
Database.CreateAccount(Cmd[1], Cmd[2], "");
                        else
                            
Database.CreateAccount(Cmd[1], Cmd[2], Cmd[3]);
                    }
                    if (
Cmd[0] == "/skilladder")
                    {
                        
Extra.SkillAdder E = new NewestCOServer.Extra.SkillAdder();
                        
System.Windows.Forms.Application.Run(E);
                    }
                    if (
Cmd[0] == "/characters")
                    {
                        
Form1 E = new Form1();
                        
System.Windows.Forms.Application.Run(E);
                    }
                    if (
Cmd[0] == "/accounts")
                    {
                        
Form2 E = new Form2();
                        
System.Windows.Forms.Application.Run(E);
                    }
                }
            }
            else
            {
                
Program.WriteLine("The database folder doesn't exist, cannot start the server.");
                
Console.ReadLine();
            }
        }
        static 
void MobThread_Execute()
        {
            try
            {
                if (
World.H_Chars.Count 0)
                {
                    try
                    {
                        foreach (
Hashtable H in Game.World.H_Mobs.Values)
                        {
                            foreach (
Mob M in H.Values)
                            {
                                
M.Step();

                                if (
M.PoisonedInfo != null)
                                {
                                    if (
DateTime.Now M.PoisonedInfo.LastAttack.AddSeconds(3))
                                    {
                                        if (
M.CurrentHP == 1)
                                        {
                                            
M.PoisonedInfo null;
                                            foreach (
Game.Character C in Game.World.H_Chars.Values)
                                                if (
M.Loc.Map == C.Loc.Map)
                                                    if (
MyMath.PointDistance(M.Loc.XM.Loc.YC.Loc.XC.Loc.Y) <= 20)
                                                        
C.MyClient.AddSend(Packets.Status(M.EntityIDNewestCOServer.Game.Status.Effect0));
                                            continue;
                                        }
                                        
M.PoisonedInfo.Times--;
                                        
M.PoisonedInfo.LastAttack DateTime.Now;
                                        
uint Dmg = (uint)(M.CurrentHP * (10 M.PoisonedInfo.SpellLevel 10) / 100);
                                        if (
Dmg == 1)
                                            continue;
                                        
M.TakeAttack(MDmgAttackType.Melee);
                                        if (
M.PoisonedInfo.Times == 0)
                                        {
                                            
M.PoisonedInfo null;
                                            foreach (
Game.Character C in Game.World.H_Chars.Values)
                                                if (
M.Loc.Map == C.Loc.Map)
                                                    if (
MyMath.PointDistance(M.Loc.XM.Loc.YC.Loc.XC.Loc.Y) <= 20)
                                                        
C.MyClient.AddSend(Packets.Status(M.EntityIDNewestCOServer.Game.Status.Effect0));
                                        }
                                    }
                                }
                            }
                        }
                    }
                    catch (
Exception Exc) { Program.WriteLine(Exc); }
                }
            }
            catch (
Exception Exc) { Program.WriteLine(Exc); }
        }
        static 
bool ExpBallClear false;
        static 
void ServerStuff_Execute()
        {
            try
            {
                if (
DateTime.Now SystemMsgTime.AddMinutes(1))
                {
                    
Handle_Events();
                    
SystemMsgTime DateTime.Now;
                }
                if (
World.BroadCastCount && DateTime.Now World.LastBroadCast.AddMinutes(1))
                {
                    
BroadCastMessage B World.BroadCasts[0];

                    for (
int i 0World.BroadCastCounti++)
                        
World.BroadCasts[i] = World.BroadCasts[1];

                    
World.BroadCastCount--;

                    
World.SendMsgToAll(B.NameB.Message25000);
                    
World.LastBroadCast DateTime.Now;
                    
World.CurrentBC B;
                }
            }
            catch { }
            try
            {
                foreach (
Hashtable H in World.H_Items.Values)
                {
                    
ArrayList Deleted = new ArrayList();
                    try
                    {
                        foreach (
DroppedItem I in H.Values)
                            if (
DateTime.Now I.DropTime.AddSeconds(60))
                                
Deleted.Add(I);
                        foreach (
DroppedItem I in Deleted)
                            
I.Dissappear();
                    }
                    catch { }
                }
            }
            catch { }
            try
            {
                
//if (!Features.GuildWars.War && DateTime.Now.Minute == 0 && Database.GWOn.Contains(DateTime.Now.Hour))
                //    Features.GuildWars.StartWar();
            
}
            catch { }
            try
            {
                
//if (Features.GuildWars.War && DateTime.Now > Features.GuildWars.LastScores.AddSeconds(5))
                //    Features.GuildWars.SendScores();
            
}
            catch { }
            try
            {
                if (
DateTime.Now.Hour == && !ExpBallClear)
                {
                    
Database.ExpBallReset();
                    
ExpBallClear true;
                }
                if (
ExpBallClear && DateTime.Now.Hour == 1)
                    
ExpBallClear false;
            }
            catch { }
        }
        static 
void Handle_Events()
        {
            switch (
DateTime.Now.Minute)
            {
                case 
7:
                case 
8:
                    
Game.World.SendMsgToAll("GM""GMs have [GM] or [PM] at the end of their names. Don`t trust anyone claiming to be a GM but not having [GM]/[PM] in their names."20110);
                    break;
                case 
19:
                case 
20:
                    
Game.World.SendMsgToAll("GM""File account problems and TQ Point Card purchase problems at SUPPORT on the official site."20110);
                    break;
                case 
31:
                case 
32:
                    
Game.World.SendMsgToAll("GM""Help UnknownMan at Market (212,204) to level up quickly."20110);
                    break;
                case 
43:
                case 
44:
                    
Game.World.SendMsgToAll("GM""Trading of game accounts is illegal and may result in the instant banning of the accounts involved in the trading."20110);
                    break;
                case 
55:
                case 
56:
                    
Game.World.SendMsgToAll("GM""co.91.com is the only official website of CO, which is also the only website where you can purchase Dragonballs."20110);
                    break;
                default:
                    break;
            }
        }
        
        static 
void CompanionThread_Execute()
        {
            try
            {
                if (
World.H_Chars.Count 0)
                {
                    foreach (
Companion C in World.H_Companions.Values)
                        try
                        {
                            
C.Step();
                        }
                        catch { }
                }
            }
            catch { }
        }
        public static 
void QuestDropDone(object sourceSystem.Timers.ElapsedEventArgs e)
        {
            try
            {
                if (
DropEventTimer != null)
                {
                    if (
DropEventType == "dragonball")
                        
DropRates.DragonBall SaveOldRate;
                    else if (
DropEventType == "meteor")
                        
DropRates.Meteor SaveOldRate;
                    else if (
DropEventType == "minicpbag")
                        
DropRates.CPMiniBag SaveOldRate;
                    else if (
DropEventType == "cpbag")
                        
DropRates.CPBag SaveOldRate;

                    
Game.World.SendMsgToAll("Server""Drop " DropEventType "s event ended."20010);
                    
DropEventType ""SaveOldRate 0;
                    
DropEventTimer.Stop();
                    
DropEventTimer.Close();
                    
DropEventTimer null;

            try 
            { 
                if (
DateTime.Now Features.DMScore.LastScores.AddSeconds(1)) 
                    
Features.DMScore.SendScores(); 
            }
            catch { }
        }
    }
}                   <<<<<<<<<<<<<  
im getting error here in this mark 
so what i need to change/edit ?

and here is da pic

usually cuz U added the catch line wrong...when it was suppose 2 b UNDER the line he said not under another code you added...maybe try putting that on top of the code...I'm a newb too sorry ..EITHER that or just add 1 or 2 more brackets after the one underlined in red...
killersub is offline  
Reply


Similar Threads Similar Threads
Error : Invalid Client Program will be terminated plz help
08/26/2017 - Silkroad Online - 16 Replies
When i have install silkroad and the luncher starts it comes up and error invalid client, program will be terminated. what is wrong plz answer :)
[Fehler] Patch? Error? Hier Hilfe! [Error]
12/02/2010 - Combat Arms - 14 Replies
Da ich keine Werbung machen möchte muss ich wohl alles abkopieren... Ich entschuldige mich das ich alles zuspoilern musste aber bei soviel Text....;) 1.Error Codes und ähnliches Da es nach einem neuen Update immer wieder Probleme auftreten, empfehlen wir Euch folgende Liste mit den häufigsten Fehlern durchzugehen: 1. Deinstalliere Combat Arms über Arbeitsplatz-->Software 2. Prüfe ob alle Ordner von Nexon auf der Festplatte gelöscht sind. Wenn nicht lösche...
Error: Please launch first Dekaron program Shortcuts or Minilauncher.exe
07/23/2009 - Dekaron Private Server - 2 Replies
yo... in some clients you can run the Game by opening dekaron.exe in bin folder. but in other servers comes with errors. how can i change that i can run every client with dekaron.exe?



All times are GMT +1. The time now is 14:41.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.