• Welcome to Valhalla Legends Archive.
 

Channel ops and ping

Started by TeEhEiMaN, June 18, 2004, 08:42 PM

Previous topic - Next topic

TeEhEiMaN

 I need help with setting the ops users to the top of the channel list, heres my code im useing for my channel list. Also what would be the best way for adding a ping? im not looking to do the bars or anything more someing just like the actual ping so i can just do like  ,, Ping at the end. Oh ya and i knoew some clients are missing =P


If Flag = 2 Or Flag = 18 Then
       Form1.Channel.ListItems.Add 1, , Username, , 1
         If Form1.Channel.FindItem(Username) <> "" Then Exit Sub
        ElseIf Client = "PXES" Then
       Form1.Channel.ListItems.Add 1, , Username, , 9
               ElseIf Client = "RATS" Then
       Form1.Channel.ListItems.Add 1, , Username, , 6
               ElseIf Client = "NB2W" Then
       Form1.Channel.ListItems.Add 1, , Username, , 10
               ElseIf Client = "VD2D" Then
       Form1.Channel.ListItems.Add 1, , Username, , 5
               ElseIf Client = "PX2D" Then
       Form1.Channel.ListItems.Add 1, , Username, , 13
                       ElseIf Client = "3RAW" Then
       Form1.Channel.ListItems.Add 1, , Username, , 61
           Else
       Form1.Channel.ListItems.Add , , Username, , 12
[code/]      
       
       

warz

#1
Well, I see a few things kind of sloppy with that. You sound like you're just wanting to to know how to make an operator appear at top, and place the ping values next to their names?

Ops at top:

       If flags = "2" Then
           .ListItems.Add 1, , username, , ConvertGameCodeToIconFunction(here)
           .ListItems(1).ListSubItems.Add , , "0 ms ping!"
           .ListItems(1).ToolTipText = "this person is a op!"
       Else
           .ListItems.Add , , username, , ConvertGameCodeToIconFunction(here)
           .ListItems(frmMain.lstChannel.ListItems.Count).ListSubItems.Add , , "0ms!"
           .ListItems(frmMain.lstChannel.ListItems.Count).ToolTipText = "this person is not an op!"
       End If


If the user is an operator (flag: 2) add them to the top (first argument in add() sub is the index ~aka 'location' - starting, top, at 1) and utilize your function that converts the game abreviation into the appropriate game icon, then place the ping time next to their name by choosing the item in the listitems array that matches the user you just added to the list and giving it a side text, then lastly give them an optional tooltip text box.
Otherwise, if the user is not an operator just add them to the bottom of the list.

TeEhEiMaN

#2
alright i tryed this, but when i test it i get an, Compile error - Invalid or unqualifed referance. What do i do to fix this?
       
ElseIf Client = "PXES" Then
       Form1.Channel.ListItems.Add , , Username, , 9
       .ListItems(1).ListSubItems.Add , , 1   ' 1 as for a ping icon only for example


I get the error on this part

.ListItems(1).ListSubItems.Add , , 1


LordNevar

#3

.ListItems(1).ListSubItems.Add , , 1



Should be


.ListItems(1).ListSubItems.Add 1, ,  

A good fortune may forbode a bad luck, which may in turn disguise a good fortune.
The greatest trick the Devil ever pulled, was convincing the world he didn't exsist.

warz

#4
Instead of having tons of if's, and elseif's to place correct product icons, just use one like in my example and create a function that takes the game code which you are passing through your if statements and matches it to the corresponding number to display the correct icon.

I think this is a pretty well known function:

Public Function ConvertGameCodeToIconFunction(ByVal Product as string) As Integer
  Select Case Product
       Case "PXES": ConvertGameCodeToIconFunction = pidSEXP
       Case "RATS": ConvertGameCodeToIconFunction = pidSTAR
       Case "RTSJ": ConvertGameCodeToIconFunction = pidJSTR
       Case "RHSS": ConvertGameCodeToIconFunction = pidSSHR
       Case "NB2W": ConvertGameCodeToIconFunction = pidW2BN
       Case "VD2D": ConvertGameCodeToIconFunction = pidD2DV
       Case "PX2D": ConvertGameCodeToIconFunction = pidD2XP
       Case "LTRD": ConvertGameCodeToIconFunction = pidDRTL
       Case "RHSD": ConvertGameCodeToIconFunction = pidDRTL
       Case "TAHC": ConvertGameCodeToIconFunction = pidCHAT
       Case "3RAW": ConvertGameCodeToIconFunction = pidWAR3
       Case Else: ConvertGameCodeToIconFunction = pidELSE
   End Select
