• Welcome to Valhalla Legends Archive.
 

LIstview removing....

Started by OuTLawZGoSu, August 18, 2003, 10:19 AM

Previous topic - Next topic

OuTLawZGoSu

Sup... this is what i need. i have a listvew called "Channellist" i need to get a code where a user leaves the channel and it removes teh user fromt eh list. this is the code i  have so far:

Case ID_JOIN

Form1.List1.AddItem username & " [" & Ping & "] - " & message, 0

Form1.ChannelList.ListItems.add 1, , username

If Form4.Check5 = vbChecked Then
AddC vbGreen, username & " has joined the channel"
End If

Case ID_LEAVE

If Form4.Check5 = vbChecked Then
AddC vbGreen, username & " has left the channel"
Form1.ChannelList.ListItems.remove 1

End If

Form1.List1.RemoveItem SendMessage(Form1.List1.hwnd, LB_FINDSTRING, 0, username & " [" & Ping & "] - " & message)
End Select
Exit Sub

Where it sais "Form1.ChannelList.ListItems.remove 1" thats where the username gets removed. Just that when any user leaves it will always take off the 1st username and not the one that left. i dont get how to make that work..

Some one help?

L8terZ

Soul Taker

#1
You're always removing the first item rather than finding and removing the user.

Something like

For x = 1 to Form1.ChannelList.ListItems.Count
 If Form1.ChannelList.ListItems.Item(x).text = username then
   Form1.ChannelList.ListItems.remove x
 End If
Next x

should work.

______

Quote from: Soul Taker on August 18, 2003, 11:33 AM
You're always removing the first item rather than finding and removing the user.

Something like

For x = 1 to Form1.ChannelList.ListItems.Count
 If Form1.ChannelList.ListItems.Item(x).text = username then
   Form1.ChannelList.ListItems.remove x
 End If
Next x

should work.

should work better

Form1.channellist.ListItems.Remove Form1.ChannelList.FindItem(Username).Index '

OuTLawZGoSu

Ok... now this is what i have...


Case ID_JOIN

Form1.ChannelList.ListItems.add 1, , username

If Form4.Check5 = vbChecked Then
AddC vbGreen, username & " has joined the channel"
End If

Case ID_LEAVE

If Form4.Check5 = vbChecked Then
AddC vbGreen, username & " has left the channel"
Form1.ChannelList.ListItems.remove 1

End If
End Select
Exit Sub


It all works good just I need more then jsut the screenname. I need the ping in the next column and the client in the 3rdcolumn. can you help me out?

L8terr

______

Quote from: OuTLawZGoSu on August 18, 2003, 02:43 PM
Ok... now this is what i have...


Case ID_JOIN

Form1.ChannelList.ListItems.add 1, , username

If Form4.Check5 = vbChecked Then
AddC vbGreen, username & " has joined the channel"
End If

Case ID_LEAVE

If Form4.Check5 = vbChecked Then
AddC vbGreen, username & " has left the channel"
Form1.ChannelList.ListItems.remove 1

End If
End Select
Exit Sub


It all works good just I need more then jsut the screenname. I need the ping in the next column and the client in the 3rdcolumn. can you help me out?

L8terr
that is the same thing you had in the your first post

OuTLawZGoSu

#5
Oh shit, you're right. Srry bgout that..

Tis is the righ tcode:



Case ID_JOIN

Form1.ChannelList.ListItems.add 1, , username
If Form4.Check5 = vbChecked Then
AddC vbGreen, username & " has joined the channel"
End If
End If


Case ID_LEAVE
For X = 1 To Form1.ChannelList.ListItems.Count
 If Form1.ChannelList.ListItems.Item(X).Text = username Then
   Form1.ChannelList.ListItems.Remove X
 End If
Next X

If Form4.Check5 = vbChecked Then
AddC vbGreen, username & " has left the channel"
End If

End Select
Exit Sub

End Sub



t all works good just I need more then jsut the screenname. I need the ping in the next column and the client in the 3rd column.

Soul Taker

Quote from: ___/\___ on August 18, 2003, 11:56 AM
Quote from: Soul Taker on August 18, 2003, 11:33 AM
You're always removing the first item rather than finding and removing the user.

Something like

For x = 1 to Form1.ChannelList.ListItems.Count
 If Form1.ChannelList.ListItems.Item(x).text = username then
   Form1.ChannelList.ListItems.remove x
 End If
Next x

should work.

should work better

Form1.channellist.ListItems.Remove Form1.ChannelList.FindItem(Username).Index '

What if you want your bot to be able to connect to user-made servers which might not gauruntee unique accounts!

______

Quote from: Soul Taker on August 19, 2003, 12:21 PM
Quote from: ___/\___ on August 18, 2003, 11:56 AM
Quote from: Soul Taker on August 18, 2003, 11:33 AM
You're always removing the first item rather than finding and removing the user.

Something like

For x = 1 to Form1.ChannelList.ListItems.Count
 If Form1.ChannelList.ListItems.Item(x).text = username then
   Form1.ChannelList.ListItems.remove x
 End If
Next x

should work.

should work better

Form1.channellist.ListItems.Remove Form1.ChannelList.FindItem(Username).Index '

What if you want your bot to be able to connect to user-made servers which might not gauruntee unique accounts!
you should be able to replace username with whatever your using.

OuTLawZGoSu

Thx ... But no wi need to put the username and the ping in diferent columns. can you tell me how to do that? i have 2 columns already, i just need to ge tthe code to put the ping in the secon one.

Arta

Quote from: Soul Taker on August 19, 2003, 12:21 PM
What if you want your bot to be able to connect to user-made servers which might not gauruntee unique accounts!

That server would be incredibly broken. Given the brokenness, there's no guaranteed way.

That said, server splits and wierd errors can cause 2 users with the same name to be present in the channel at the same time. If you want to be very safe, you should check the ping as well as the username to make sure it's the same.

On broken servers that often doesn't work, though, because some of them (*cough* BnetD/PVPGN) update clients' pings in flag updates after they've logged on.

Camel


Eibro

Quote from: Camel on August 20, 2003, 10:36 PM
BTW, PVPGN == BnetD++
Hehe, I think what you really mean is PVPGN == ++BnetD
Eibro of Yeti Lovers.

Camel

Quote from: Eibro on August 20, 2003, 10:55 PM
Quote from: Camel on August 20, 2003, 10:36 PM
BTW, PVPGN == BnetD++
Hehe, I think what you really mean is PVPGN == ++BnetD
I think you mean PVPGN = BnetD + 1;
I mean PBPGN == BnetD++ like C++, STFU++, and n00b++.

Eibro

Quote from: Camel on August 20, 2003, 11:56 PM
Quote from: Eibro on August 20, 2003, 10:55 PM
Quote from: Camel on August 20, 2003, 10:36 PM
BTW, PVPGN == BnetD++
Hehe, I think what you really mean is PVPGN == ++BnetD
I think you mean PVPGN = BnetD + 1;
I mean PBPGN == BnetD++ like C++, STFU++, and n00b++.
In a single statement (eg. C++), the effects of preincrement and postincrement are the same. When put into a statement (as you did above) you need to be careful what you use.
If you really mean what you said above, then BnetD will be 1 greater than PVPGN at the end of the statement. Also, it will evaluate true if both are initially the same value.
;)
Eibro of Yeti Lovers.