Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: gotcha_ass on February 25, 2003, 07:07 PM

Title: Vb -> ListView Question
Post by: gotcha_ass on February 25, 2003, 07:07 PM
Ok Im using a listview to do the members in a channel and their icon. My problem is when someone leaves the channel, the list doesnt bump up to fill in that person empty space. It just leaves an empty space until the next user joins and fills it in. Is there any code that will automatically shift everyone up when someone leaves the channel?
Title: Re: Vb -> ListView Question
Post by: Grok on February 26, 2003, 12:10 AM
Use Remove method of the ListItems collection in the ListView.  The parameter is Key.

ListView1.ListItems.Remove ItemX.Key
Title: Re: Vb -> ListView Question
Post by: Noodlez on February 26, 2003, 12:02 PM
listview1.refresh after you remove someone
Title: Re: Vb -> ListView Question
Post by: Mesiah / haiseM on February 26, 2003, 12:09 PM
are you sure its a listview, ive known listbox's to do that, but never on my listview...

and yes make sure you remove the item by its index, you can use finditem to retreive this, or store it in a subitem(pointless, but would work all the same)
Title: Re: Vb -> ListView Question
Post by: gotcha_ass on February 26, 2003, 12:30 PM
I think it is the refresh that its missing
Title: Re: Vb -> ListView Question
Post by: Mesiah / haiseM on February 26, 2003, 12:47 PM
no because it automatically refreshes in a way, and if you refresh the list every time you do that, if you get a floodbot or something, your bot is gonna freeze up rendering it completely helpless, even after the flood bots leave, so i wouldnt reccoment it..
Title: Re: Vb -> ListView Question
Post by: haZe on February 26, 2003, 02:58 PM
You don't even really have to worry about floodbots anymore on account of how strictly battle.net is enforcing their rules on rejoins/reconnects because of all the complaints on LoRd]ZeR0['s gay ass floodbot. :-/
Title: Re: Vb -> ListView Question
Post by: Mesiah / haiseM on February 26, 2003, 04:21 PM
no offense, but any smart programmer can sit down and make the best flood bot ever seen, and get away with it being faster than ones that already exist.
Title: Re: Vb -> ListView Question
Post by: Zakath on February 26, 2003, 04:47 PM
The only people who are interested in things like floodbots (whose entire purpose is to annoy other people) are almost by definition idiots...
Title: Re: Vb -> ListView Question
Post by: Camel on February 26, 2003, 05:52 PM
Quoteno because it automatically refreshes in a way, and if you refresh the list every time you do that, if you get a floodbot or something, your bot is gonna freeze up rendering it completely helpless, even after the flood bots leave, so i wouldnt reccoment it..

make a timer and set its interval to like 10ms or something small like that. every time you you want to refresh the listview, do tmrwhatever.enabled = false and then tmrwhatever.enabled = true. that way the timer wont execute until 10ms after the "last" time you modify the list. well, vb timers suck and are inaccurate, but it works ;)
Title: Re: Vb -> ListView Question
Post by: gotcha_ass on February 26, 2003, 07:17 PM
Ahhh! Its still doing it. No one else has ever had this problem? Like when the second person in the channel leaves, his places stays blank and then the next person to join fills it, I mean I can live w/ it but its annoying.

*And yes its a listview heres the code that does it, I copied it strait off AssBot(I gave it credits to)

Public Sub DelNick(ByVal strKey$)
    Dim i&
    
    If frmMain.ChannelUsers.ListItems.Count > 1 Then
        For i = 1 To frmMain.ChannelUsers.ListItems.Count
            If Left(frmMain.ChannelUsers.ListItems(i).Key, InStr(1, frmMain.ChannelUsers.ListItems(i).Key, "&") - 1) = strKey Then
                frmMain.ChannelUsers.ListItems.Remove i
                frmMain.ChannelUsers.Refresh
                Exit For
            End If
        Next i
    Else
        If Left(frmMain.ChannelUsers.ListItems(1).Key, InStr(1, frmMain.ChannelUsers.ListItems(1).Key, "&") - 1) = strKey Then
            frmMain.ChannelUsers.ListItems.Remove 1
            frmMain.ChannelUsers.Refresh
        End If
    End If
End Sub
Title: Re: Vb -> ListView Question
Post by: Camel on February 26, 2003, 07:40 PM
Quoteyou can use finditem to retreive this
Title: Re: Vb -> ListView Question
Post by: Mesiah / haiseM on February 27, 2003, 11:25 AM
let me see if i can modify this a bit for ya

