55using System . Collections . Generic ;
66using System . Linq ;
77using System . Threading . Tasks ;
8- using Sandbox . Engine . Multiplayer ;
8+ using Sandbox . Game . World ;
99using Torch . API . Managers ;
1010using Torch . Commands ;
1111using Torch . Commands . Permissions ;
@@ -183,7 +183,7 @@ public void VoteCount()
183183 StringBuilder sb = new StringBuilder ( ) ;
184184 sb . AppendLine ( $ "Current vote: { voteInProgress } ") ;
185185 sb . AppendLine ( $ "vote Status: { VoteStatus . ToString ( ) } ") ;
186- sb . AppendLine ( $ "vote count: { _voteReg . Count } / player count: { MyMultiplayer . Static . MemberCount - 1 } ") ;
186+ sb . AppendLine ( $ "vote count: { _voteReg . Count } / player count: { MySession . Static . Players . GetOnlinePlayerCount ( ) } ") ;
187187 sb . AppendLine ( $ "vote percent: { votePercent } ") ;
188188 Context . Respond ( sb . ToString ( ) ) ;
189189
@@ -202,7 +202,7 @@ private IEnumerable VoteCountdown(TimeSpan time)
202202 {
203203 Context . Torch . CurrentSession . Managers . GetManager < IChatManagerClient > ( )
204204 . SendMessageAsSelf ( $ "Vote for { voteInProgress } cancelled") ;
205- VoteReset ( ) ;
205+ VoteClear ( ) ;
206206 yield break ;
207207 }
208208
@@ -222,7 +222,7 @@ private IEnumerable VoteCountdown(TimeSpan time)
222222 }
223223 else
224224 {
225- votePercent = ( int ) Math . Round ( ( double ) 100 * ( _voteReg . Count / ( MyMultiplayer . Static . MemberCount - 1 ) ) ) ;
225+ votePercent = ( int ) Math . Round ( ( double ) 100 * ( _voteReg . Count / ( MySession . Static . Players . GetOnlinePlayerCount ( ) ) ) ) ;
226226
227227 if ( votePercent >= command . Percentage )
228228 {
@@ -235,13 +235,28 @@ private IEnumerable VoteCountdown(TimeSpan time)
235235 Context . Torch . CurrentSession . Managers . GetManager < IChatManagerClient > ( )
236236 . SendMessageAsSelf ( $ "Vote for { voteInProgress } failed") ;
237237 }
238- VoteReset ( ) ;
238+ VoteClear ( ) ;
239239 yield break ;
240240 }
241241 }
242242 }
243243
244+ [ Command ( "vote reset" , "Reset all vote logs" ) ]
245+ [ Permission ( MyPromoteLevel . Admin ) ]
244246 public void VoteReset ( )
247+ {
248+ if ( VoteStatus == Status . VoteInProgress )
249+ {
250+ VoteCancel ( ) ;
251+ }
252+ else
253+ VoteClear ( ) ;
254+ VoteClear ( ) ;
255+ votePercent = 0 ;
256+ _votetimeout . Clear ( ) ;
257+ }
258+
259+ public void VoteClear ( )
245260 {
246261 Random rnd = new Random ( ) ;
247262 _cooldown = rnd . Next ( 5 , 30 ) ;
0 commit comments