Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Resolving conflict before uploading
  • Loading branch information
N1Ran committed Feb 11, 2019
commit a528dc1b4a1403eaaa42697415614ed4e6e6f085
24 changes: 8 additions & 16 deletions Essentials/Commands/VotingModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ public void VoteReset()
//vote countdown
private IEnumerable VoteCountdown(TimeSpan time)
{
var command = EssentialsPlugin.Instance.Config.AutoCommands.FirstOrDefault(c => c.Name.Equals(voteInProgress));


for (var i = time.TotalSeconds; i >= 0; i--)
Expand All @@ -217,6 +218,7 @@ private IEnumerable VoteCountdown(TimeSpan time)
.SendMessageAsSelf($"Vote for {voteInProgress} cancelled");
voteResult = Status.voteCancel;
VoteEnd();

yield break;
}

Expand All @@ -236,9 +238,8 @@ private IEnumerable VoteCountdown(TimeSpan time)
}
else
{
var command = EssentialsPlugin.Instance.Config.AutoCommands.FirstOrDefault(c => c.Name.Equals(voteInProgress));

if (VoteCount(_voteReg.Count) >= command.Percentage)
var _votePercent = 100 * (_voteReg.Count / MySession.Static.Players.GetOnlinePlayerCount());
if (_votePercent >= command.Percentage)
{
Context.Torch.CurrentSession.Managers.GetManager<IChatManagerClient>()
.SendMessageAsSelf($"Vote for {voteInProgress} is successful");
Expand All @@ -251,26 +252,17 @@ private IEnumerable VoteCountdown(TimeSpan time)
.SendMessageAsSelf($"Vote for {voteInProgress} failed");
voteResult = Status.voteFail;
}
voteResultPercentage = VoteCount(_voteReg.Count);
voteResultPercentage = _votePercent;
VoteEnd();

yield break;
}
}
}

//creating calculation method for reasons

public double VoteCount(double votecount)
{
double playercount = MySession.Static.Players.GetOnlinePlayerCount();
double result = Math.Round(100 * (votecount / playercount));
return result;

}



public void VoteEnd()
{

//Make sure it's all good for next round
VoteStatus = Status.voteStandby;
voteInProgress = null;
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.