Valhalla Legends Forums Archive | Battle.net Bot Development | WC3 - Stat Update

AuthorMessageTime
BaDDBLooD
This code adds user to userlist

[code]

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

[/code]

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

Any ideas?
April 25, 2004, 3:48 PM
BaDDBLooD
This is what i came up with.. but it doesn't work!

[code]

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

[/code]

i thought i knew the problem... anyone?
April 25, 2004, 4:25 PM
BaDDBLooD
THERE .. YEAH!!! GOT IT!!

[code]

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

[/code]
April 25, 2004, 4:32 PM
Spht
Instead of trying to make sense out of your code, do something like this to remove duplicate and add the name:

[code]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[/code]
April 25, 2004, 4:35 PM
BaDDBLooD
[quote author=Spht link=board=17;threadid=6469;start=0#msg56837 date=1082910939]
Instead of trying to make sense out of your code, do something like this to remove duplicate and add the name:

[code]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[/code]
[/quote]

you just took my entire ego, rolled it up into a ball, and hit me with it... :(
April 25, 2004, 4:50 PM
BinaryzL
[quote author=BaDDBLooD link=board=17;threadid=6469;start=0#msg56842 date=1082911801]
[quote author=Spht link=board=17;threadid=6469;start=0#msg56837 date=1082910939]
Instead of trying to make sense out of your code, do something like this to remove duplicate and add the name:

[code]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[/code]
[/quote]

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

I could of told you that code but I had no idea what you were talking about :-\
April 25, 2004, 4:52 PM
BaDDBLooD
lol no problem
April 25, 2004, 5:01 PM
Myndfyr
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.
April 25, 2004, 6:41 PM
BaDDBLooD
i'll assume sence you posted, i can post here

Thanks for the tip, i keep forgetting ::)
April 25, 2004, 6:56 PM

Search