Kaeft Posted October 11, 2010 Share Posted October 11, 2010 (edited) Note: full code for all functions related to the vote kick at the very bottom. Ok so I have a "vote system" that stops after 3 minutes from the starting "vote." During the vote it tells how many minutes the vote has been going every minute. the $votearray[$l][5] is defined as @min + 3 Case $votearray[$l][5] <= @MIN $votearray[$l][1] = 0 _IRC_SendMessage(DescritionAndCommand() & "3 minutes have passed since vote started against") _IRC_SendMessage(DescritionAndCommand() & "player: "& $votearray[$l][0]) _IRC_SendMessage(DescritionAndCommand() & "All votes for " & $votearray[$l][0] & " are removed.") $votekickfile = FileOpen($votekicklog,1) FileWriteLine($votekickfile,"Incomplete vote kick: " & $votearray[$l][0] & "," & $votearray[$l][2] & "," & $votearray[$l][3] & "," & $votearray[$l][4]) FileClose($votekickfile) _ArrayDelete2D($votearray, $l) $hasvotename = True ExitLoop This works up until @min is 57 - 59 as $votearray[$l][5] becomes 60 - 62 respectively. It can never be <= @min. As a fix I did this: If $votearray[$l][5] > 59 Then $votearray[$l][5] -= 59 $votearray[$l][5] &= "0" EndIf That causes the problem that $votearray[$l][5] will always be under @min durring the 57-59th minutes when the vote is made. Instantly ending the vote. So as a fix I attempted this: Case ($votearray[$l][5] + 3) < @min If $spamcontrol == False Then UpdateTime() $newspamcontrol = $curMin + 1 $minutesago = @MIN - $votinghourandmin[2] _IRC_SendMessage(DescritionAndCommand() & "vote started for " & $newvotename & " " & "time in" & " minute(s) ago.") $spamcontrol = True ElseIf $spamcontrol == True Then UpdateTime() If $votearray[$l][6] < $curmin Then If $curmin < 59 Then $spamcontrol = False $votearray[$l][6] += 1 If $votearray[$l][6] > 59 Then $votearray[$l][6] -= 59 $votearray[$l][6] &= "0" EndIf Else $spamcontrol = True $votearray[$l][6] += 1 If $votearray[$l][6] > 59 Then $votearray[$l][6] -= 59 $votearray[$l][6] &= "0" EndIf EndIf Elseif $votearray[$l][6] >= $curmin Then $spamcontrol = True EndIf EndIf Seems like it should work The spam control keeps the bot from flooding the chat with "vote started for $name $minutesago" Case $votearray[$l][5] > @MIN If $spamcontrol == False Then UpdateTime() $newspamcontrol = $curMin + 1 $minutesago = @MIN - $votinghourandmin[2] _IRC_SendMessage(DescritionAndCommand() & "vote started for " & $newvotename & " " & $minutesago & " minute(s) ago.") $spamcontrol = True ElseIf $spamcontrol == True Then UpdateTime() If $votearray[$l][6] < $curmin Then $spamcontrol = False $votearray[$l][6] += 1 Elseif $votearray[$l][6] >= $curmin Then $spamcontrol = True EndIf EndIf It still works when the minutes are no where near the 57-59 which is a good thing. It's just that this bug can't go away after a certain amount of time. It just lingers and posts ever minute the negative minutes till the vote. Here is all the code pertaining to the vote system: expandcollapse popupFunc vote($votes,$votestarter) If $votes[1] = $cmdprefix & "vote" and ($votes[2] = "kick" or $votes[2] = "ban") Then Select case $votes[2] = "kick" votekick($votes[3],$votes[4],$votestarter) Case $votes[2] = "ban" EndSelect Else EndIf EndFunc Func votenoreason($votes,$votestarter) If $votes[1] = $cmdprefix & "vote" and ($votes[2] = "kick" or $votes[2] = "ban") Then Select case $votes[2] = "kick" votekick($votes[3],"Generic",$votestarter) Case $votes[2] = "ban" EndSelect Else EndIf EndFunc Func votekick($name,$reason,$voter) $hasvotename = False $votekickubound = UBound($votearray) - 1 For $l = 1 To $votekickubound If $votearray[$l][0] = $name Then ;found the matching name $nameforvotemessaging = $votearray[$l][0] If $votearray[$l][1] < 2 then ;if that name doesn't have to many votes yet... _IRC_SendMessage(DescritionAndCommand() & "1 vote for " & $name & " has been added.") $votearray[$l][1] += 1 ;increase his votes by 1 _IRC_SendMessage(DescritionAndCommand() & "This makes " & $votearray[$l][1] & " total.") $votearray[$l][6] = @MIN if $votearray[$l][3] = "" then $votearray[$l][3] &= $voter Else $votearray[$l][3] &= "," & $voter EndIf If $votearray[$l][4] = "" then $votearray[$l][4] &= $reason Else $votearray[$l][4] &= "," & $reason EndIf $hasvotename = True Else $votearray[$l][3] &= "," & $voter $votearray[$l][4] &= "," & $reason _IRC_SendMessage(DescritionAndCommand() & $name & " is now kicked.") _IRC_SendPrivateMessage("kick " & $name, $ircname); & " For reasons: " & $votearray[$l][4],$ircname) $votearray[$l][1] = 0 ;reset his votes $votekickfile = FileOpen($votekicklog,1) FileWriteLine($votekickfile,$votearray[$l][0] & "," & $votearray[$l][2] & "," & $votearray[$l][3] & "," & $votearray[$l][4]) FileClose($votekickfile) _ArrayDelete2D($votearray, $l) $hasvotename = True ExitLoop EndIf $votehasstarted = True EndIf Next If $hasvotename = False Then ReDim $votearray[UBound($votearray)+1][UBound($votearray,2)] _IRC_SendMessage(DescritionAndCommand() & "1 vote for " & $name & " has been added.") $r = UBound($votearray)-1 $votearray[$r][0] = $name $votearray[$r][1] = 1 $votearray[$r][2] = curtime() $votearray[$r][3] = $voter $votearray[$r][4] = $reason $votearray[$l][6] = @MIN $votehasstarted = True EndIf EndFunc Func findname() $fixproblem = UBound($votearray)-1 If $fixproblem = 0 Then $votehasstarted = False EndIf If $m <= $fixproblem and $votearray[$m][0] <> "" Then $findname = $votearray[$m][0] $m += 1 ElseIf $m > $fixproblem Then $m = 1 EndIf Return $findname if @error Then $votehasstarted = False EndIf EndFunc Func votetime($newvotename) $votetimeubound = UBound($votearray) - 1 For $l = 1 To $votetimeubound If $votearray[$l][0] = $newvotename Then $votedatetime = $votearray[$l][2] $votingtime = StringSplit($votedatetime,"/",1) $voteminhour = $votingtime[4] $votinghourandmin = StringSplit($voteminhour,":") $votehour = $votinghourandmin[1] $votemin = $votinghourandmin[2] + 3 $votearray[$l][5] = $votemin If $votearray[$l][5] > 59 Then $votearray[$l][5] -= 59 $votearray[$l][5] &= "0" EndIf $votehasstarted = True Select Case ($votearray[$l][5] + 3) < @min If $spamcontrol == False Then UpdateTime() $newspamcontrol = $curMin + 1 $minutesago = @MIN - $votinghourandmin[2] _IRC_SendMessage(DescritionAndCommand() & "vote started for " & $newvotename & " " & "time in" & " minute(s) ago.") $spamcontrol = True ElseIf $spamcontrol == True Then UpdateTime() If $votearray[$l][6] < $curmin Then If $curmin <= 59 Then $spamcontrol = False $votearray[$l][6] += 1 If $votearray[$l][6] > 59 Then $votearray[$l][6] -= 59 $votearray[$l][6] &= "0" EndIf Else $spamcontrol = True $votearray[$l][6] += 1 If $votearray[$l][6] > 59 Then $votearray[$l][6] -= 59 $votearray[$l][6] &= "0" EndIf EndIf Elseif $votearray[$l][6] >= $curmin Then $spamcontrol = True EndIf EndIf Case $votearray[$l][5] <= @MIN $votearray[$l][1] = 0 _IRC_SendMessage(DescritionAndCommand() & "3 minutes have passed since vote started against") _IRC_SendMessage(DescritionAndCommand() & "player: "& $votearray[$l][0]) _IRC_SendMessage(DescritionAndCommand() & "All votes for " & $votearray[$l][0] & " are removed.") $votekickfile = FileOpen($votekicklog,1) FileWriteLine($votekickfile,"Incomplete vote kick: " & $votearray[$l][0] & "," & $votearray[$l][2] & "," & $votearray[$l][3] & "," & $votearray[$l][4]) FileClose($votekickfile) _ArrayDelete2D($votearray, $l) ExitLoop $hasvotename = True Case $votearray[$l][5] > @MIN If $spamcontrol == False Then UpdateTime() $newspamcontrol = $curMin + 1 $minutesago = @MIN - $votinghourandmin[2] _IRC_SendMessage(DescritionAndCommand() & "vote started for " & $newvotename & " " & $minutesago & " minute(s) ago.") $spamcontrol = True ElseIf $spamcontrol == True Then UpdateTime() If $votearray[$l][6] < $curmin Then $spamcontrol = False $votearray[$l][6] += 1 Elseif $votearray[$l][6] >= $curmin Then $spamcontrol = True EndIf EndIf EndSelect EndIf Next EndFunc edit: attempting to discover mod() Edited October 11, 2010 by Kaeft Link to comment Share on other sites More sharing options...
enaiman Posted October 11, 2010 Share Posted October 11, 2010 Mod(@MIN,60) ... leaving the joy of discovery to you SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 11, 2010 Moderators Share Posted October 11, 2010 enaiman,... leaving the joy of discovery to youLove it - do you have copyright? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
enaiman Posted October 11, 2010 Share Posted October 11, 2010 @Melba23 ... not yet ... I might get it sometime SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
Kaeft Posted October 11, 2010 Author Share Posted October 11, 2010 (edited) Ok I can see how mod() works... Attempting to put it to use. Doesn't help when there is an intense movie in the back ground lol. Edited October 11, 2010 by Kaeft Link to comment Share on other sites More sharing options...
KaFu Posted October 11, 2010 Share Posted October 11, 2010 Use _TimeToTicks() to create the initial voting-time, after that use _TimeToTicks() to determine the time elapsed in seconds and switch accordingly. OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Kaeft Posted October 11, 2010 Author Share Posted October 11, 2010 In studying both suggestions I happened upon timerdiff and timerinit seeing as my votes already go through a looped array I just stored the timerinit in the array and all is happy now! Woo hoo! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now