public override void Execute(Level level)
 {
     if (level.GetAccountPrivileges() >= GetRequiredAccountPrivileges())
     {
         var clanid = level.GetPlayerAvatar().GetAllianceId();
         if (clanid != 0)
         {
             foreach (
                 var pl in
                 ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId()).GetAllianceMembers())
             {
                 if (pl.GetRole() == 2)
                 {
                     pl.SetRole(4);
                     break;
                 }
             }
             level.GetPlayerAvatar().SetAllianceRole(2);
         }
     }
     else
     {
         var p = new GlobalChatLineMessage(level.GetClient());
         p.SetChatMessage("GameOp command failed. Access to Admin GameOP is prohibited.");
         p.SetPlayerId(0);
         p.SetLeagueId(22);
         p.SetPlayerName("UCS Bot");
         p.Send();
     }
 }
Beispiel #2
0
        /* END OF CONFIG EDITOR TAB*/

        /* MAIL TAB*/

        //Send To Gobal Chat Button
        private void materialRaisedButton9_Click(object sender, EventArgs e)
        {
            foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
            {
                var pm = new GlobalChatLineMessage(onlinePlayer.GetClient());
                pm.SetChatMessage(textBox21.Text);
                pm.SetPlayerId(0);
                pm.SetLeagueId(22);
                pm.SetPlayerName(textBox22.Text);
                pm.Send();
            }
        }
