Sign in to follow this  
Followers 0
Kaeft

Transcending the 59th minute.....

7 posts in this topic

#1 ·  Posted (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:

Func 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 by Kaeft

Share this post


Link to post
Share on other sites



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 :)

Share this post


Link to post
Share on other sites

enaiman,

... leaving the joy of discovery to you

Love 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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

@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 :)

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by Kaeft

Share this post


Link to post
Share on other sites

Use _TimeToTicks() to create the initial voting-time, after that use _TimeToTicks() to determine the time elapsed in seconds and switch accordingly.

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0