Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: BaDDBLooD on April 25, 2004, 10:48 AM

Title: WC3 - Stat Update
Post by: BaDDBLooD on April 25, 2004, 10:48 AM
This code adds user to userlist



Private Sub ChatBot_OnUser(ByVal username As String, ByVal Flags As Long, ByVal message As String, ByVal Ping As Long)

Dim Blah As New clsBnetBot, I As Integer

With frmMain.lstChannel

   If (BNFLAGS_OP And Flags) = BNFLAGS_OP Then

       .ListItems.Add 1, , username, , Blah.GetIconCode(message, Flags)
       .ListItems(1).ListSubItems.Add , , , Blah.GetPingCode(Ping, Flags)
       .ListItems(1).ToolTipText = username & " [ " & Ping & " ms ] - Flags: " & Flags & " - Moderator"
   
   Else

       .ListItems.Add , , username, , Blah.GetIconCode(message, Flags)
       .ListItems(.ListItems.Count).ListSubItems.Add , , , Blah.GetPingCode(Ping, Flags)
       .ListItems(.ListItems.Count).ToolTipText = " [ " & Ping & " ms ] " & " - Flags: " & Flags
       
   End If
   
End With

frmMain.txtChannelInfo = Bot.CurrentChannel & " ( " & frmMain.lstChannel.ListItems.Count & " )"

End Sub



I want it so it checks the userlist for Duplicates..

Any ideas?
Title: Re:WC3 - Stat Update
Post by: BaDDBLooD on April 25, 2004, 11:25 AM
This is what i came up with.. but it doesn't work!



Private Sub ChatBot_OnUser(ByVal username As String, ByVal Flags As Long, ByVal message As String, ByVal Ping As Long)

Dim Blah As New clsBnetBot, I As Integer

With frmMain.lstChannel

   If (BNFLAGS_OP And Flags) = BNFLAGS_OP Then
   
       For I = 1 To .ListItems.Count
   
           If .ListItems.Item(I).text = username Then
               
               .ListItems.Remove .FindItem(username).Index
               
               AddChat vbGreen, "Stat Update For: " & username
               
               .ListItems.Add 1, , username, , Blah.GetIconCode(message, Flags)
               .ListItems(1).ListSubItems.Add , , , Blah.GetPingCode(Ping, Flags)
               .ListItems(1).ToolTipText = username & " [ " & Ping & " ms ] - Flags: " & Flags & " - Moderator"
                   
           Else
               .ListItems.Add 1, , username, , Blah.GetIconCode(message, Flags)
               .ListItems(1).ListSubItems.Add , , , Blah.GetPingCode(Ping, Flags)
               .ListItems(1).ToolTipText = username & " [ " & Ping & " ms ] - Flags: " & Flags & " - Moderator"
               
           End If
               
       Next I

   Else
   
       For I = 1 To .ListItems.Count
   
           If .ListItems.Item(I).text = username Then
               
               .ListItems.Remove .FindItem(username).Index
               
               AddChat vbGreen, "Stat Update For: " & username
               
               .ListItems.Add , , username, , Blah.GetIconCode(message, Flags)
               .ListItems(.ListItems.Count).ListSubItems.Add , , , Blah.GetPingCode(Ping, Flags)
               .ListItems(.ListItems.Count).ToolTipText = " [ " & Ping & " ms ] " & " - Flags: " & Flags
               
           Else
           
               .ListItems.Add , , username, , Blah.GetIconCode(message, Flags)
               .ListItems(.ListItems.Count).ListSubItems.Add , , , Blah.GetPingCode(Ping, Flags)
               .ListItems(.ListItems.Count).ToolTipText = " [ " & Ping & " ms ] " & " - Flags: " & Flags
                   
           End If
               
       Next I

   End If
   
End With

frmMain.txtChannelInfo = Bot.CurrentChannel & " ( " & frmMain.lstChannel.ListItems.Count & " )"

End Sub



i thought  i knew the problem... anyone?
Title: Re:WC3 - Stat Update
Post by: BaDDBLooD on April 25, 2004, 11:32 AM
THERE .. YEAH!!! GOT IT!!