Beispiel #3
0
        private void materialRaisedButton20_Click(object sender, EventArgs e)
        {
            var Name     = textBox1.Text;
            int Interval = Convert.ToInt32(((textBox2.Text + 0) + 0) + 0);
            var Message  = textBox3.Text;

            if (Convert.ToInt32(Interval) < 1)
            {
                MessageBox.Show("The Interval can't be null!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                foreach (Level onlinePlayer in ResourcesManager.m_vOnlinePlayers)
                {
                    var pm = new GlobalChatLineMessage(onlinePlayer.Client)
                    {
                        Message       = Message,
                        HomeId        = 0,
                        CurrentHomeId = 0,
                        LeagueId      = 22,
                        PlayerName    = Name
                    };
                    pm.Send();
                }

                Count++;
                materialLabel13.Text = Convert.ToString(Count);

                T.Interval = Interval;
                T.Elapsed += ((s, o) =>
                {
                    foreach (Level onlinePlayer in ResourcesManager.m_vOnlinePlayers)
                    {
                        var pm = new GlobalChatLineMessage(onlinePlayer.Client)
                        {
                            Message = Message,
                            HomeId = 0,
                            CurrentHomeId = 0,
                            LeagueId = 22,
                            PlayerName = Name
                        };
                        pm.Send();
                    }
                    Count++;
                    materialLabel13.Text = Convert.ToString(Count);
                });
                T.Start();
            }
        }
Beispiel #4
0
        /* END OF CONFIG EDITOR TAB*/

        /* MAIL TAB*/

        //Send To Gobal Chat Button
        private void materialRaisedButton9_Click(object sender, EventArgs e)
        {
            foreach (var onlinePlayer in ResourcesManager.m_vOnlinePlayers)
            {
                var pm = new GlobalChatLineMessage(onlinePlayer.Client)
                {
                    Message       = textBox21.Text,
                    HomeId        = 0,
                    CurrentHomeId = 0,
                    LeagueId      = 22,
                    PlayerName    = textBox22.Text
                };

                pm.Send();
            }
        }
Beispiel #5
0
 public override void Execute(Level level)
 {
     if (level.GetAccountPrivileges() >= GetRequiredAccountPrivileges())
     {
         /* Starting saving of players */
         var pm = new GlobalChatLineMessage(level.GetClient());
         pm.SetChatMessage("Starting saving process of every player!");
         pm.SetPlayerId(0);
         pm.SetLeagueId(22);
         pm.SetPlayerName("UCS Bot");
         pm.Send();
         var levels = DatabaseManager.Instance.Save(ResourcesManager.GetInMemoryLevels());
         levels.Wait();
         var p = new GlobalChatLineMessage(level.GetClient());
         /* Confirmation */
         p.SetChatMessage("All Players are saved!");
         p.SetPlayerId(0);
         p.SetLeagueId(22);
         p.SetPlayerName("UCS Bot");
         p.Send();
         /* Starting saving of Clans */
         var pmm = new GlobalChatLineMessage(level.GetClient());
         pmm.SetPlayerId(0);
         pmm.SetLeagueId(22);
         pmm.SetPlayerName("UCS Bot");
         pmm.SetChatMessage("Starting with saving of every Clan!");
         pmm.Send();
         /* Confirmation */
         var clans = DatabaseManager.Instance.Save(ResourcesManager.GetInMemoryAlliances());
         clans.Wait();
         var pmp = new GlobalChatLineMessage(level.GetClient());
         pmp.SetPlayerId(0);
         pmp.SetLeagueId(22);
         pmp.SetPlayerName("UCS Bot");
         pmp.SetChatMessage("All Clans are saved!");
         pmp.Send();
     }
     else
     {
         var p = new GlobalChatLineMessage(level.GetClient());
         p.SetChatMessage("GameOp command failed. Access to Admin GameOP is prohibited.");
         p.SetPlayerId(0);
         p.SetLeagueId(22);
         p.SetPlayerName("UCS Bot");
         p.Send();
     }
 }
 public override void Execute(Level level)
 {
     if (level.Avatar.AccountPrivileges >= GetRequiredAccountPrivileges())
     {
         if (m_vArgs.Length >= 1)
         {
             GlobalChatLineMessage _MSG = new GlobalChatLineMessage(level.Client);
             _MSG.PlayerName = "Ultrapowa Clash Server";
             _MSG.LeagueId   = 22;
             _MSG.Message    = "Your ID: " + level.Avatar.UserId;
             _MSG.Send();
         }
     }
     else
     {
         SendCommandFailedMessage(level.Client);
     }
 }
Beispiel #7
0
        public override void Execute(Level level)
        {
            if (level.GetAccountPrivileges() >= GetRequiredAccountPrivileges())
            {
                DatabaseManager.Instance.Save(level);

                var p = new GlobalChatLineMessage(level.GetClient());
                p.SetChatMessage("Game Successful Saved!");
                p.SetPlayerId(0);
                p.SetLeagueId(22);
                p.SetPlayerName("CoM Bot");
                p.Send();
            }
            else
            {
                var p = new GlobalChatLineMessage(level.GetClient());
                p.SetChatMessage("GameOp command failed. Access to Admin GameOP is prohibited.");
                p.SetPlayerId(0);
                p.SetLeagueId(22);
                p.SetPlayerName("CoM Bot");
                p.Send();
            }
        }
        public override void Process(Level level)
        {
            if (Message.Length > 0)
            {
                if (Message[0] == '/')
                {
                    var obj = GameOpCommandFactory.Parse(Message);
                    if (obj != null)
                    {
                        var player = "";
                        if (level != null)
                        {
                            player += " (" + level.GetPlayerAvatar().GetId() + ", " +
                                      level.GetPlayerAvatar().GetAvatarName() + ")";
                        }
                        ((GameOpCommand)obj).Execute(level);
                    }
                }
                else
                {
                    if (File.Exists(@"filter.ucs"))
                    {
                        var senderId   = level.GetPlayerAvatar().GetId();
                        var senderName = level.GetPlayerAvatar().GetAvatarName();

                        var badwords = new List <string>();
                        var r        = new StreamReader(@"filter.ucs");
                        var line     = "";
                        while ((line = r.ReadLine()) != null)
                        {
                            badwords.Add(line);
                        }
                        var badword = badwords.Any(s => Message.Contains(s));

                        if (badword)
                        {
                            var p = new GlobalChatLineMessage(level.GetClient());
                            p.SetPlayerId(0);
                            p.SetPlayerName("Chat Filter System");
                            p.SetLeagueId(22);
                            p.SetChatMessage("DETECTED BAD WORD! PLEASE AVOID USING BAD WORDS!");
                            p.Send();
                            return;
                        }

                        Parallel.ForEach((ResourcesManager.GetOnlinePlayers()), (onlinePlayer, l) =>
                        {
                            var p  = new GlobalChatLineMessage(onlinePlayer.GetClient());
                            var p2 = onlinePlayer.GetPlayerAvatar().GetPremium();
                            if (onlinePlayer.GetAccountPrivileges() > 0)
                            {
                                p.SetPlayerName(senderName + " #" + senderId);
                            }
                            else
                            {
                                p.SetPlayerName(senderName);
                            }
                            p.SetChatMessage(Message);
                            p.SetPlayerId(senderId);
                            p.SetLeagueId(level.GetPlayerAvatar().GetLeagueId());
                            p.SetAlliance(ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId()));
                            p.Send();
                            Logger.Write("Chat Message: '" + Message + "' from '" + senderName + "':'" + senderId + "'");
                        });
                    }
                }
            }
        }
        public override void Process(Level level)
        {
            if (Message.Length > 0)
            {
                if (Message[0] == '/')
                {
                    var cmd = (GameOpCommand)GameOpCommandFactory.Parse(Message);
                    cmd?.Execute(level);
                }
                else
                {
                    var senderId   = level.GetPlayerAvatar().GetId();
                    var senderName = level.GetPlayerAvatar().GetAvatarName();

                    if (File.Exists(@"filter.ucs"))
                    {
                        var messageLower = Message.ToLower();
                        var flagged      = false;
                        for (int i = 0; i < s_bannedWords.Length; i++)
                        {
                            if (messageLower.Contains(s_bannedWords[i]))
                            {
                                flagged = true;
                                break;
                            }
                        }

                        if (flagged)
                        {
                            var message = new GlobalChatLineMessage(level.GetClient());
                            message.SetPlayerId(0);
                            message.SetPlayerName("Chat Filter System");
                            message.SetLeagueId(22);
                            message.SetChatMessage("We've detected banned words in your chat message.");
                            message.Send();
                            return;
                        }
                    }

                    var onlinePlayers = ResourcesManager.GetOnlinePlayers();
                    for (int i = 0; i < onlinePlayers.Count; i++)
                    {
                        var player  = onlinePlayers[i];
                        var message = new GlobalChatLineMessage(player.GetClient());

                        if (player.GetAccountPrivileges() > 0)
                        {
                            message.SetPlayerName(senderName + " #" + senderId);
                        }
                        else
                        {
                            message.SetPlayerName(senderName);
                        }

                        message.SetChatMessage(Message);
                        message.SetPlayerId(senderId);
                        message.SetLeagueId(level.GetPlayerAvatar().GetLeagueId());
                        message.SetAlliance(ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId()));
                        message.Send();
                    }
                }
            }
        }
