コード例 #1
0
ファイル: ShowPlayer.cs プロジェクト: jvlppm/q2Tool
        void Quake_OnStringCmd(Quake sender, CommandEventArgs<StringCmd> e)
        {
            if (e.Command.Message.StartsWith("show"))
            {
                string[] cmd = e.Command.Message.Split(' ');

                if (cmd.Length == 1)
                    Quake.SendToClient(new Print(Print.PrintLevel.High, GetPlayerList()));
                else if (cmd.Length > 3)
                    Quake.SendToClient(new Print(Print.PrintLevel.High, "Usage: show [# [skin] ]\n"));
                else
                {
                    string showSkin = "nut";
                    if (cmd.Length == 3)
                        showSkin = cmd[2];

                    int playerId = int.Parse(cmd[1]);
                    if (!GetPlugin<PAction>().PlayersById.ContainsKey(playerId))
                        Quake.SendToClient(new Print(Print.PrintLevel.High, "Bad player number\n"));
                    else
                    {
                        var player = GetPlugin<PAction>().PlayersById[playerId];
                        Quake.SendToClient(new PlayerInfo(player.Id, player.Name, "male", showSkin));
                        if (!_skins.ContainsKey(player.Name))
                            _skins.Add(player.Name, showSkin);
                        else
                            _skins[player.Name] = showSkin;
                        Client.SendMessage(GetPlugin<PAction>().CurrentPlayer.Name + "\\" + player.Name);
                    }
                }

                e.Command.Message = string.Empty;
            }
        }
コード例 #2
0
ファイル: ShowMessages.cs プロジェクト: jvlppm/q2Tool
        static void QuakeOnPrint(Quake sender, CommandEventArgs<Print> e)
        {
            if (e.Command.Level == Print.PrintLevel.Chat)
            {
                string message = e.Command.Message;
                bool deadMessage = message.StartsWith("[DEAD] ");

                if (deadMessage)
                    message = message.Substring(7);
                bool teamMessage = message.StartsWith("(");

                string player = message.Split(':')[0];
                if (teamMessage) player = player.Trim('(', ')');

                message = string.Join(":", message.Split(':'), 1, message.Split(':').Length - 1).Trim(' ');

                ConsoleColor nickColor = deadMessage ? ConsoleColor.DarkGray : ConsoleColor.Gray;
                lock (SyncLines)
                {
                    Show(nickColor, " {1}{0}{2}: ", player, teamMessage ? "(" : "", teamMessage ? ")" : "");
                    ShowLine(ConsoleColor.DarkGray, message);
                }
            }
            else if (e.Command.Level == Print.PrintLevel.High)
            {
                lock (SyncLines)
                    ShowLine((ConsoleColor)e.Command.Level + 1, e.Command.Message);
            }
        }
コード例 #3
0
ファイル: ShowMessages.cs プロジェクト: jvlppm/q2Tool
 static void QuakeOnServerData(Quake sender, CommandEventArgs<ServerData> e)
 {
     lock (SyncLines)
     {
         ShowLine(ConsoleColor.DarkGreen, "******************************");
         ShowLine(ConsoleColor.DarkGreen, e.Command.LevelName);
     }
 }
コード例 #4
0
ファイル: Client.cs プロジェクト: jvlppm/q2Tool
 public Client(Quake game, string groupName, string playerName)
 {
     _server = game.Server.Ip;
     _playerName = playerName;
     _groupName = groupName;
     MessageSender = new Worker(string.Format("{0} message sender", groupName));
     Quake.OnExit += delegate
     {
         MessageSender.Exit();
     };
     SendMessage(null);
 }
コード例 #5
0
ファイル: SpeedJump.cs プロジェクト: jvlppm/q2Tool
 void Quake_OnUserInfo(Quake sender, CommandEventArgs<Commands.Client.UserInfo> e)
 {
     if (_ignore)
     {
         e.Command.Message = string.Empty;
         _ignore = false;
     }
     else if (e.Command["timescale"] != null && e.Command["timescale"] != "1")
     {
         e.Command.Message = string.Empty;
         _ignore = true;
     }
 }