End Function


declarations:

Private Const pidSEXP = 11
Private Const pidSTAR = 8
Private Const pidD2DV = 4
Private Const pidD2XP = 3
Private Const pidW2BN = 13
Private Const pidJSTR = 7
Private Const pidSSHR = 12
Private Const pidWAR3 = 14
Private Const pidDSHR = 9
Private Const pidCHAT = 15
Private Const pidELSE = 11
Private Const pidDRTL = 5
Private Const pidBLIZZ = 1


What that does is take the "PXES", "RATS", "PX2D" or whatever game code you're passing to it, and it will return the corresponding number of the icon in your image library - thus creating a easy way of plugging the correct image number into the paramater of that ListItems.Add() function.

Eli_1

#5
Quote from: warz on June 18, 2004, 10:53 PM

Public Function ConvertGameCodeToIconFunction(ByVal Product as string) As Integer
End Function


That's a long ass function name  ;).

An add-on to his post to check for basic flags:

Constants:

Const BNFLAGS_BLIZZ = &H1
Const BNFLAGS_OP = &H2
Const BNFLAGS_SPKR = &H4
Const BNFLAGS_SYSOP = &H8
Const BNFLAGS_PLUG = &H10
Const BNFLAGS_SQUELCH = &H20
Const BNFLAGS_GLASSES = &H40


New 'GetIcon' :P code:

If BNFLAGS_OP And Flags = BNFLAGS_OP Then ConvertGameCodeToIconFunction = pidUOPS: Exit Function

If BNFLAGS_SQUELCH And Flags = BNFLAGS_SQUELCH Then ConvertGameCodeToIconFunction = pidSQUEL: Exit Function

' ect...

  Select Case Product
       Case "PXES": ConvertGameCodeToIconFunction = pidSEXP
       Case "RATS": ConvertGameCodeToIconFunction = pidSTAR
       Case "RTSJ": ConvertGameCodeToIconFunction = pidJSTR
       Case "RHSS": ConvertGameCodeToIconFunction = pidSSHR
       Case "NB2W": ConvertGameCodeToIconFunction = pidW2BN
       Case "VD2D": ConvertGameCodeToIconFunction = pidD2DV
       Case "PX2D": ConvertGameCodeToIconFunction = pidD2XP
       Case "LTRD": ConvertGameCodeToIconFunction = pidDRTL
       Case "RHSD": ConvertGameCodeToIconFunction = pidDRTL
       Case "TAHC": ConvertGameCodeToIconFunction = pidCHAT
       Case "3RAW": ConvertGameCodeToIconFunction = pidWAR3
       Case Else: ConvertGameCodeToIconFunction = pidELSE
   End Select


New Function prototype:
ConvertGameCodeToIconFunction(ByVal Product as string, ByRef Flags as Long) As Integer



New Usage:

Dim RVal as Long
RVal = GetIcon(Product, Flags) ' :P

Select Case RVal
Case 1: lstChannel.ListItems.AddItem 1, , Username, , RVal
Case Else: lstChannel.Listitems.Additem , , Username, , RVal
End Select

warz

I was just keepin' it simple.  8)

CrAz3D

Quote from: TeEhEiMaN on June 18, 2004, 10:02 PM
alright i tryed this, but when i test it i get an, Compile error - Invalid or unqualifed referance. What do i do to fix this?
       
ElseIf Client = "PXES" Then
       Form1.Channel.ListItems.Add , , Username, , 9
       .ListItems(1).ListSubItems.Add , , 1   ' 1 as for a ping icon only for example


I get the error on this part

.ListItems(1).ListSubItems.Add , , 1


Notice how you have "Form1.Channel.ListItems.Add"...& the next one is missing Form1.Channel?

;)

You could do With Form1.Channel
   .ListItems.Add , , Username, , 9
   .Listitems.Add , , 1
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

BinaryzL

If (BNFLAGS_OP And lngFlags) = BNFLAGS_OP Then
   With frmMain.lvChannel.ListItems.Add(1, , strUsername, , Icon)
       .ListSubItems.Add 1, , , LagIcon
   End With
Else
   With frmMain.lvChannel.ListItems.Add(, , strUsername, , Icon)
       .ListSubItems.Add , , , LagIcon
   End With
End If