Valhalla Legends Forums Archive | Battle.net Bot Development | Channel ops and ping

AuthorMessageTime
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

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

[/code]
June 19, 2004, 1:42 AM
warz
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:
[code]
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
[/code]

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.
June 19, 2004, 1:59 AM
TeEhEiMaN
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?
[code]
ElseIf Client = "PXES" Then
Form1.Channel.ListItems.Add , , Username, , 9
.ListItems(1).ListSubItems.Add , , 1 ' 1 as for a ping icon only for example
[/code]

I get the error on this part
[code]
.ListItems(1).ListSubItems.Add , , 1
[/code]
June 19, 2004, 3:02 AM
LordNevar
[code]
.ListItems(1).ListSubItems.Add , , 1
[/code]


Should be

[code]
.ListItems(1).ListSubItems.Add 1, ,
[/code]
June 19, 2004, 3:27 AM
warz
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:
[code]
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
[/code]

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

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.
June 19, 2004, 3:53 AM
Eli_1
[quote author=warz link=board=17;threadid=7313;start=0#msg66011 date=1087617188]
[code]
Public Function ConvertGameCodeToIconFunction(ByVal Product as string) As Integer
End Function
[/code]
[/quote]

That's a long ass function name ;).

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

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

New 'GetIcon' :P code:
[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
[/code]

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


New Usage:
[code]
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
[/code]
June 19, 2004, 12:29 PM
warz
I was just keepin' it simple. 8)
June 19, 2004, 4:01 PM
CrAz3D
[quote author=TeEhEiMaN link=board=17;threadid=7313;start=0#msg65994 date=1087614122]
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?
[code]
ElseIf Client = "PXES" Then
Form1.Channel.ListItems.Add , , Username, , 9
.ListItems(1).ListSubItems.Add , , 1 ' 1 as for a ping icon only for example
[/code]

I get the error on this part
[code]
.ListItems(1).ListSubItems.Add , , 1
[/code]

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

;)

You could do [code]With Form1.Channel
.ListItems.Add , , Username, , 9
.Listitems.Add , , 1
[/code]
June 19, 2004, 4:13 PM
BinaryzL
[code]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[/code]
June 19, 2004, 7:36 PM

Search