• Welcome to Valhalla Legends Archive.
 

WC3 - Stat Update

Started by BaDDBLooD, April 25, 2004, 10:48 AM

Previous topic - Next topic

BaDDBLooD

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?
There are only two kinds of people who are really fascinating: people who know absolutely everything, and people who know absolutely nothing.

BaDDBLooD

#1
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?
There are only two kinds of people who are really fascinating: people who know absolutely everything, and people who know absolutely nothing.

BaDDBLooD

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

There are only two kinds of people who are really fascinating: people who know absolutely everything, and people who know absolutely nothing.

Spht

#3
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

BaDDBLooD

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...  :(
There are only two kinds of people who are really fascinating: people who know absolutely everything, and people who know absolutely nothing.

BinaryzL

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

BaDDBLooD

There are only two kinds of people who are really fascinating: people who know absolutely everything, and people who know absolutely nothing.

MyndFyre

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.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

BaDDBLooD

i'll assume sence you posted, i can post here

Thanks for the tip, i keep forgetting  ::)
There are only two kinds of people who are really fascinating: people who know absolutely everything, and people who know absolutely nothing.