Valhalla Legends Forums Archive | Battle.net Bot Development | OP holders not staying on top of listview.

AuthorMessageTime
Crypticflare
When I join a channel the ops go to the top of the listview. my problem is on the bots textbot, say i type /join Clan CF and I see the op holder CF there, I'd go to join "public chat 1", then I'd go back to Clan CF, and the op holder isn't on top of the listview anymore, is there a property on the listview table I can set so the op holder always stays on top.. like with the arrangement of icons, or do I have to hardcode it into the bot?
March 4, 2003, 6:16 PM
ILurker
use a code like this for when someone is in the channel
[code]
dim icon as integer
icon = geticoncode(client, flags)
Dim lagicoN As Integer
lagicoN = GetLagIcon(Ping, Flags)
If icon = ICON_GAVEL Then
   With form1.ChannelList.ListItems.add(1, username, username, , icon)
   .ListSubItems.add ChannelList.FindItem(username).Index, , , lagicoN
   End With
End If
If icon <> ICON_GAVEL Then
   With form1.ChannelList.ListItems.add(, , username, , icon)
   .ListSubItems.add , , , lagicoN
   End With
[/code]


Do the same for when someone joins the channel
for when someone leaves the channel do this

[code]
form1.ChannelList.ListItems.Remove form1.ChannelList.FindItem(username).Index
form1.ChannelList.Refresh
[/code]

make sure when you join a channel it automatically clears the channellist

[code]
channellist.listitems.clear
[/code]
March 4, 2003, 7:33 PM
Camel
never done it, but i imagine the easiest way would be to make an extra column and sort by its value
blizz reps = 0
speaker = 1
op = 5
all other users = gettickcount (when they join)

*shrug*
March 4, 2003, 7:34 PM
Grok
If you're using a listview, this is easy.  Make the listview sortable.  Create a column header for priority and set the sort column to it.  As you add each user, add the item to the listview, set the subitem for priority appropriately.  Your listview will stay sorted.  Here's an example:

10 - Blizzard icons like Admin
20 - Possibly speaker and other important icons
30 - Ops (hammer)
40 - Clan members maybe
90 - Everyone else

Don't numbers close together, in case you change your mind and want to sort someone between say 2 and 3.

The listview will put all 10's first, 20's, etc.  You never have to worry about sorting again.

Edit:  You can make the sort priority column invisible by setting its column-width to 0.  Creating subitems is a neat way to do various sorts.
March 4, 2003, 7:37 PM
Crypticflare
ah ok, I see how to do it now, thanks!
March 4, 2003, 7:39 PM
Spht
You're going to have to do better than that if you want it to properly arrange the names when new special flagged users are added. In ILurker's case, as the bot finds new channel operators, they will be throw directly to the top. Which means, when he joins a channel with two or more channel operators, they will be listed in the opposite order in which they are in the channel (most recently found names will be at top). So I'd suggest creating a GetPlacementIndex() function which will tell the list view where to add the new special user based on recently added special users so that the special user order is in the order that they are actually in the channel.
March 4, 2003, 7:40 PM
Camel
[quote]You can make the sort priority column invisible by setting its column-width to 0.  Creating subitems is a neat way to do various sorts.[/quote]
so you could create a subitem with gettickcount, so you revert to when they joined, eh?
March 4, 2003, 7:42 PM
ILurker
while we're in this topic, i was wondering why it doesnt show someone as a moderator icon when they join the channel.
for example, if i was in clan boo and boo joined
it doesnt show hiom as a moderator
only when i join
March 4, 2003, 7:44 PM
Spht
[quote]while we're in this topic, i was wondering why it doesnt show someone as a moderator icon when they join the channel.
for example, if i was in clan boo and boo joined
it doesnt show hiom as a moderator
only when i join[/quote]

Obviously because he's wasn't a moderator before the joined the channel. The status is only acquired after the user is present in the channel.

You'll notice that Blizzard employees always carry this flag, because they would be moderators in any channel - it's not dependant on the channel they're in.
March 4, 2003, 7:47 PM
ILurker
Is there any way which i could make it show him as a moderator tho?

i noticed that when you unignore someone bnet sends you a flag update of everyone in the channel you are in, i could use that for when someone joins the channel it automatically attempts to unignore the logged on account, then uses the updates the re-ad everyone to the list, but this would flood the bot allot
March 4, 2003, 7:51 PM
Camel
[quote]Is there any way which i could make it show him as a moderator tho?

i noticed that when you unignore someone bnet sends you a flag update of everyone in the channel you are in, i could use that for when someone joins the channel it automatically attempts to unignore the logged on account, then uses the updates the re-ad everyone to the list, but this would flood the bot allot[/quote]

