Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: TriCk on May 23, 2003, 07:20 AM

Title: How do i load from a listbox
Post by: TriCk on May 23, 2003, 07:20 AM
how do i choose items from a listbox ?
say like an access thing... ?
Title: Re:How do i load from a listbox
Post by: drivehappy on May 23, 2003, 04:12 PM
QuotePrivate Sub List1_Click()
MsgBox List1.List(List1.ListIndex)
End Sub
Title: Re:How do i load from a listbox
Post by: TriCk on May 23, 2003, 07:34 PM
hmmm
I tried that with cleanslatebot ...
Code:
CleanSlateBot_UserJoins
If Username = List.List(List.ListIndex) Then
'Don't Ban
Else If Username = Username Then
CleanSlateBot.Send "/ban " & username


Doesnt work...
how would i get it to work with that sort of setup i have there ?
Title: Re:How do i load from a listbox
Post by: drivehappy on May 23, 2003, 07:58 PM
CleanSlateBot_UserJoins
If trim(ucase(Username)) = trim(ucase(List.List(List.ListIndex))) Then
'Don't Ban
Else
CleanSlateBot.Send "/ban " & Username
End If

Try that.
Title: Re:How do i load from a listbox
Post by: TriCk on May 23, 2003, 08:19 PM
hmmm thats still not working
I have my name on the list but if i join it still bans me...
are u sure that code is right ?
Title: Re:How do i load from a listbox
Post by: Camel on May 23, 2003, 08:30 PM
that code compares the name of the user joining to the value of the selected item in the list. you probably want to search through the list and compare the users name to every entry, rather than just the selected one.
Title: Re:How do i load from a listbox
Post by: TriCk on May 23, 2003, 10:37 PM
yeah how would i do that?
code please
i'm sorta newb to vb6   :(
Title: Re:How do i load from a listbox
Post by: TriCk on May 24, 2003, 02:36 AM
how do i find a username in a listbox so they dont get banned when they join ?
Title: Re:How do i load from a listbox
Post by: drivehappy on May 24, 2003, 05:16 PM
CleanSlateBot_UserJoins()
For X = 0 to List1.Listcount -1
  If trim(ucase(Username)) = trim(ucase(List1.List(X)) Then
    'Don't Ban
  ElseIf Trim(UCase(Username)) <> List1.List(X) and X = (List1.Listcount - 1) Then
    CleanSlateBot.Send "/ban " & Username
  End If
Next
Title: Re:How do i load from a listbox
Post by: TriCk on May 24, 2003, 06:41 PM
Thanks DriveHappy  ;D
Title: Re:How do i load from a listbox
Post by: TriCk on May 24, 2003, 07:00 PM
hmmm...
one more thing... it only works for 1 person if i put more than 1 person in the listbox it bans the first one whys it doin that ??
Title: Re:How do i load from a listbox
Post by: Mesiah / haiseM on May 24, 2003, 07:12 PM
finditem.
Title: Re:How do i load from a listbox
Post by: Camel on May 24, 2003, 10:00 PM
Quote from: TriCk on May 24, 2003, 02:36 AM
how do i find a username in a listbox so they dont get banned when they join ?

Quote from: Camel on May 23, 2003, 08:30 PM
...search through the list and compare the users name to every entry...
or use the [listbox].FindItem method as mesiah pointed out
Title: Re:How do i load from a listbox
Post by: TriCk on May 24, 2003, 10:39 PM
are u talking about VB .net ? Coz i dont think on VB6 they have ListBox.FindItem ...?

I also own VB .net but im using vb6 for this bot
Title: Re:How do i load from a listbox
Post by: drivehappy on May 25, 2003, 03:29 PM
Trick, it depends on what you have Username set to when you loop it. I'm trying to figure out what you're not doing right, so this is my best guess:

CleanSlateBot_UserJoins()
Dim Username() as String
For Y = 0 to UBound.Username
 For X = 0 to List1.Listcount -1
   If trim(ucase(Username(Y))) = trim(ucase(List1.List(X)) Then
     'Don't Ban
     Exit For
   ElseIf Trim(UCase(Username(Y))) <> List1.List(X) and X = (List1.Listcount - 1 Then
     CleanSlateBot.Send "/ban " & Username(Y)
     Exit For
   End If
 Next
Next


Kind of messy, but it should work. The Username array should contain all the usernames you don't want banned.

Edit: use [ code ] tags.
Title: Re:How do i load from a listbox
Post by: Camel on May 26, 2003, 11:44 AM
no drivehappy, that wont work
you have to check every user agains the entire username() array. you're checking everyone against the array one entry at a time and banning them if they're not that element in the array.