Exemplo n.º 1
0
        private void ExecuteAction(PluginReaction a)
        {
            if (a == null)
            {
                return;
            }

            LastBackendActivity = DateTime.Now;
            try
            {
                PluginManager.Log("Action for car " + a.CarId + ": " + a.Reaction + " " + a.Text);
                switch (a.Reaction)
                {
                case PluginReaction.ReactionType.None:
                    break;

                case PluginReaction.ReactionType.Whisper:
                    PluginManager.SendChatMessage(a.CarId, a.Text);
                    break;

                case PluginReaction.ReactionType.Broadcast:
                    PluginManager.BroadcastChatMessage(a.Text);
                    break;

                case PluginReaction.ReactionType.Ballast:
                    break;

                case PluginReaction.ReactionType.Pit:
                    break;

                case PluginReaction.ReactionType.Kick:
                {
                    // To be 100% sure we kick the right person we'll have to compare the steam id
                    DriverInfo c;
                    if (this.PluginManager.TryGetDriverInfo(a.CarId, out c))
                    {
                        if (c.IsConnected && c.DriverGuid == a.SteamId)
                        {
                            PluginManager.BroadcastChatMessage("" + c.DriverName + " has been kicked by minorating.com");
                            PluginManager.RequestKickDriverById(a.CarId);
                        }
                    }
                }
                break;

                case PluginReaction.ReactionType.Ban:
                    break;

                case PluginReaction.ReactionType.NextSession:
                    PluginManager.NextSession();
                    break;

                case PluginReaction.ReactionType.RestartSession:
                    PluginManager.RestartSession();
                    break;

                case PluginReaction.ReactionType.AdminCmd:
                    PluginManager.AdminCommand(a.Text);
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Execute action: Error for car " + a.CarId + "/" + a.Text + ": " + ex.Message);
            }
        }