Пример #1
0
        /// <summary>
        /// Called when a shutdown vote ends.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">A <see cref="VoteEndedEventArgs"/> object containing the event data.</param>
        private void OnShutdownVoteEnded(object sender, VoteEndedEventArgs e)
        {
            if (this.shutdownInProgress)
            {
                this.PrintToChatAll($"{(this.autoRestart.AsBool ? "Restart" : "Shutdown")} In Progress");
                return;
            }

            if (e.Percents[0] >= this.votePercent.AsFloat)
            {
                this.LogAction(null, null, "Server shutdown vote succeeded");
                this.PrintToChatAll("Vote Succeeded", e.Percents[0]);
                this.PrintToChatAll(this.autoRestart.AsBool ? "Restarting" : "Shutting Down");
                if (this.shutdownTimer != null)
                {
                    this.shutdownTimer.Dispose();
                }

                this.shutdownInProgress     = true;
                this.countdown              = 0;
                this.shutdownTimer          = new Timer(30000);
                this.shutdownTimer.Elapsed += this.OnShutdownTimerElapsed;
                this.shutdownTimer.Enabled  = true;
            }
            else
            {
                this.LogAction(null, null, "Server shutdown vote failed");
                this.PrintToChatAll("Vote Failed", e.Percents[0]);
            }
        }
Пример #2
0
 /// <summary>
 /// Called when a generic vote ends.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">A <see cref="VoteEndedEventArgs"/> object containing the event data.</param>
 private void OnVoteEnded(object sender, VoteEndedEventArgs e)
 {
     this.PrintToChatAll("Voting has ended");
     for (var i = 0; i < e.Options.Length; i++)
     {
         this.PrintToChatAll("Vote Results", e.Options[i], e.Percents[i], e.Votes[i]);
     }
 }
Пример #3
0
        /// <summary>
        /// Called when a kick vote ends.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">A <see cref="VoteEndedEventArgs"/> object containing the event data.</param>
        private void OnKickVoteEnded(object sender, VoteEndedEventArgs e)
        {
            var target = e.Data as SMClient;

            if (e.Percents[0] >= this.voteKickPercent.AsFloat)
            {
                this.PrintToChatAll("Votekick Succeeded", e.Percents[0], target.PlayerName);
                this.LogAction(null, target, "Vote kick successful, kicked \"{0:L}\"", target);
                SdtdConsole.Instance.ExecuteSync(this.GetString("Vote kicked", target, target.PlayerId), null);
            }
            else
            {
                this.LogAction(null, target, "Kick vote against \"{0:L}\" failed.", target);
                this.PrintToChatAll("Vote Failed", e.Percents[0]);
            }
        }
Пример #4
0
        /// <summary>
        /// Triggeres an event whenever the vote round ended.
        /// </summary>
        /// <param name="e">Argument containing all participants and the "winner"</param>
        protected virtual void VoteEndedEvent(VoteEndedEventArgs e)
        {
            var handler = VoteEnded;

            handler?.Invoke(this, e);
        }