Private Sub ChatBot_OnUser(ByVal username As String, ByVal Flags As Long, ByVal message As String, ByVal Ping As Long)

Dim Blah As New clsBnetBot, I As Integer

With frmMain.lstChannel

   If (BNFLAGS_OP And Flags) = BNFLAGS_OP Then
   
       For I = 1 To .ListItems.Count
   
           If .ListItems.Item(I).text = username Then
               
               .ListItems.Remove .FindItem(username).Index
               
               AddChat vbGreen, "Stat Update For: " & username
                   
           End If
           
       Next I
       
           .ListItems.Add 1, , username, , Blah.GetIconCode(message, Flags)
           .ListItems(1).ListSubItems.Add , , , Blah.GetPingCode(Ping, Flags)
           .ListItems(1).ToolTipText = username & " [ " & Ping & " ms ] - Flags: " & Flags & " - Moderator"
               
   Else
   
       For I = 1 To .ListItems.Count
   
           If .ListItems.Item(I).text = username Then
               
               .ListItems.Remove .FindItem(username).Index
               
               AddChat vbGreen, "Stat Update For: " & username

           End If
           
       Next I
               
           .ListItems.Add , , username, , Blah.GetIconCode(message, Flags)
           .ListItems(.ListItems.Count).ListSubItems.Add , , , Blah.GetPingCode(Ping, Flags)
           .ListItems(.ListItems.Count).ToolTipText = " [ " & Ping & " ms ] " & " - Flags: " & Flags

   End If
   
End With

frmMain.txtChannelInfo = Bot.CurrentChannel & " ( " & frmMain.lstChannel.ListItems.Count & " )"

End Sub

Title: Re:WC3 - Stat Update
Post by: Spht on April 25, 2004, 11:35 AM
Instead of trying to make sense out of your code, do something like this to remove duplicate and add the name:

With MyListView.ListItems
   For i = .Count To 1 Step -1
       If StrComp(.Item(i), username, vbTextCompare) Then .Remove i
   Next i
   .Add .Count + 1, , username
End With
Title: Re:WC3 - Stat Update
Post by: BaDDBLooD on April 25, 2004, 11:50 AM
Quote from: Spht on April 25, 2004, 11:35 AM
Instead of trying to make sense out of your code, do something like this to remove duplicate and add the name:

With MyListView.ListItems
   For i = .Count To 1 Step -1
       If StrComp(.Item(i), username, vbTextCompare) Then .Remove i
   Next i
   .Add .Count + 1, , username
End With


you just took my entire ego, rolled it up into a ball, and hit me with it...  :(
Title: Re:WC3 - Stat Update
Post by: BinaryzL on April 25, 2004, 11:52 AM
Quote from: BaDDBLooD on April 25, 2004, 11:50 AM
Quote from: Spht on April 25, 2004, 11:35 AM
Instead of trying to make sense out of your code, do something like this to remove duplicate and add the name:

With MyListView.ListItems
   For i = .Count To 1 Step -1
       If StrComp(.Item(i), username, vbTextCompare) Then .Remove i
   Next i
   .Add .Count + 1, , username
End With


you just took my entire ego, rolled it up into a ball, and hit me with it...  :(

I could of told you that code but I had no idea what you were talking about  :-\
Title: Re:WC3 - Stat Update
Post by: BaDDBLooD on April 25, 2004, 12:01 PM
lol no problem
Title: Re:WC3 - Stat Update
Post by: MyndFyre on April 25, 2004, 01:41 PM
Yes, and Baddblood, I'm sure you've seen it before -- in fact, I'm relatively certain that we've told you before -- don't make 3 posts in a row.  If nobody has posted after you, use "Modify" to modify your last post.  Don't keep tacking on posts to "bump" yours up.
Title: Re:WC3 - Stat Update
Post by: BaDDBLooD on April 25, 2004, 01:56 PM
i'll assume sence you posted, i can post here

Thanks for the tip, i keep forgetting  ::)