• Welcome to Valhalla Legends Archive.
 

OnFlags Squelched Ops

Started by Tass, November 20, 2005, 05:54 PM

Previous topic - Next topic

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

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.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

Networks

Quote from: Kp on November 20, 2005, 06:00 PM
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.

Kp you're way to wild for my taste.

Tass

Heh, I thought I tried that maybe not, I'll try it tho.. >:/

Joe[x86]

#4
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.
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

Mystical

Quote from: Tass on November 20, 2005, 05:54 PM
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



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.

Hdx

#6
Why dont you treat flags like the bitmasks they are?

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
   

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)~-~

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

Tass

Basically I diden't have them in the right order to do so, my "order of operations" were wrong

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
~ FrOzeN

Joe[x86]

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.
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

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

Joe[x86]

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".
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

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.
Quote from: replaced on November 04, 2006, 11:54 AM
I dunno wat it means, someone tell me whats ix86 and pmac?
Can someone send me a working bot source (with bnls support) to my email?  Then help me copy and paste it to my bot? ;D
Já jsem byl určenej abych tady žil,
Dával si ovar, křen a k tomu pivo pil.
Tam by ses povídaj jak prase v žitě měl,
Já nechci před nikym sednout si na prdel.

Já nejsem z USA, já nejsem z USA, já vážně nejsem z USA... a snad se proto na mě nezloběj.