Public Sub DelNick(ByVal strName$)
    
    frmmain.channelusers.listitems.remove frmmain.channelusers.finditem(strname$)

End Sub

thats all you really need to do, simply.. if you want to add things like extended support for duplicated names, im sure you can do it, but initially this is all u need.
Title: Re: Vb -> ListView Question
Post by: gotcha_ass on February 27, 2003, 01:18 PM
Thanks Messiah, I dont know why they put so much code into the AssBot, when all it required was that. Hopefully it'll work I'll go try it now.
Title: Re: Vb -> ListView Question
Post by: Spht on February 27, 2003, 01:32 PM
Well if you actually read the function you'd see what he is searching for in the list view. Ickis has his reason for doing such things.

It is more accurate to identify users in channel by unique keys, instead of by their name. Seeing as things like two people in the channel having the same name occurs sometimes, identifying user's by their name would not work out very well at all in this case.
Title: Re: Vb -> ListView Question
Post by: gotcha_ass on February 27, 2003, 01:52 PM
Oh ok, I wasnt tryin to insult him or anything, just ignorance on my part.
Title: Re: Vb -> ListView Question
Post by: gotcha_ass on February 28, 2003, 05:46 AM
I was tried that code, the real simple one MesiaH posted, and it worked at first, but now I am gettin an invalid key error. Any help?
Title: Re: Vb -> ListView Question
Post by: Mesiah / haiseM on February 28, 2003, 06:47 PM
when your error raises, hit debug, the line of code should be highlighted yellow, look at it carefully, if you cant figure out whats causing the error, paste it on here.
Title: Re: Vb -> ListView Question
Post by: gotcha_ass on March 02, 2003, 06:57 PM
Its the same simplified code you posted earlier in this thread. The error is invalid key.

Public Sub DelNick(ByVal strKey$)
        frmMain.ChannelUsers.ListItems.Remove frmMain.ChannelUsers.FindItem(strKey$)
End Sub
Title: Re: Vb -> ListView Question
Post by: Mesiah / haiseM on March 02, 2003, 07:29 PM
thats your problem, i changed it to delete them by their name, not the key.
Title: Re: Vb -> ListView Question
Post by: Camel on March 03, 2003, 11:23 AM
lvUsers.ListItems.Remove lvUsers.FindItem(key).Index
Title: Re: Vb -> ListView Question
Post by: guest on March 03, 2003, 11:32 AM
form1.ChannelList.ListItems.add , , username, , icon
form1.ChannelList.ListItems.Remove form1.ChannelList.FindItem(username).Index
Title: Re: Vb -> ListView Question
Post by: gotcha_ass on March 04, 2003, 05:10 PM
Oh my god its still doin it  ??? ??? ???
At least I dont get an error, I wish I could put up a screen shot so I can better explain it. But this is weird.
Title: Re: Vb -> ListView Question
Post by: ILurker on March 04, 2003, 05:23 PM
show me the code of how you add items to the list
Title: Re: Vb -> ListView Question
Post by: gotcha_ass on March 05, 2003, 12:52 PM
Public Sub AddNick(ByVal strKey$, ByVal strName$, lngIcon&)
    Dim i&
    i = frmMain.ChannelUsers.ListItems.Count + 1
    frmMain.ChannelUsers.ListItems.Add i, strKey, strName, 0, lngIcon
End Sub
Title: Re: Vb -> ListView Question
Post by: ILurker on March 05, 2003, 01:00 PM
try doing this under the user_join sub
Dim icon As Integer
icon = GetIconCode(client, Flags)
Dim lagicoN As Integer
lagicoN = GetLagIcon(Ping, Flags)

 If icon = ICON_GAVEL Then
    With frmMain.ChannelUsers.ListItems.add(1, username, username, , icon)
    .ListSubItems.add , , , lagicoN
    End With
 End If
 If icon <> ICON_GAVEL Then
    With frmMain.ChannelUsers.ListItems.add(, , username, , icon)
    .ListSubItems.add , , , lagicoN
    End With
 End If

This is a code you could use to remove a user from the list.

form1.ChannelList.ListItems.Remove form1.ChannelList.FindItem(username).Index
form1.ChannelList.Refresh


If you're trying to add a lag icon also, you would need to add a "ping as string" in your sub. then use that as i did with mine
Title: Re: Vb -> ListView Question
Post by: Noodlez on March 06, 2003, 03:24 PM
why dont you check the flags instead of the icon? also, what about blizz reps and bnet ops?
Title: Re: Vb -> ListView Question
Post by: ILurker on March 06, 2003, 05:25 PM
yeah i relized about those this morning,