Beispiel #10
0
        public static void CommandRead(string cmd)
        {
            if (cmd == null)
            {
                if (ConfUCS.IsConsoleMode)
                {
                    ManageConsole();
                }
            }
            try
            {
                switch (cmd.ToLower())
                {
                case "/help":
                    Console.WriteLine("/start                             <-- Inicia el servidor");
                    Console.WriteLine("/ban <PlayerID>                    <-- Banear un jugador");

                    Console.WriteLine("/banip <PlayerID>                  <-- Banear un jugador mediante IP");
                    Console.WriteLine("/unban <PlayerID>                  <-- Unbanear un jugador");

                    Console.WriteLine("/unbanip <PlayerID>                <-- Unbanear un jugador");
                    Console.WriteLine("/tempban <PlayerID> <Seconds>      <-- Banea un jugador temporalmente");
                    Console.WriteLine("/tempbanip <PlayerID> <Seconds>    <-- Banea temporalmente un jugador mediante IP");
                    Console.WriteLine("/kick <PlayerID>                   <-- Expulsa un jugador del servidor");

                    Console.WriteLine("/mute <PlayerID>                   <-- Silencia a un jugador");
                    Console.WriteLine("/unmute <PlayerID>                 <-- Quita silencio a jugador");
                    Console.WriteLine("/setlevel <PlayerID> <Level>       <-- Fija un level a un jugador");
                    Console.WriteLine("/update                            <-- Comprueba si hay actualizaciónes disponibles");

                    Console.WriteLine("/say <Text>                        <-- Envia un mensaje a todos los jugadores");
                    Console.WriteLine("/sayplayer <PlayerID> <Text>       <-- Envia un mensaje al jugador especificado");
                    Console.WriteLine("/stop  or   /shutdown              <-- Detiene el servidor y guarda todos los datos");
                    Console.WriteLine("/forcestop                         <-- Fuerza el cierre del servidor !! ATENCION SE PIERDEN LOS DATOS!!");
                    Console.WriteLine("/restart                           <-- Guarda los datos y reinicia el servidor");
                    Console.WriteLine("/send sysinfo                      <-- Envia la información del servidor a los jugadores conectados");
                    Console.WriteLine("/status                            <-- Obtiene el estado el servidor");
                    Console.WriteLine("/uptime                            <-- Obtiene el tiempo activo del servidor");
                    Console.WriteLine("/switch                            <-- Cambiar modo GUI/Console");
                    Console.WriteLine("/clear                             <-- Limpia todos los mensajes de a consola");
                    break;

                case "/start":

                    if (!ConfUCS.IsServerOnline)
                    {
                        ConsoleThread CT = new ConsoleThread();
                        CT.Start();
                    }
                    else
                    {
                        Core.Debug.Write("El servidor esta activo!");
                    }
                    break;

                case "/stop":
                case "/shutdown":

                    Core.Debug.Write("Apagando servidor... Guardando datos, esperare...");

                    foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
                    {
                        var p = new ShutdownStartedMessage(onlinePlayer.GetClient());
                        p.SetCode(5);
                        p.Send();
                    }

                    ConsoleManage.FreeConsole();
                    Environment.Exit(0);
                    break;

                case "/forcestop":

                    Core.Debug.Write("Terminado proceso del servidor... los ultimos datos se perderan!");
                    Process.GetCurrentProcess().Kill();
                    break;

                case "/uptime":

                    Core.Debug.Write("Tiempo servidor iniciado: " + ControlTimer.ElapsedTime);
                    break;

                case "/restart":

                    Core.Debug.Write("Reiniciando servidor....");

                    var 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("JJBreaker Administrador");
                    mail.SetMessage("El servidor se reiniciará en breve.");
                    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("El servidor se reiniciará en breve.");
                        pm.SetPlayerId(0);
                        pm.SetLeagueId(22);
                        pm.SetPlayerName("System Manager");
                        p.Send();
                        ps.Send();
                        pm.Send();
                    }
                    Console.WriteLine("Guaradndo datos...");

                    DatabaseManager.Save(ResourcesManager.GetInMemoryLevels());

                    Console.WriteLine("Restarting now");

                    Process.Start(Application.ResourceAssembly.Location);
                    Process.GetCurrentProcess().Kill();
                    break;

                case "/clear":

                    Core.Debug.Write("Consola limpiada");
                    if (ConfUCS.IsConsoleMode)
                    {
                        Console.Clear();
                    }
                    else
                    {
                        MainWindow.RemoteWindow.RTB_Console.Clear();
                    }
                    break;

                case "/status":

                    Console.WriteLine("Server IP: " + ConfUCS.GetIP() + " on port 9339");
                    Console.WriteLine("IP Address (public): "
                                      + new WebClient().DownloadString("http://bot.whatismyipaddress.com/"));
                    Console.WriteLine("Online Player: " + ResourcesManager.GetOnlinePlayers().Count);
                    Console.WriteLine("Connected Player: " + ResourcesManager.GetConnectedClients().Count);
                    Console.WriteLine("Starting Gold: " + Settings.StartingGold);
                    Console.WriteLine("Starting Gems: " + Settings.StartingGems);
                    var versionData = FingerPrint.version.Split('.');
                    Console.WriteLine("CRS Version: " + versionData[0] + "." + versionData[1] + "." + versionData[2]);
                    if (Convert.ToBoolean(Constants.Patching))
                    {
                        Console.WriteLine("Patch: Active");
                        Console.WriteLine("Patching Server: " + Constants.PatchURL);
                    }
                    else
                    {
                        Console.WriteLine("Patch: Disable");
                    }

                    if (Convert.ToBoolean(Settings.Maintenance))
                    {
                        Console.WriteLine("Maintance Mode: Active");
                        Console.WriteLine("Maintance time: " + Convert.ToInt32(Settings.MaintenanceDuration)
                                          + " Seconds");
                    }
                    else
                    {
                        Core.Debug.Write("Maintance Mode: Disable");
                    }

                    break;

                case "/send sysinfo":

                    Console.WriteLine("Server Status is now sent to all online players");

                    var mail1 = new AllianceMailStreamEntry();
                    mail1.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds);
                    mail1.SetSenderId(0);
                    mail1.SetSenderAvatarId(0);
                    mail1.SetSenderName("System Manager");
                    mail1.SetIsNew(0);
                    mail1.SetAllianceId(0);
                    mail1.SetAllianceBadgeData(0);
                    mail1.SetAllianceName("Legendary Administrator");
                    mail1.SetMessage("Latest Server Status:\nConnected Players:" +
                                     ResourcesManager.GetConnectedClients().Count + "\nIn Memory Alliances:" +
                                     ObjectManager.GetInMemoryAlliances().Count + "\nIn Memory Levels:" +
                                     ResourcesManager.GetInMemoryLevels().Count);
                    mail1.SetSenderLeagueId(22);
                    mail1.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(mail1);
                        p.Send();
                        pm.Send();
                    }
                    break;

                case "/update":
                    UpdateChecker.Check();
                    break;

                case "/kick":
                    var CommGet = cmd.Split(' ');
                    if (CommGet.Length >= 2)
                    {
                        try
                        {
                            var id = Convert.ToInt64(CommGet[1]);
                            var l  = ResourcesManager.GetPlayer(id);
                            if (ResourcesManager.IsPlayerOnline(l))
                            {
                                ResourcesManager.LogPlayerOut(l);
                                var p = new OutOfSyncMessage(l.GetClient());
                                p.Send();
                            }
                            else
                            {
                                Console.WriteLine("Kick failed: id " + id + " not found");
                            }
                        }
                        catch (FormatException)
                        {
                            Console.WriteLine("The given id is not a valid number");
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Kick failed with error: " + ex);
                        }
                    }
                    else
                    {
                        Console.WriteLine("Not enough arguments");
                    }
                    break;

                case "/ban":
                    var CommGet1 = cmd.Split(' ');
                    if (CommGet1.Length >= 2)
                    {
                        try
                        {
                            var id = Convert.ToInt64(CommGet1[1]);
                            var l  = ResourcesManager.GetPlayer(id);
                            if (l != null)
                            {
                                l.SetAccountStatus(99);
                                l.SetAccountPrivileges(0);
                                if (ResourcesManager.IsPlayerOnline(l))
                                {
                                    new OutOfSyncMessage(l.GetClient()).Send();
                                }
                            }
                            else
                            {
                                Console.WriteLine("Ban failed: id " + id + " not found");
                            }
                        }
                        catch (FormatException)
                        {
                            Console.WriteLine("The given id is not a valid number");
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Ban failed with error: " + ex);
                        }
                    }
                    else
                    {
                        Console.WriteLine("Not enough arguments");
                    }
                    break;

                case "/unban":
                    var CommGet2 = cmd.Split(' ');
                    if (CommGet2.Length >= 2)
                    {
                        try
                        {
                            var id = Convert.ToInt64(CommGet2[1]);
                            var l  = ResourcesManager.GetPlayer(id);
                            if (l != null)
                            {
                                l.SetAccountStatus(0);
                            }
                            else
                            {
                                Core.Debug.Write("Unban failed: id " + id + " not found");
                            }
                        }
                        catch (FormatException)
                        {
                            Core.Debug.Write("The given id is not a valid number");
                        }
                        catch (Exception ex)
                        {
                            Core.Debug.Write("Unban failed with error: " + ex);
                        }
                    }
                    else
                    {
                        Core.Debug.Write("Not enough arguments");
                    }
                    break;

                case "/switch":
                    if (ConfUCS.IsConsoleFirst)
                    {
                        Core.Debug.Write("Sorry, you need to launch UCS in GUI mode first.");
                    }
                    else
                    {
                        if (ConfUCS.IsConsoleMode)
                        {
                            ConfUCS.IsConsoleMode = false;
                            ConsoleManage.HideConsole();
                            InterfaceThread.Start();
                            Core.Debug.Write("Switched to GUI");
                            ControlTimer.SwitchTimer();
                        }
                        else
                        {
                            ConfUCS.IsConsoleMode = true;
                            ConsoleManage.ShowConsole();
                            Console.SetOut(AllocateConsole.StandardConsole);
                            MainWindow.RemoteWindow.Hide();
                            Console.Title = ConfUCS.UnivTitle;
                            Core.Debug.Write("Switched to Console");
                            ControlTimer.SwitchTimer();
                            ManageConsole();
                        }
                    }

                    break;

                default:
                    Core.Debug.Write("Unknown command ( " + cmd + " ). Type \"/help\" for a list containing all available commands.");
                    break;
                }
            }
            catch (Exception)
            {
                Core.Debug.Write("Something wrong happens...");

                // throw;
            }

            // else if (cmd.ToLower().StartsWith("/mute"))
            // {
            // var CommGet = cmd.Split(' ');
            // if (CommGet.Length >= 2)
            // {
            // try
            // {
            // var id = Convert.ToInt64(CommGet[1]);
            // var l = ResourcesManager.GetPlayer(id);
            // if (ResourcesManager.IsPlayerOnline(l))
            // {
            // var p = new BanChatTrigger(l.GetClient());
            // p.SetCode(999999999);
            // PacketManager.ProcessOutgoingPacket(p);
            // }
            // else
            // {
            // Console.WriteLineDebug("Chat Mute failed: id " + id + " not found", CoreWriter.level.DEBUGLOG);
            // }
            // }
            // catch (FormatException)
            // {
            // Console.WriteLineDebug("The given id is not a valid number", CoreWriter.level.DEBUGFATAL);
            // }
            // catch (Exception ex)
            // {
            // Console.WriteLineDebug("Chat Mute failed with error: " + ex, CoreWriter.level.DEBUGFATAL);
            // }
            // }
            // else Console.WriteLineDebug("Not enough arguments", CoreWriter.level.DEBUGFATAL);
            // }

            if (ConfUCS.IsConsoleMode)
            {
                ManageConsole();
            }
        }
        public override void Execute(Level level)
        {
            if (level.GetAccountPrivileges() >= GetRequiredAccountPrivileges())
            {
                if (m_vArgs.Length >= 2)
                {
                    try
                    {
                        long  id = Convert.ToInt64(m_vArgs[1]);
                        Level l  = ResourcesManager.GetPlayer(id);
                        if (l != null)
                        {
                            ClientAvatar acc = l.GetPlayerAvatar();
                            Message = "Player Info : \n\n" + "ID = " + id + "\nName = " + acc.GetAvatarName() + "\nCreation Date : " + acc.GetAccountCreationDate() + "\nRegion : " + acc.GetUserRegion() + "\nIP Address : " + l.GetIPAddress();
                            if (acc.GetAllianceId() != 0)
                            {
                                Message = Message + "\nClan Name : " + ObjectManager.GetAlliance(acc.GetAllianceId()).GetAllianceName();
                                switch (acc.GetAllianceRole())
                                {
                                case 1:
                                    Message = Message + "\nClan Role : Member";
                                    break;

                                case 2:
                                    Message = Message + "\nClan Role : Leader";
                                    break;

                                case 3:
                                    Message = Message + "\nClan Role : Elder";
                                    break;

                                case 4:
                                    Message = Message + "\nClan Role : Co-Leader";
                                    break;

                                default:
                                    Message = Message + "\nClan Role : Unknown";
                                    break;
                                }
                            }
                            Message = Message + "\nLevel : " + acc.GetAvatarLevel() + "\nTrophy : " + acc.GetScore() + "\nTown Hall Level : " + (acc.GetTownHallLevel() + 1) + "\nAlliance Castle Level : " + (acc.GetAllianceCastleLevel() + 1);

                            var avatar = level.GetPlayerAvatar();
                            AllianceMailStreamEntry mail = new AllianceMailStreamEntry();
                            mail.SetSenderId(avatar.GetId());
                            mail.SetSenderAvatarId(avatar.GetId());
                            mail.SetSenderName(avatar.GetAvatarName());
                            mail.SetIsNew(2);
                            mail.SetAllianceId(0);
                            mail.SetAllianceBadgeData(1526735450);
                            mail.SetAllianceName("UCS Server Information");
                            mail.SetMessage(Message);
                            mail.SetSenderLevel(avatar.GetAvatarLevel());
                            mail.SetSenderLeagueId(avatar.GetLeagueId());

                            AvatarStreamEntryMessage p = new AvatarStreamEntryMessage(level.GetClient());
                            p.SetAvatarStreamEntry(mail);
                            p.Send();
                        }
                    }
                    catch (Exception)
                    {
                        GlobalChatLineMessage c = new GlobalChatLineMessage(level.GetClient());
                        c.SetChatMessage("Command Failed, Wrong Format Or User Doesn't Exist (/accinfo id).");
                        c.SetPlayerId(level.GetPlayerAvatar().GetId());
                        c.SetLeagueId(22);
                        c.SetPlayerName("Ultrapowa Clash Server");
                        c.Send();
                        return;
                    }
                }
                else
                {
                    GlobalChatLineMessage b = new GlobalChatLineMessage(level.GetClient());
                    b.SetChatMessage("Command Failed, Wrong Format (/accinfo id).");
                    b.SetPlayerId(level.GetPlayerAvatar().GetId());
                    b.SetLeagueId(22);
                    b.SetPlayerName("Ultrapowa Clash Server");
                    b.Send();
                }
            }
        }
