For some reason when I squelch somebody it doesn't assign them the icon; however, I have the same code for updating the users icon for ops updates and that works.
ID_Flags
If Flags = 30 Or Flags = 20 Then
On Error Resume Next
AddChat frmMain.rtbChannel, username & " has been squelched." & vbNewLine, vbYellow
frmMain.lvChannel.ListItems.Remove (frmMain.lvChannel.FindItem(username).Index)
frmMain.lvChannel.ListItems.Add , , username, , ICON_SQUELCH
frmMain.lvChannel.ListItems(frmMain.lvhannel.ListItems.Count).ListSubItems.Add , , ping
frmMain.lvChannel.ForeColor = vbWhite
End If
Edit: Code format came out..weird, but looked good when I previewed
Quote from: Sonic on March 08, 2004, 03:10 PM
For some reason when I squelch somebody it doesn't assign them the icon; however, I have the same code for updating the users icon for ops updates and that works.
ID_Flags
If Flags = 30 Or Flags = 20 Then
On Error Resume Next
AddChat frmMain.rtbChannel, username & " has been squelched." & vbNewLine, vbYellow
frmMain.lvChannel.ListItems.Remove (frmMain.lvChannel.FindItem(username).Index)
frmMain.lvChannel.ListItems.Add , , username, , ICON_SQUELCH
frmMain.lvChannel.ListItems(frmMain.lvhannel.ListItems.Count).ListSubItems.Add , , ping
frmMain.lvChannel.ForeColor = vbWhite
End If
Edit: Code format came out..weird, but looked good when I previewed
I don't think 20 or 30 are correct, I think it's 32 or 34 or both...
I use something like this
ElseIf (Flags And UF_SQUELCHED) = UF_SQUELCHED Then
frmMain.lwChannel.FindItem(User).SmallIcon = ICON_SQUELCH
frmMain.lwChannel.Refresh
Public Const UF_SQUELCHED = &H20
heh. I just finished reading another thread about how you should use symbolic constants and use bitwise testing for flags. Your code does neither of these. A quick rewrite of the first part:
' Assume these constants have been declared to the following values
' Squelched=&H20
' NoUDP=&H10
' Operator=2
if((Flags AND Squelched) <> 0)
' do something to show a squelched icon
' etc. with else-ifs for the other situations. Note the use of AND instead of equality.
To address Eli_1's post, and to provide clarity as to why this failed: 20 and 30 are the correct values for squelched and squelched-no-udp if you write constants in hex. :) However, VB is interpreting those as decimal since you didn't specify otherwise.
If I am correct you dont need to parse OnFlags for the NO UDP do you? I mean b/c you cant be on udp in a channel then change it in the channel without leaving, am I correct?
Edit: Spelling
Alright fixed, I incorporated what Kp and Money said and combined them.
If ((Flags And BNFLAGS_SQUELCH) <> 0) Then
frmMain.lvChannel.FindItem(username).SmallIcon = ICON_SQUELCH
Dim u As Integer
For u = 1 To frmMain.lvChannel.ListItems.Count
If frmMain.lvChannel.ListItems(u).text = username Then
frmMain.lvChannel.ListItems(u).ForeColor = vbRed
End If
Next u
frmMain.lvChannel.Refresh
ElseIf ((Flags And BNFLAGS_OP) <> 0) Then
AddChat frmMain.rtbChannel, username & " has acquired operator status." & vbNewLine, vbYellow
frmMain.lvChannel.ListItems.Remove (frmMain.lvChannel.FindItem(username).Index)
frmMain.lvChannel.ListItems.Add 1, , username, , ICON_GAVEL
frmMain.lvChannel.ListItems(1).ListSubItems.Add , , ping
Else
frmMain.lvChannel.FindItem(username).SmallIcon = GetIcon(product, Flags, username)
Dim ut As Integer
For ut = 1 To frmMain.lvChannel.ListItems.Count
If frmMain.lvChannel.ListItems(ut).text = username Then
frmMain.lvChannel.ListItems(ut).ForeColor = vbWhite
End If
Next ut
frmMain.lvChannel.Refresh
End If
Thanks to you both. :)
Quote from: MoNeY on March 08, 2004, 03:53 PMIf I am correct you dont need to parse OnFlags for the NO UDP do you? I mean b/c you cant be on udp in a channel then change it in the channel without leaving, am I correct?
It's a bit hard to figure what you're asking, but if I understand the question, you are correct. A user cannot change his UDP-support status without reconnecting afaik (and if he can, that's a serious violation of how the real clients do it and could easily be detected by the server).
The only reason to consider the UDP flag in an OnFlags update routine is if you are testing for equality, since having the no-UDP flag does not prohibit you from acquiring other flags. However, as I and others have said several times, testing for equality is a bad idea when dealing with bitmasks. :)
Ok thx for the response and yes that was the right question. Sorry for not making it more clear
Are there any flags I should handle apart from Squelch/Op?
Quote from: Sonic on March 08, 2004, 04:43 PMAre there any flags I should handle apart from Squelch/Op?
You should probably detect Blizzard and SysOp class users, though I doubt you'll ever see a flags-change event for one of them.