public override void Execute(Level level) { if(level.GetAccountPrivileges() >= GetRequiredAccountPrivileges()) { if(m_vArgs.Length >= 1) { string message = string.Join(" ", m_vArgs.Skip(1)); var avatar = level.GetPlayerAvatar(); AllianceMailStreamEntry mail = new AllianceMailStreamEntry(); mail.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds); mail.SetSenderId(avatar.GetId()); mail.SetSenderAvatarId(avatar.GetId()); mail.SetSenderName(avatar.GetAvatarName()); mail.SetIsNew(0); mail.SetAllianceId(0); mail.SetAllianceBadgeData(0); mail.SetAllianceName("Legendary Administrator"); mail.SetMessage(message); mail.SetSenderLevel(avatar.GetAvatarLevel()); mail.SetSenderLeagueId(avatar.GetLeagueId()); foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers()) { var p = new AvatarStreamEntryMessage(onlinePlayer.GetClient()); p.SetAvatarStreamEntry(mail); PacketManager.ProcessOutgoingPacket(p); } } } else { SendCommandFailedMessage(level.GetClient()); } }
public override void Execute(Level level) { if (level.GetAccountPrivileges() >= GetRequiredAccountPrivileges()) { if (m_vArgs.Length >= 1) { var avatar = level.GetPlayerAvatar(); AllianceMailStreamEntry mail = new AllianceMailStreamEntry(); mail.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds); mail.SetSenderId(0); mail.SetSenderAvatarId(0); mail.SetSenderName("System Admin"); mail.SetIsNew(0); mail.SetAllianceId(0); mail.SetAllianceBadgeData(0); mail.SetAllianceName("System Manager"); mail.SetMessage("System is restarting in a few moments"); mail.SetSenderLevel(500); mail.SetSenderLeagueId(22); foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers()) { var p = new AvatarStreamEntryMessage(onlinePlayer.GetClient()); p.SetAvatarStreamEntry(mail); PacketManager.ProcessOutgoingPacket(p); Console.WriteLine("issue"); } System.Diagnostics.Process.Start(@"tools\ucs-restart.bat"); } } else { SendCommandFailedMessage(level.GetClient()); } }
public override void Execute(Level level) { if (level.GetAccountPrivileges() >= GetRequiredAccountPrivileges()) { if (m_vArgs.Length >= 1) { string message = string.Join("\n", m_vArgs.Skip(1)); AllianceMailStreamEntry mail = new AllianceMailStreamEntry(); mail.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds); mail.SetSenderId(0); mail.SetSenderAvatarId(0); mail.SetSenderName("EuroClash.Net"); mail.SetIsNew(0); mail.SetAllianceId(0); mail.SetAllianceBadgeData(0); mail.SetAllianceName("Automatic Information"); mail.SetMessage("Total Completed Connections: " + ResourcesManager.GetConnectedClients().Count + "\nPlayers Online: " + ResourcesManager.GetOnlinePlayers().Count + "\nIn Memory Alliances: " + ObjectManager.GetInMemoryAlliances().Count + "\nIn Memory Levels: " + ResourcesManager.GetInMemoryLevels().Count); mail.SetSenderLeagueId(22); var p = new AvatarStreamEntryMessage(level.GetClient()); p.SetAvatarStreamEntry(mail); PacketManager.ProcessOutgoingPacket(p); } } else { SendCommandFailedMessage(level.GetClient()); } }
public override void Execute(Level level) { if (level.GetAccountPrivileges() >= GetRequiredAccountPrivileges()) { if (m_vArgs.Length >= 1) { //"Established Connections: " Maybe useless string message = string.Join("\n", m_vArgs.Skip(1)); AllianceMailStreamEntry mail = new AllianceMailStreamEntry(); mail.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds); mail.SetSenderId(0); mail.SetSenderAvatarId(0); mail.SetSenderName("UCS System"); mail.SetIsNew(0); mail.SetAllianceId(0); mail.SetAllianceBadgeData(0); mail.SetAllianceName("Legendary Administrator"); mail.SetMessage("Latest Server Status:\nConnected Players:" + ResourcesManager.GetConnectedClients().Count + "\nIn Memory Alliances:" + ObjectManager.GetInMemoryAlliances().Count + "\nIn Memory Levels:" + ResourcesManager.GetInMemoryLevels().Count); mail.SetSenderLeagueId(22); foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers()) { var p = new AvatarStreamEntryMessage(onlinePlayer.GetClient()); p.SetAvatarStreamEntry(mail); PacketManager.ProcessOutgoingPacket(p); } } } else { SendCommandFailedMessage(level.GetClient()); } }
public override void Execute(Level level) { if (level.GetAccountPrivileges() >= GetRequiredAccountPrivileges()) { if (m_vArgs.Length >= 1) { string message = string.Join("\n", m_vArgs.Skip(1)); AllianceMailStreamEntry mail = new AllianceMailStreamEntry(); mail.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds); mail.SetSenderId(0); mail.SetSenderAvatarId(0); mail.SetSenderName("EuroClash.Net"); mail.SetIsNew(0); mail.SetAllianceId(0); mail.SetAllianceBadgeData(0); mail.SetAllianceName("Automatic Information"); mail.SetMessage("/info72 - Shows Server Statistics \n/refill - Refill Resources \n/changelog - View Last Updates"); mail.SetSenderLeagueId(22); var p = new AvatarStreamEntryMessage(level.GetClient()); p.SetAvatarStreamEntry(mail); PacketManager.ProcessOutgoingPacket(p); } } else { SendCommandFailedMessage(level.GetClient()); } }
public Gestiune() { while (true) { Console.WriteLine(""); string line = Console.ReadLine(); if (line == "/shutdown") { foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers()) { var p = new ShutdownStartedMessage(onlinePlayer.GetClient()); p.SetCode(5); PacketManager.ProcessOutgoingPacket(p); } Console.WriteLine("Message has been send to the user"); } else if (line == "/sysinfo") { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Server Status is now sent to all online players"); AllianceMailStreamEntry mail = new AllianceMailStreamEntry(); mail.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds); mail.SetSenderId(0); mail.SetSenderAvatarId(0); mail.SetSenderName("System Manager"); mail.SetIsNew(0); mail.SetAllianceId(0); mail.SetAllianceBadgeData(0); mail.SetAllianceName("Legendary Administrator"); mail.SetMessage("Latest Server Status:\nConnected Players:" + ResourcesManager.GetConnectedClients().Count + "\nIn Memory Alliances:" + ObjectManager.GetInMemoryAlliances().Count + "\nIn Memory Levels:" + ResourcesManager.GetInMemoryLevels().Count); mail.SetSenderLeagueId(22); mail.SetSenderLevel(500); foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers()) { var p = new AvatarStreamEntryMessage(onlinePlayer.GetClient()); var pm = new GlobalChatLineMessage(onlinePlayer.GetClient()); pm.SetChatMessage("Our current Server Status is now sent at your mailbox!"); pm.SetPlayerId(0); pm.SetLeagueId(22); pm.SetPlayerName("System Manager"); p.SetAvatarStreamEntry(mail); PacketManager.ProcessOutgoingPacket(p); PacketManager.ProcessOutgoingPacket(pm); } Console.ForegroundColor = ConsoleColor.White; } } }
public override void Process(Level level) { if (Convert.ToBoolean(ConfigurationManager.AppSettings["maintenanceMode"])) { var p = new LoginFailedMessage(this.Client); p.SetErrorCode(10); PacketManager.ProcessOutgoingPacket(p); return; } string[] versionData = ConfigurationManager.AppSettings["clientVersion"].Split('.'); if(versionData.Length >= 2) { if(m_vClientMajorVersion != Convert.ToInt32(versionData[0]) || m_vClientBuild != Convert.ToInt32(versionData[1])) { var p = new LoginFailedMessage(this.Client); p.SetErrorCode(8); p.SetUpdateURL("market://details?id=com.supercell.clashofclans"); PacketManager.ProcessOutgoingPacket(p); return; } } else { Debugger.WriteLine("Connection failed. UCS config key clientVersion is not properly set."); } level = ResourcesManager.GetPlayer(m_vAccountId); if(level != null) { if(level.GetAccountStatus() == 99) { var p = new LoginFailedMessage(this.Client); p.SetErrorCode(11); PacketManager.ProcessOutgoingPacket(p); return; } } if(Convert.ToBoolean(ConfigurationManager.AppSettings["useCustomPatch"])) { if (m_vResourceSha != ObjectManager.FingerPrint.sha) { var p = new LoginFailedMessage(this.Client); p.SetErrorCode(7); p.SetResourceFingerprintData(ObjectManager.FingerPrint.SaveToJson()); p.SetContentURL(ConfigurationManager.AppSettings["patchingServer"]); p.SetUpdateURL("market://details?id=com.supercell.clashofclans"); PacketManager.ProcessOutgoingPacket(p); return; } } this.Client.ClientSeed = m_vClientSeed; PacketManager.ProcessOutgoingPacket(new SessionKeyMessage(this.Client)); //Console.WriteLine("Debug: Retrieve Player Data for player " + auth.PlayerId.ToString()); //New player if (level == null) { level = ObjectManager.CreateAvatar(m_vAccountId); byte[] tokenSeed = new byte[20]; new Random().NextBytes(tokenSeed); SHA1 sha = new SHA1CryptoServiceProvider(); m_vPassToken = BitConverter.ToString(sha.ComputeHash(tokenSeed)).Replace("-",""); } //if (level.GetAccountPrivileges() > 0) // level.GetPlayerAvatar().SetLeagueId(21); //if (level.GetAccountPrivileges() > 4) // level.GetPlayerAvatar().SetLeagueId(22); if (level.GetPlayerAvatar().GetScore() >= 400 && level.GetPlayerAvatar().GetScore() <= 800) { level.GetPlayerAvatar().SetLeagueId(3); } else if (level.GetPlayerAvatar().GetScore() >= 801 && level.GetPlayerAvatar().GetScore() <= 1400) { level.GetPlayerAvatar().SetLeagueId(6); } else if (level.GetPlayerAvatar().GetScore() >= 1401 && level.GetPlayerAvatar().GetScore() <= 2000) { level.GetPlayerAvatar().SetLeagueId(9); } else if (level.GetPlayerAvatar().GetScore() >= 2001 && level.GetPlayerAvatar().GetScore() <= 2600) { level.GetPlayerAvatar().SetLeagueId(12); } else if (level.GetPlayerAvatar().GetScore() >= 2601 && level.GetPlayerAvatar().GetScore() <= 3200) { level.GetPlayerAvatar().SetLeagueId(15); } else if (level.GetPlayerAvatar().GetScore() >= 3201 && level.GetPlayerAvatar().GetScore() <= 4099) { level.GetPlayerAvatar().SetLeagueId(18); } else if (level.GetPlayerAvatar().GetScore() >= 4100) { level.GetPlayerAvatar().SetLeagueId(21); } ResourcesManager.LogPlayerIn(level, this.Client); level.Tick(); var loginOk = new LoginOkMessage(this.Client); var avatar = level.GetPlayerAvatar(); loginOk.SetAccountId(avatar.GetId()); loginOk.SetPassToken(m_vPassToken); loginOk.SetServerMajorVersion(m_vClientMajorVersion); loginOk.SetServerBuild(m_vClientBuild); loginOk.SetContentVersion(m_vClientContentVersion); loginOk.SetServerEnvironment("prod"); loginOk.SetDaysSinceStartedPlaying(10); loginOk.SetServerTime(Math.Round((level.GetTime().Subtract(new DateTime(1970, 1, 1))).TotalSeconds * 1000).ToString()); loginOk.SetAccountCreatedDate("1414003838000"); loginOk.SetStartupCooldownSeconds(0); loginOk.SetCountryCode("FR"); PacketManager.ProcessOutgoingPacket(loginOk); if (ResourcesManager.IsPlayerOnline(level)) { AllianceMailStreamEntry mail = new AllianceMailStreamEntry(); mail.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds); mail.SetSenderId(0); mail.SetSenderAvatarId(0); mail.SetSenderName("EuroClash.Net"); mail.SetIsNew(0); mail.SetAllianceId(0); mail.SetAllianceBadgeData(0); mail.SetAllianceName("Automatic Information"); mail.SetMessage("Welcome to EuroClash ! \nTo see available commands type /help \n\nSaveGame is fully automatic, you don't have to type anything, commands like /savegame or ./savegame doesn't exist, all commands are available on /help\n\nTrophies are randomly given on first login, this will be fixed soon.\n\nNow Clans calculate trophies of players, 50% of their trophies will be added to clan trophies, still kinda bugged, we're testing with simple math. Clan Owner's trophies are not added (bug).\n\nServer is currently in Alpha, to see bugfixes please visit http://euroclash.net ChangeLog Section!"); mail.SetSenderLeagueId(22); var abe = new AvatarStreamEntryMessage(level.GetClient()); abe.SetAvatarStreamEntry(mail); PacketManager.ProcessOutgoingPacket(abe); } //level.GetPlayerAvatar().SetResourceCount(ObjectManager.DataTables.GetResourceByName("Diamonds"), Convert.ToInt32(1000000)); Alliance alliance = ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId()); if (alliance == null) level.GetPlayerAvatar().SetAllianceId(0); PacketManager.ProcessOutgoingPacket(new OwnHomeDataMessage(this.Client, level)); if (alliance != null) PacketManager.ProcessOutgoingPacket(new AllianceStreamMessage(this.Client, alliance)); }
public Menu() { while (true) { Console.WriteLine(""); string line = Console.ReadLine(); if (line == "/shutdown") { foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers()) { var p = new ShutdownStartedMessage(onlinePlayer.GetClient()); p.SetCode(5); PacketManager.ProcessOutgoingPacket(p); } Console.WriteLine("Message has been send to the user"); } else if (line == "/clear") { Console.Clear(); } else if (line == "/restart") { AllianceMailStreamEntry mail = new AllianceMailStreamEntry(); mail.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds); mail.SetSenderId(0); mail.SetSenderAvatarId(0); mail.SetSenderName("System Manager"); mail.SetIsNew(0); mail.SetAllianceId(0); mail.SetAllianceBadgeData(0); mail.SetAllianceName("Legendary Administrator"); mail.SetMessage("System is about to restart in a few moments."); mail.SetSenderLevel(500); mail.SetSenderLeagueId(22); foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers()) { var pm = new GlobalChatLineMessage(onlinePlayer.GetClient()); var ps = new ShutdownStartedMessage(onlinePlayer.GetClient()); var p = new AvatarStreamEntryMessage(onlinePlayer.GetClient()); ps.SetCode(5); p.SetAvatarStreamEntry(mail); pm.SetChatMessage("System is about to restart in a few moments."); pm.SetPlayerId(0); pm.SetLeagueId(22); pm.SetPlayerName("System Manager"); PacketManager.ProcessOutgoingPacket(p); PacketManager.ProcessOutgoingPacket(ps); PacketManager.ProcessOutgoingPacket(pm); } Console.WriteLine("System Restarting...."); System.Diagnostics.Process.Start(@"tools\ucs-restart.bat"); } else if (line == "/status") { string hostName = Dns.GetHostName(); string IPM = Dns.GetHostByName(hostName).AddressList[0].ToString(); Console.WriteLine("Server IP : " + IPM + " on port 9339"); Console.WriteLine("Players Online : " + ResourcesManager.GetOnlinePlayers().Count); Console.WriteLine("Starting Gold : " + Int32.Parse(ConfigurationManager.AppSettings["StartingGold"])); Console.WriteLine("Starting Elixir : " + Int32.Parse(ConfigurationManager.AppSettings["StartingElixir"])); Console.WriteLine("Starting Dark Elixir : " + Int32.Parse(ConfigurationManager.AppSettings["StartingDarkElixir"])); Console.WriteLine("Starting Gems : " + Int32.Parse(ConfigurationManager.AppSettings["StartingGems"])); Console.WriteLine("CoC Version : " + ConfigurationManager.AppSettings["ClientVersion"]); if (Convert.ToBoolean(ConfigurationManager.AppSettings["useCustomPatch"])) { Console.WriteLine("Patch : Active"); Console.WriteLine("Patching Server : " + ConfigurationManager.AppSettings["patchingServer"]); } else { Console.WriteLine("Patch : Disable"); } if (Convert.ToBoolean(ConfigurationManager.AppSettings["maintenanceMode"])) { Console.WriteLine("Maintance Mode : Active"); Console.WriteLine("Maintance time : " + (Convert.ToInt32(ConfigurationManager.AppSettings["maintenanceTimeleft"])) + " Seconds"); } else { Console.WriteLine("Maintance Mode : Disable"); } } else if (line == "/sysinfo") { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Server Status is now sent to all online players"); AllianceMailStreamEntry mail = new AllianceMailStreamEntry(); mail.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds); mail.SetSenderId(0); mail.SetSenderAvatarId(0); mail.SetSenderName("System Manager"); mail.SetIsNew(0); mail.SetAllianceId(0); mail.SetAllianceBadgeData(0); mail.SetAllianceName("Legendary Administrator"); mail.SetMessage("Latest Server Status:\nConnected Players:" + ResourcesManager.GetConnectedClients().Count + "\nIn Memory Alliances:" + ObjectManager.GetInMemoryAlliances().Count + "\nIn Memory Levels:" + ResourcesManager.GetInMemoryLevels().Count); mail.SetSenderLeagueId(22); mail.SetSenderLevel(500); foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers()) { var p = new AvatarStreamEntryMessage(onlinePlayer.GetClient()); var pm = new GlobalChatLineMessage(onlinePlayer.GetClient()); pm.SetChatMessage("Our current Server Status is now sent at your mailbox!"); pm.SetPlayerId(0); pm.SetLeagueId(22); pm.SetPlayerName("System Manager"); p.SetAvatarStreamEntry(mail); PacketManager.ProcessOutgoingPacket(p); PacketManager.ProcessOutgoingPacket(pm); } Console.ForegroundColor = ConsoleColor.White; } else if (line == "/help") { Console.WriteLine(""); Console.WriteLine("Available commands :"); Console.WriteLine(""); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("/restart - This commands restart server and sending online player info about it."); Console.WriteLine(""); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("/shutdown - This commands fully close the server with message after five minutes."); Console.WriteLine(""); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("/status - This commands show informations about the server."); Console.WriteLine(""); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("/clear - Clean the emulator screen"); Console.WriteLine(""); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("/help - This commands show a list of available commands."); Console.WriteLine(""); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("/sysinfo - This command will send the current Server Status to all online players."); Console.ForegroundColor = ConsoleColor.White; } else { Console.WriteLine(""); Console.WriteLine("Available commands :"); Console.WriteLine(""); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("/restart - This commands restart server and sending online player info about it."); Console.WriteLine(""); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("/shutdown - This commands fully close the server with message after five minutes."); Console.WriteLine(""); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("/status - This commands show informations about the server."); Console.WriteLine(""); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("/clear - Clean the emulator screen"); Console.WriteLine(""); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("/help - This commands show a list of available commands."); Console.WriteLine(""); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("/sysinfo - This command will send the current Server Status to all online players."); Console.ForegroundColor = ConsoleColor.White; } } }