コード例 #6
0
ファイル: ShowMessages.cs プロジェクト: jvlppm/q2Tool
        static void QuakeOnCenterPrint(Quake sender, CommandEventArgs<CenterPrint> e)
        {
            ConsoleColor messageColor;
            switch (e.Command.Message)
            {
                case "LIGHTS...\n":
                    messageColor = ConsoleColor.Green;
                    break;
                case "CAMERA...\n":
                    messageColor = ConsoleColor.Yellow;
                    break;
                case "ACTION!\n":
                    messageColor = ConsoleColor.Red;
                    break;
                default:
                    messageColor = ConsoleColor.DarkMagenta;
                    break;
            }

            lock (SyncLines)
                ShowCentralizedLine(messageColor, e.Command.Message);
        }
コード例 #7
0
ファイル: ForceProxy.cs プロジェクト: jvlppm/q2Tool
 void Quake_OnClientStringCmd(Quake sender, CommandEventArgs<Commands.Client.StringCmd> e)
 {
     e.Command.Message = e.Command.Message.Replace(_localIp, _serverIp);
 }
コード例 #8
0
ファイル: ForceProxy.cs プロジェクト: jvlppm/q2Tool
 void QuakeOnStuffText(Quake sender, CommandEventArgs<StuffText> e)
 {
     e.Command.Message = e.Command.Message.Replace(_serverIp, _localIp);
 }
コード例 #9
0
ファイル: ShowPlayer.cs プロジェクト: jvlppm/q2Tool
 void Quake_OnPlayerInfo(Quake sender, CommandEventArgs<PlayerInfo> e)
 {
     if (_skins.ContainsKey(e.Command.Name))
         e.Command.Skin = _skins[e.Command.Name];
 }
コード例 #10
0
ファイル: Test.cs プロジェクト: jvlppm/q2Tool
 void Quake_OnServerStuffText(Quake sender, CommandEventArgs<StuffText> e)
 {
     e.Command.Message = e.Command.Message.Replace("allow_download 1", "allow_download 0");
 }
コード例 #11
0
ファイル: Program.cs プロジェクト: jvlppm/q2Tool
        public static void Main(string[] args)
        {
            try
            {
                if (!args.ToList().Contains("--disable-updates"))
                {
                    bool msgOk = false;
                    if (Settings.ReadValue("Update", "CheckUpdates") == "True" || Settings.ReadValue("Update", "CheckUpdates") == string.Empty)
                    {
                        msgOk = true;
                        Console.Write("Checking updates...");
                        var updater = new Updater(Settings.ReadValue("Update", "UpdateUrl"));
                        Settings.WriteValue("Update", "CheckUpdates", "Plugins");

                        if (MainUpdateRequired(updater))
                        {
                            Console.WriteLine("Update required!");
                            updater = new Updater(Settings.ReadValue("Update", "UpdaterUrl"));
                            foreach (var file in updater.GetUpdateFileList())
                                updater.DownloadFile(file);

                            Process.Start("Update.exe", "--wait-process q2Tool --auto-execute \"q2Tool.exe\"");
                            return;
                        }
                    }
                    if (Settings.ReadValue("Update", "CheckUpdates") == "Plugins")
                    {
                        if(!msgOk)
                            Console.Write("Checking updates...");
                        var updater = new Updater(Settings.ReadValue("Update", "UpdateUrl"));
                        Settings.WriteValue("Update", "CheckUpdates", "False");
                        EnableOnlyPlugins(updater);
                        var pluginFiles = updater.GetUpdateFileList();
                        if (pluginFiles.Count > 0)
                        {
                            Console.Write("Downloading plugins..");
                            foreach (var plugin in pluginFiles)
                            {
                                Console.Write(".");
                                updater.DownloadFile(plugin);
                            }
                        }
                        Console.WriteLine("OK");
                    }
                    else
                    {
                        BackgroundUpdateCheck();
                    }
                }
                else
                {
                    BackgroundUpdateCheck();
                }

                LoadPlugins();

                var quake = new Quake(Settings.ReadValue("Game", "Path"))
                {
                    CFG = Settings.ReadValue("Game", "CFG")
                };

                string server = Settings.ReadValue("Game", "DefaultServer");

                for (int i = 0; i < args.Length; i++)
                {
                    if (args[i] == "+connect")
                    {
                        server = args[++i];
                        break;
                    }
                }

                quake.Run(server);

                foreach (Plugin plugin in PluginManager.GetPlugins<Plugin>())
                {
                    try
                    {
                        plugin.Quake = quake;
                        plugin.GameStart();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Plugin {0} could not be loaded: {1}.", plugin.GetType().Name, ex.Message);
                        PluginManager.UnLoadPlugin(plugin);
                    }
                }
            }
            catch (FileNotFoundException ex)
            {
                Settings.WriteValue("Update", "CheckUpdates", "True");
                Console.WriteLine("O arquivo \"{0}\" não foi encontrado.", ex.FileName);
                PluginManager.MessageToPlugin<PLog>(ex);
            }
            catch (Exception ex)
            {
                Settings.WriteValue("Update", "CheckUpdates", "True");
                Exception inner = ex.InnerException;
                Console.WriteLine("Error: {0}", ex.Message);
                while (inner != null)
                {
                    Console.WriteLine(inner.Message);
                    inner = inner.InnerException;
                }
                PluginManager.MessageToPlugin<PLog>(ex);
            }
        }