you shouldn't have to do that...bnet will always send you the correct flag when someone gets ops
if your bot doesn't show someone as ops taht should have ops, you are parsing it wrong
March 4, 2003, 8:15 PM
Camel
truely a simple thing to do :)
(obviously, that column will be hidden)

[img]http://camel.ik0ns.com:84/bnusort.jpg[/img]

[code]If Flags And &H40 Then SortOrder = 4 'blizz guest
If Flags And &H4 Then SortOrder = 3 'speaker
If Flags And &H2 Then SortOrder = 2 'op
If Flags And &H8 Then SortOrder = 1 'bnet rep
If Flags And &H1 Then SortOrder = 0 'blizz rep[/code]
March 4, 2003, 8:36 PM
Zakath
Battle.net does send a flags update message (EventID 0x09 in the 0x0f packet) when someone becomes an operator while in a channel.

I created an UpdateUser() function that takes parameters corresponding to the new info in this packet and makes the appropriate changes to the user in the list, such as changing their icon, and notifying the user that someone has become an operator).
March 6, 2003, 6:17 PM
ILurker
Thx
March 6, 2003, 6:50 PM
MesiaH
No it doesnt update it, but in order for somebody to recive ops, they have to join under the clan name account, or rejoin when they are designated, either way it shows up in the flags under the corresponding event..., somebody cant just be in the channel and automatically receive ops...
March 7, 2003, 12:47 AM
Grok
Try designating someone, then telling ops to leave channel.  The designated person does not rejoin, they just receive ops.

As people have tried to tell you, ops comes with a flags update.  You do not get ops until after joining the channel, unless you are Blizzard, as Yoni pointed out.
March 7, 2003, 8:29 AM
Skywing
[quote]Try designating someone, then telling ops to leave channel.  The designated person does not rejoin, they just receive ops.

As people have tried to tell you, ops comes with a flags update.  You do not get ops until after joining the channel, unless you are Blizzard, as Yoni pointed out.[/quote]
There is an exception to this.  If an Operator "joins" the channel during a server resync after a server split, they'll come in with Operator flags.
March 7, 2003, 2:13 PM
Camel
[quote]There is an exception to this.  If an Operator "joins" the channel during a server resync after a server split, they'll come in with Operator flags.[/quote]
just write a function to find the icon based on statstring and flags, and use it for both userjoin and userupdate
that way you'll never have to worry about if it's a problem with a specific one of the packets
March 7, 2003, 7:22 PM
ILurker
I recently noticed that after someone with ops joins, bnet sends a flags update, i just am using that to update their icon/subitems
March 8, 2003, 12:33 AM
Camel
use the same function to find the icon for both events
in fact, i even use the same function to add users as to modify them in the list, because when a d2 char logs in it'll send a userjoin packet even if that user is already in the channel

[code]            Select Case ID2
               Case 1 'user list
                   frmMain.UL.AddUser UserName, chat, Flags, Ping
               Case 2 'user join
                   frmMain.UL.AddUser UserName, chat, Flags, Ping
               Case 3 'user part
                   frmMain.UL.RemoveUser UserName[/code]
[code]Public Sub AddUser(Name As String, StatStr As String, Flags As Long, Ping As Long)
   Dim Acct As String, sName As String
   Acct = AccountOf(Name)
   sName = ShowName(Name)
   
   On Error GoTo AddUser
   With lvUsers.FindItem(Acct, lvwTag) 'Acct) 'attempt to find the user with that account; if it fails, Add them to the listview
       .Text = sName 'Acct
       .SmallIcon = GetIcon(StatStr, Flags)
       .ListSubItems(1).Text = Ping
       .ListSubItems(1).ReportIcon = LagBars(GetLag(Ping, Flags))
       .ListSubItems(2).Text = SortOrder(Flags)
   End With
   Exit Sub

AddUser:
   With lvUsers.ListItems.Add(, , sName)  'Acct)
       .Tag = Acct
       .SmallIcon = GetIcon(StatStr, Flags)
       .ListSubItems.Add , , Ping, LagBars(GetLag(Ping, Flags))
       .ListSubItems.Add , , SortOrder(Flags)
   End With
End Sub

Public Sub RemoveUser(Name As String)
   lvUsers.ListItems.Remove lvUsers.FindItem(AccountOf(Name), lvwTag).Index
End Sub[/code]
March 8, 2003, 12:57 AM
tA-Kane
[quote]after someone with ops joins, bnet sends a flags update[/quote]
Assuming that the only changed flag is the channel operator flag, they did not have ops when they joined.
March 8, 2003, 8:38 AM

Search