Valhalla Legends Forums Archive | Battle.net Bot Development | OnFlags Squelched Ops

AuthorMessageTime
Tass
Yeah when you get the flags of someone who is opped and is squelched you get 34 so how would you give him the squelched icon instead of the opped icon? this is what i use at the moment..

Private Sub OnFlags(ByVal Name As String, ByVal Flags As Long, ByVal Ping As Long, ByVal Message As String, ByVal Client As String)
If (&H2 And Flags) = &H2 Then
frmMain.lvChannel.ListItems.Remove frmMain.lvChannel.FindItem(Name).Index
frmMain.lvChannel.ListItems.Add 1, , Name, , Icon_ChanOp
If Name = CurrentName Then: Opped = True
AddC vbYellow, Name, vbLightGreen, " has aquired ops."
ElseIf Flags = "0" Then
frmMain.lvChannel.FindItem(Name).SmallIcon = GetIconCode(Client, Flags)
ElseIf (&H10 And Flags) = &H10 Then
frmMain.lvChannel.FindItem(Name).SmallIcon = GetIconCode(Client, Flags)
ElseIf (&H20 And Flags) = &H20 Then
frmMain.lvChannel.FindItem(Name).SmallIcon = Icon_Squelched
End If
frmMain.lvChannel.Refresh
End Sub
November 20, 2005, 11:54 PM
Kp
This is a completely wild idea, but what about checking for the squelch flag before checking for operator status?  Then if he has both, the squelch will take priority.
November 21, 2005, 12:00 AM
Networks
[quote author=Kp link=topic=13304.msg134850#msg134850 date=1132531242]
This is a completely wild idea, but what about checking for the squelch flag before checking for operator status?  Then if he has both, the squelch will take priority.
[/quote]

Kp you're way to wild for my taste.
November 21, 2005, 12:02 AM
Tass
Heh, I thought I tried that maybe not, I'll try it tho.. >:/
November 21, 2005, 12:21 AM
JoeTheOdd
Again, see my ChannelList class. Check for squelch first.

EDIT -
IMPORTANT: Be sure to Exit Function in your GetIcon function, once you return ICN_SQUELCH (or whatever you call it), or ICN_OPS (again, replace name) will overwrite it.
November 21, 2005, 3:08 AM
MyStiCaL
[quote author=Tass link=topic=13304.msg134849#msg134849 date=1132530876]
Yeah when you get the flags of someone who is opped and is squelched you get 34 so how would you give him the squelched icon instead of the opped icon? this is what i use at the moment..

Private Sub OnFlags(ByVal Name As String, ByVal Flags As Long, ByVal Ping As Long, ByVal Message As String, ByVal Client As String)
If (&H2 And Flags) = &H2 Then
frmMain.lvChannel.ListItems.Remove frmMain.lvChannel.FindItem(Name).Index
frmMain.lvChannel.ListItems.Add 1, , Name, , Icon_ChanOp
If Name = CurrentName Then: Opped = True
AddC vbYellow, Name, vbLightGreen, " has aquired ops."
ElseIf Flags = "0" Then
frmMain.lvChannel.FindItem(Name).SmallIcon = GetIconCode(Client, Flags)
ElseIf (&H10 And Flags) = &H10 Then
frmMain.lvChannel.FindItem(Name).SmallIcon = GetIconCode(Client, Flags)
ElseIf (&H20 And Flags) = &H20 Then
frmMain.lvChannel.FindItem(Name).SmallIcon = Icon_Squelched
End If
frmMain.lvChannel.Refresh
End Sub
[/quote]



Private Sub OnFlags(UserName As String, Flags As Long, Message As String, ping As Long)

Dim PingCode As Integer, Icon As Integer
PingCode = GetLagIcon(ping, Flags)
Icon = GetIconCode(Message, Flags)

Dim iIndex As Variant
iIndex = lvChannel.FindItem(UserName).Index
With lvChannel

Select Case Flags

Case Is = 2, 18

        AddChat, &H808080, " -- ", vbYellow, UserName, &HC000&, " has acquired operator status."

            .ListItems.Remove iIndex
            .ListItems.Add 1, , UserName, , BnetIcon.GAVEL
            .ListItems(1).ListSubItems.Add (CInt(1)), , , PingCode

Case 32, 48

            .ListItems.Remove iIndex
            .ListItems.Add iIndex, , UserName, , BnetIcon.SQUELCH
            .ListItems(iIndex).ListSubItems.Add (CInt(1)), , , PingCode

Case Is <> 2 <> 18 <> 32 <> 48

            .ListItems.Remove iIndex
            .ListItems.Add iIndex, , UserName, , Icon
            .ListItems(iIndex).ListSubItems.Add (CInt(1)), , , PingCode       
        End Select
        End With

End Sub

Mine, works great! maybe it would give you an idea.
November 21, 2005, 8:17 AM
HdxBmx27
Why dont you treat flags like the bitmasks they are?
[code]
Public const FLAG_SQU as intager = &H20
Public const FLAG_OPS as intager = &H02

Public const ICONS_SQU as intager = 1
Public const ICONS_OPS as intager = 2

Public Function GetIcon(sStatString as string, iFlags as Long) as Intager
  Dim iReturn as Intager
  If (FLAGS_SQU And iFlags) = FLAGS_SQU Then
     iReturn = ICONS_SQU
  ElseIf (FLAGS_OPS And iFlags) = FLAGS_OPS Then
     iReturn = ICONS_OPS
  '//Add more ElseIf statements for other flags
  End If

  '//Check if the flags give a special icon. Flags take presedance over statstring.
  If not iReturn = 0 Then
     GetIcon = iReturn
     Exit Function
  End if
  '//Do the rest of the icon parsing here
End Function

Private Sub OnFlags(UserName As String, Flags As Long, Message As String, ping As Long)
  Dim iIcon as Intager, iIndex as Intager
  iIcon = GetIcon(Message, Flags)
  iIndex = frmMain.lvChannel.FindItem(Username).Index

  If (Flags And FLAGS_OPS) = FLAGS_OPS Then
     AddChat vbYellow, UserName, vbLightGreen, " has aquired ops."
     frmMain.lvChannel.ListItems.Remove iIndex
     frmMain.lvChannel.ListItems.Add 1, , UserName, iIcon
  ElseIf (Flags And FLAGS_SQU) = FLAGS_SQU Then
     frmMain.lvChannel.ListItem(iIndex).SmallIcon = ICONS_SQU
  End If
  frmMain.lvChannel.refresh
End Sub[/code]   

Wait.. Tass was doing this, but he was trying to get the Icon the wrong way.
The code was more for Mystical, Your Case statement looks extreamly eww.
The main Idea is you should use the flags to determin the icon first, then use the statstring, Then once all fo that is determined. Use the fags to tell witch position to change.

~-~(HDX)~-~
November 21, 2005, 5:43 PM
Tass
Basically I diden't have them in the right order to do so, my "order of operations" were wrong
November 21, 2005, 9:17 PM
FrOzeN
When using StarCraft/BroodWar on Battle.net and you squelch a channel Operator they still show as Ops, as it's setup to have Ops as a higher priority than a Squelched user. Though it's your choice. :)

Also a note to MyStiCaL, that there are more combinations which could occur in your select case. Best to run a Bitwise comparison, like Hdx showed.

[EDIT] Yay for my 69th post. :P
November 22, 2005, 5:39 AM
JoeTheOdd
If you don't use them as a bitmask, you get to have a VERY large amount of cases when you get up to parsing KBK users. Theres a reason this is sent as a DWORD instead of a BYTE. The KBK flag is, IIRC, 0x20000000.
November 22, 2005, 12:50 PM
MyStiCaL
You know its weird to sit here and say somthings wrong with the way i use it, witch in fact i have not had any problems doing prasing n-e thing every thing works perfectly.

and i'd rather use enum over const

Public Enum BNFLAGS
BLIZZ = &H1
Op = &H2
SPKR = &H4
SYSOP = &H8
PLUG = &H10
SQUELCH = &H20
GLASSES = &H40
End Enum
November 26, 2005, 2:31 AM
JoeTheOdd
That made me laugh..

Do some research on bitmasks and you might understand why we say you're doing it wrong. The sample code is written in PHP, but I think you should be able to make out whats going on.

A few more things:
"witch" is an evil person on a broomstick. You mean "which".
The word "I" is always capitalized, at least in English.
"prasing" is what you do to deities ("praising", if you want to get technical). I think you meant "parsing".
November 26, 2005, 4:45 AM
l2k-Shadow
I'm with Joe on this one.
Mystical: You may think yours works well even though you are using a quite complex way to do it and not using bitmasks. Thing is, you do not even cover all the cases which could occur. EX: The Ops Flag could be 2, 18, 34, or 50 and I see you are only covering 2 cases out of those 4. So why write out all those cases and not If (Flags And &H2) = &H2, so yeah if you think your parsing works perfectly, then no you're wrong.
November 26, 2005, 6:31 AM

Search