コード例 #12
0
ファイル: Action.cs プロジェクト: jvlppm/q2Tool
        void Quake_OnServerPrint(Quake sender, CommandEventArgs<Print> e)
        {
            string message = e.Command.Message;

            if (e.Command.Level != Print.PrintLevel.Chat)
            {
                if (OnServerMessage != null)
                    OnServerMessage(this, new ServerMessageEventArgs(e.Command.Message, e.Command.Level));

                if(e.Command.Level == Print.PrintLevel.Medium)
                    CheckPlayerDeath(e.Command.Message);
            }
            else
            {
                if (OnPlayerMessage != null)
                {
                    bool dead = false;
                    if (message.StartsWith("[DEAD] "))
                    {
                        message = message.Substring(7);
                        dead = true;
                    }

                    string nick = message.Substring(0, message.IndexOf(": "));
                    bool team = nick.StartsWith("(") && nick.EndsWith(")") && GetPlayerByName(nick) == null;
                    if (team)
                        nick = nick.Substring(1, nick.Length - 2);
                    if (nick.EndsWith(" "))
                    {
                        Player fixPlayer = GetPlayerByName(nick.Trim(' '));
                        if(fixPlayer != null)
                            fixPlayer.Name = nick;
                    }

                    message = message.Substring(message.IndexOf(": ") + 2).Replace("\n", "").Replace("\r", "");
                    Player player = GetPlayerByName(nick);
                    if (player != null)
                        OnPlayerMessage(this, new PlayerMessageEventArgs(player, message, dead, team, Players));
                }
            }
        }
コード例 #13
0
ファイル: Action.cs プロジェクト: jvlppm/q2Tool
 void Quake_OnServerData(Quake sender, CommandEventArgs<ServerData> e)
 {
     _playerNum = e.Command.PlayerNum;
 }
コード例 #14
0
ファイル: Action.cs プロジェクト: jvlppm/q2Tool
 void Quake_OnServerCenterPrint(Quake sender, CommandEventArgs<CenterPrint> e)
 {
     if (e.Command.Message == "LIGHTS...\n")
     {
         _roundActive = true;
         if (OnRoundBegin != null)
             OnRoundBegin(this, EventArgs.Empty);
     }
 }
コード例 #15
0
ファイル: Action.cs プロジェクト: jvlppm/q2Tool
 void Quake_Connected(Quake sender, CommandEventArgs<Print> e)
 {
     if (OnConnectedToServer != null)
     {
         OnConnectedToServer(this, EventArgs.Empty);
         Quake.OnServerPrint -= Quake_Connected;
     }
 }
コード例 #16
0
ファイル: FakeVideoSettings.cs プロジェクト: jvlppm/q2Tool
 void OnStuffText(Quake sender, CommandEventArgs<Commands.Server.StuffText> e)
 {
     foreach (string var in _values.Keys)
         e.Command.Message = e.Command.Message.Replace(var, _values[var]);
 }