Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: Yegg on September 25, 2004, 07:17 PM

Title: Help with wildcards!
Post by: Yegg on September 25, 2004, 07:17 PM
I cant seem to figure out how to work wildcards for my bot. all i want to know how to do is have a command that makes it so lets say i wanted something like !kill load. ne1 with load in their name would get banned. Can ne1 help me do this correctly?
Title: Re:Help with wildcards!
Post by: Newby on September 25, 2004, 07:38 PM
Look up InStr()
Title: Re:Help with wildcards!
Post by: UserLoser. on September 25, 2004, 07:43 PM
Quote from: Yegg on September 25, 2004, 07:17 PM
I cant seem to figure out how to work wildcards for my bot. all i want to know how to do is have a command that makes it so lets say i wanted something like !kill load. ne1 with load in their name would get banned. Can ne1 help me do this correctly?

For something basic, look up the Like (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vaoprlike.asp) operator.
Title: Re:Help with wildcards!
Post by: Yegg on September 25, 2004, 09:02 PM
I think i'll stick with InStr() (i forgot about that)
Im not sure exactly how 2 go about doing this, so far i have:

If InStr(1, username, splt(1), vbTextCompare) <> 0 Then
CleanSlateBot1.Send "/ban " & splt(1)
End If
GoTo Done121
Done121:
Title: Re:Help with wildcards!
Post by: UserLoser. on September 25, 2004, 09:09 PM
Quote from: Yegg on September 25, 2004, 09:02 PM
I think i'll stick with InStr() (i forgot about that)
Im not sure exactly how 2 go about doing this, so far i have:

If InStr(1, username, splt(1), vbTextCompare) <> 0 Then
CleanSlateBot1.Send "/ban " & splt(1)
End If
GoTo Done121
Done121:

Probably be a better idea to do:


CleanSlateBot1.Send "/ban " & Username


If someone does .ban user, wouldn't that send "/ban user" when you're wanting to ban all UserLosers?
Title: Re:Help with wildcards!
Post by: Banana fanna fo fanna on September 25, 2004, 11:21 PM
I really, really insist that you use LIKE.
Title: Re:Help with wildcards!
Post by: CrAz3D on September 25, 2004, 11:38 PM
If "jim" Like "*i*" Then

The full string is on the left, the one with the wildcard is on the right.  Don't forget to use the asterixs correctly though.
Title: Re: Help with wildcards!
Post by: Yegg on September 26, 2004, 05:32 PM
ok, im getting really confused with this Like code.
I dont get how to use it in a command, like if i had a user with access say !own 123, every1 with 123 in their name would get banned, i am not sure where to put the code or how 2 correctly use it, right now i have:

If LCase(splt(0)) = Trigger & "own" And LCase(username) = Master Then
(i dont know wut would go here)
CleanSlateBot1.Send "/ban " & username
End If
GoTo Done
Done:
Title: Re: Help with wildcards!
Post by: Yegg on September 26, 2004, 06:36 PM
k, userloser, ur way worked fine, only heres the code im using, and whenever i use it the bot gets an error within seconds:

If LCase(splt(0)) = Trigger & "own" And LCase(username) = Master And InStr(1, username, splt(1), vbTextCompare) <> 0 Then
Form1.tmrWild.Interval = "3000"
Form1.tmrWild.Enabled = True
Form1.tmrWild2.Interval = "3000"
Form1.tmrWild2.Enabled = True
Form1.tmrWild.Enabled = False
Form1.tmrWild2.Enabled = False
Form1.tmrWild.Interval = "4000"
Form1.tmrWild.Enabled = True
Form1.tmrWild2.Interval = "4000"
Form1.tmrWild2.Enabled = True
Form1.tmrWild.Enabled = False
Form1.tmrWild2.Enabled = False
Form1.tmrWild.Interval = "3000"
Form1.tmrWild.Enabled = True
Form1.tmrWild2.Interval = "3000"
Form1.tmrWild2.Enabled = False
End If
GoTo Done190
Done190:


I dunno y i used so many timers, but the bot bans users every 3 seconds.
U may need this code to, its the code to my timer:

Private Sub tmrWild_Timer()
If lstWild.ListCount = 0 Then
Exit Sub
End If
CleanSlateBot1.Send "/ban " & lstWild.List(0) & " OWNED!"
lstWild.RemoveItem username
End Sub
Title: Re: Help with wildcards!
Post by: Yegg on September 26, 2004, 08:48 PM
Ok i changed my command and it almost works only 1 problem is that it wil only ban me, heres the code:

If LCase(splt(0)) = Trigger & "own" And InStr(1, username, splt(1), vbTextCompare) <> 0 And LCase(username) = Master Then
lstWild.AddItem username
Form1.tmrWild.Interval = "3000"
Form1.tmrWild.Enabled = True
Form1.tmrWild2.Interval = "3000"
Form1.tmrWild2.Enabled = True
Form1.tmrWild.Enabled = False
Form1.tmrWild2.Enabled = False
Form1.tmrWild.Interval = "4000"
Form1.tmrWild.Enabled = True
Form1.tmrWild2.Interval = "4000"
Form1.tmrWild2.Enabled = True
Form1.tmrWild.Enabled = False
Form1.tmrWild2.Enabled = False
Form1.tmrWild.Interval = "3000"
Form1.tmrWild.Enabled = True
Form1.tmrWild2.Interval = "3000"
Form1.tmrWild2.Enabled = False
GoTo Done190
Done190:
End If
Title: Re: Help with wildcards!
Post by: Stealth on September 27, 2004, 12:05 AM
Several things to think about.

1: Where's your Tab key?
2:

tmrWild.Interval = "4000"

The Interval property is stored as a number. Why are you passing it a string?

tmrWild.Interval = 4000

3: The chunk of code you just showed us is executed by you computer in less than a millisecond. There's no time in there to ban anyone or take any actions, because the timers each need 3000-4000 milliseconds to fire.
Title: Re: Help with wildcards!
Post by: Grok on September 27, 2004, 12:26 AM
Take advantage of the ADODB Recordset object so you can do SQL queries.  Load the recordset with the data against which you want to query.  With the Filter property, set the value to a SQL WHERE clause.


rs.Filter = "UserName='%[vL]%'"
If rs.RecordCount > 0 Then
    'do stuff with matching records...
End If
Title: Re: Help with wildcards!
Post by: Yegg on September 27, 2004, 05:18 PM
Ok, i dont need all this extra help, i just want to know which item i have to add to lstWild. If i add username it only adds the person doing the command. Any help with this?
Title: Re: Help with wildcards!
Post by: Puzzle on September 28, 2004, 12:14 PM
If LCase(splt(0)) = Trigger & "own" And LCase(username) = Master Then
(i dont know wut would go here)
CleanSlateBot1.Send "/ban " & username
End If
GoTo Done
Done:

If you implemented this, your code would ban the users that issued the command to the bot. You need to ban the username that matches the string you are comparing with.

Also, don't tell people you don't want their help if you post here. This thread will not only help you but any users that visit it in the future or will prevent threads like this if people use the Search page.
Title: Re: Help with wildcards!
Post by: Yegg on September 28, 2004, 04:24 PM
Ok, i just tried another way in doing wildcards, here it is: (plz dotn correct me with timers, im just trying this out)

If LCase(splt(0)) = Trigger & "own" And LCase(username) = Master Then
End If
If InStr(1, username, splt(1), vbTextCompare) <> 0 Then
lstWild.AddItem username
Form1.tmrWild.Interval = "1000"
Form1.tmrWild.Enabled = True
Form1.tmrWild2.Interval = "1000"
Form1.tmrWild2.Enabled = True
Form1.tmrWild3.Interval = "1000"
Form1.tmrWild3.Enabled = True
Form1.tmrWild.Interval = "5000"
Form1.tmrWild.Enabled = True
Form1.tmrWild2.Interval = "5000"
Form1.tmrWild2.Enabled = True
Form1.tmrWild3.Interval = "5000"
Form1.tmrWild3.Enabled = True
End If
GoTo Done253
Done253:


the only problem is that after the bot gets the chance to add a few usernames to a listbox, before it adds them all and then bans them, i get an error on the following line of code:

If InStr(1, username, splt(1), vbTextCompare) <> 0 Then
Title: Re: Help with wildcards!
Post by: Michael on September 29, 2004, 04:06 PM
I would like to know what is the point of the timers?
Title: Re: Help with wildcards!
Post by: Yegg on September 29, 2004, 05:02 PM
i'll let u figure this out on ur own with 1 small hint.....ipbanned from flooding...
Title: Re: Help with wildcards!
Post by: Michael on September 29, 2004, 08:08 PM
That has to be the worst idea for a queue system i have ever seen.... Wow...... anyway i suggest useing a array and one timer. then make the timer send out
the array, But before it sends it checks text lenth as in

public sub arraycheckandsend(own as boolean)
if own = false then
if len(array(0).text) =<59 then timer.interval = 6000
send array(0).text
else
timer.interval = 3500
send array(0).text
end if.
else
send left(array(0).text), 59)
send left(array(0).text), 59)
send left(array(0).text), 59)
send left(array(0).text), 59)
timer.interval = 12000
end if


or something along them lines that dosent require alot of pointless timers which uses more ram then needed. also you will have to design a code to remove the array(0).text and make array(1).text into array(0) which can be done but i don't have the time to post the code.