samehven...
i've done this... take a look:
Code:
/*
* Created by SharpDevelop.
* User: sams
* Date: 3/8/2009
* Time: 8:03 PM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections;
using System.Threading;
using System.Collections.Generic;
using System.Collections.Specialized;
using CoEmu_v2_GameServer.Connections;
using CoEmu_v2_GameServer.Structs;
using CoEmu_v2_GameServer.Entities;
using OpenSSL;
namespace CoEmu_v2_GameServer
{
/// <summary>
/// Nano, CoEmu v2's Leveling server 'nickname' is hence forth the primary location of threaded operations.
/// This class holds all data which is to be shared amongst connected players, that being said
/// it is here entirely to be a 'dataholder' as seen in CoEmu v2's initial release.
/// </summary>
public static class Nano
{
public const int VIEW_THRESHOLD = 18;
public static string PoleHolder = "None";
public static bool Continue = true;
public static Dictionary<int, ClientSocket> ClientPool = new Dictionary<int, ClientSocket>();
//public static Dictionary<string, ClientSocket> NewCharacters = new Dictionary<string, ClientSocket>();
public static Dictionary<ulong, ConnectionRequest> AuthenticatedLogins = new Dictionary<ulong, ConnectionRequest>();
public static Dictionary<int, Struct.ItemData> Items = new Dictionary<int, Struct.ItemData>();
public static Dictionary<int, Struct.ItemPlusDB> ItemPluses = new Dictionary<int, Struct.ItemPlusDB>();
public static Dictionary<int, MonsterInfo> BaseMonsters = new Dictionary<int, MonsterInfo>();
public static Dictionary<int, Monster> Monsters = new Dictionary<int, Monster>();
public static Dictionary<int, MonsterSpawn> MonsterSpawns = new Dictionary<int, MonsterSpawn>();
public static Dictionary<int, Struct.NPC> Npcs = new Dictionary<int, Struct.NPC>();
public static Dictionary<string, Struct.Portal> Portals = new Dictionary<string, Struct.Portal>();
public static Dictionary<int, Struct.ItemGround> ItemFloor = new Dictionary<int, Struct.ItemGround>();
public static Dictionary<int, Struct.DmapData> Maps = new Dictionary<int, Struct.DmapData>();
public static Dictionary<int, Struct.ServerSkill> ServerSkills = new Dictionary<int, Struct.ServerSkill>();
public static Dictionary<int, Struct.TerrainNPC> TerrainNpcs = new Dictionary<int, Struct.TerrainNPC>();
public static MasterSocket GameServer;
public static MasterSocket AuthServer;
public static System.Random Rand = new System.Random();
public static int TintR = 0;
public static int TintG = 0;
public const int EXP_MULTIPLER = 10;
public const int PROF_MULTIPLER = 10;
public const int SKILL_MULTIPLER = 10;
public static System.Timers.Timer Shutdown;
private static string P = "E7A69EBDF105F2A6BBDEAD7E798F76A209AD73FB466431E2E7352ED262F8C558F10BEFEA977DE9E21DCEE9B04D245F300ECCBBA03E72630556D011023F9E857F", G = "05";
public static OpenSSL.DH ServerKey;
public static System.Timers.Timer GlobalTimer = new System.Timers.Timer();
public static void GenerateKey()
{
Nano.ServerKey = new OpenSSL.DH(OpenSSL.BigNumber.FromHexString(P), OpenSSL.BigNumber.FromHexString(G));
Nano.ServerKey.GenerateKeys();
}
public static void StartServer()
{
GenerateKey();
Struct.LoadItems("items.txt");
Struct.LoadItemPluses("itemadd.ini");
Struct.LoadMaps();
Struct.LoadMonsters();
Struct.LoadNpcs();
Struct.LoadPortals();
Struct.LoadServerskills();
Struct.LoadTNpcs();
GlobalTimer.Interval = 1000;
//Database.Database.PurgeGuilds();
//Please DO NOT REMOVE THIS LINE!
Console.WriteLine("This program is a branch of CoEmu.Nano, property of the CoEmu Foundation.");
//
Console.WriteLine("[GameServer-Init] Creating Game Thread..");
Nano.GameServer = new MasterSocket("GameServer");
new Thread(Nano.GameServer.AcceptNewConnections).Start();
Console.WriteLine("[GameServer-Init](Game Thread) Success.");
Console.WriteLine("[GameServer-Init] Creating Auth Thread..");
Nano.AuthServer = new MasterSocket("AuthServer");
new Thread(Nano.AuthServer.AcceptNewConnections).Start();
Console.WriteLine("[GameServer-Init](Auth Thread) Success.");
ConsoleCommands();
}
public static void ConsoleCommands()
{
Console.WriteLine("Ready for commands.");
string command = Console.ReadLine();
if(command == "#end")
{
Shutdown = new System.Timers.Timer();
Shutdown.Interval = 180000;
Shutdown.AutoReset = false;
Shutdown.Elapsed += delegate { Kill(); };
Shutdown.Start();
CoEmu_v2_GameServer.Packets.ConquerPacket.ToServer(CoEmu_v2_GameServer.Packets.ConquerPacket.Chat(0, "SYSTEM", "ALLUSERS", "[GameServer] Shutting down in 3 minutes.", CoEmu_v2_GameServer.Structs.Struct.ChatType.Talk), 0);
}
else
{
Console.WriteLine("Unknown command.");
ConsoleCommands();
}
}
public static void Kill()
{
CoEmu_v2_GameServer.Packets.ConquerPacket.ToServer(CoEmu_v2_GameServer.Packets.ConquerPacket.Chat(0, "SYSTEM", "ALLUSERS", "[GameServer] Shutting down in 5 seconds.", CoEmu_v2_GameServer.Structs.Struct.ChatType.Talk), 0);
Thread.Sleep(1000);
CoEmu_v2_GameServer.Packets.ConquerPacket.ToServer(CoEmu_v2_GameServer.Packets.ConquerPacket.Chat(0, "SYSTEM", "ALLUSERS", "[GameServer] Shutting down in 4 seconds.", CoEmu_v2_GameServer.Structs.Struct.ChatType.Talk), 0);
Thread.Sleep(1000);
CoEmu_v2_GameServer.Packets.ConquerPacket.ToServer(CoEmu_v2_GameServer.Packets.ConquerPacket.Chat(0, "SYSTEM", "ALLUSERS", "[GameServer] Shutting down in 3 seconds.", CoEmu_v2_GameServer.Structs.Struct.ChatType.Talk), 0);
Thread.Sleep(1000);
CoEmu_v2_GameServer.Packets.ConquerPacket.ToServer(CoEmu_v2_GameServer.Packets.ConquerPacket.Chat(0, "SYSTEM", "ALLUSERS", "[GameServer] Shutting down in 2 seconds.", CoEmu_v2_GameServer.Structs.Struct.ChatType.Talk), 0);
Thread.Sleep(1000);
CoEmu_v2_GameServer.Packets.ConquerPacket.ToServer(CoEmu_v2_GameServer.Packets.ConquerPacket.Chat(0, "SYSTEM", "ALLUSERS", "[GameServer] Shutting down in 1 second.", CoEmu_v2_GameServer.Structs.Struct.ChatType.Talk), 0);
Nano.AuthServer.Close();
Nano.GameServer.Close();
System.Environment.Exit(1);
}
this is my Nano.cs!!
i put this two things there:
public static System.Timers.Timer GlobalTimer = new System.Timers.Timer();
GlobalTimer.Interval = 1000;
also i maked the void for xp circle...
Code:
public static void XpCircle()
{
GlobalTimer.Elapsed += delegate
{
foreach (KeyValuePair<int, ClientSocket> Clients in Nano.ClientPool)
{
ClientSocket CSocket = Clients.Value;
CSocket.Client.XpSkillCounter += 1000;
if (CSocket.Client.XpSkillCounter == 3400)
{
CSocket.Client.XpSkillCounter = 0;
CSocket.Client.XpTime = true;
CSocket.Send(CoEmu_v2_GameServer.Packets.ConquerPacket.Status(CSocket, 2, 16, Struct.StatusTypes.StatusEffect));
}
}
};
}
but if its right where i need to put it? at nano.cs too? and... need more something else... like void for end?