Beispiel #12
0
        internal override async void Process()
        {
            if (Message.Length > 0 && Message.Length < 200)
            {
                if (Message[0] == '/')
                {
                    object obj = GameOpCommandFactory.Parse(Message);
                    if (obj != null)
                    {
                        string player = "";
                        if (this.Device.Player != null)
                        {
                            player += " (" + this.Device.Player.Avatar.UserId + ", " +
                                      this.Device.Player.Avatar.AvatarName + ")";
                        }
                        ((GameOpCommand)obj).Execute(this.Device.Player);
                    }
                }
                else
                {
                    long   senderId   = this.Device.Player.Avatar.UserId;
                    string senderName = this.Device.Player.Avatar.AvatarName;

                    bool badword = DirectoryChecker.badwords.Any(s => Message.Contains(s));

                    try
                    {
                        if (badword)
                        {
                            foreach (Level pl in ResourcesManager.m_vOnlinePlayers)
                            {
                                if (pl.Avatar.Region == this.Device.Player.Avatar.Region)
                                {
                                    string NewMessage = "";

                                    for (int i = 0; i < Message.Length; i++)
                                    {
                                        NewMessage += "*";
                                    }

                                    GlobalChatLineMessage p = new GlobalChatLineMessage(pl.Client)
                                    {
                                        PlayerName    = senderName,
                                        Message       = NewMessage,
                                        HomeId        = senderId,
                                        CurrentHomeId = senderId,
                                        LeagueId      = this.Device.Player.Avatar.m_vLeagueId
                                    };

                                    p.SetAlliance(ObjectManager.GetAlliance(this.Device.Player.Avatar.AllianceId));
                                    p.Send();
                                }
                            }
                        }
                        else
                        {
                            foreach (Level onlinePlayer in ResourcesManager.m_vOnlinePlayers)
                            {
                                if (onlinePlayer.Avatar.Region == this.Device.Player.Avatar.Region)
                                {
                                    GlobalChatLineMessage p = new GlobalChatLineMessage(onlinePlayer.Client)
                                    {
                                        PlayerName    = senderName,
                                        Message       = this.Message,
                                        HomeId        = senderId,
                                        CurrentHomeId = senderId,
                                        LeagueId      = this.Device.Player.Avatar.m_vLeagueId
                                    };
                                    p.SetAlliance(ObjectManager.GetAlliance(this.Device.Player.Avatar.AllianceId));
                                    p.Send();
                                    Logger.Write($"Chat Message: '{Message}' from '{senderName}':'{senderId}'");
                                }
                            }
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }
        }