Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: Gangz on May 07, 2004, 12:38 AM

Title: Sweep Ban Problem
Post by: Gangz on May 07, 2004, 12:38 AM

   Dim va1 As String
   Dim va2 As String
   If Form1.chksweep = vbChecked And InStr(message, ",") <> 0 Then
       va1 = Split(message, ", ")(0)
       banname = va1
       Dim banname1 As String
       Dim banname2 As String
       If Left(banname, 1) = "[" And Right(banname, 1) = "]" And UCase(banname) = banname Then
           banname1 = Right(message, Len(banname) - 1) & Right(message, Len(banname1) - 1)
           Form1.cboQueue.AddItem "/ban " & banname2 & " Superior Sweep"
       Else
           Form1.cboQueue.AddItem "/ban " & banname & " Superior Sweep"
       End If
       va2 = Split(message, ", ")(1)
       banname = va2
       If Left(banname, 1) = "[" And Right(banname, 1) = "]" And UCase(banname) = banname Then
           banname1 = Right(message, Len(banname) - 1)
           banname1 = Left(message, Len(banname) - 1)
           Form1.cboQueue.AddItem "/ban " & banname1 & " Superior Sweep"
       Else
           Form1.cboQueue.AddItem "/ban " & banname & " Superior Sweep"
       End If
   End If
   If Form1.chkci = vbChecked And InStr(message, ",") <> 0 Then
       va1 = Split(message, ", ")(0)
       banname = va1
       If Left(banname, 1) = "[" And Right(banname, 1) = "]" And UCase(banname) = banname Then
           banname1 = Right(message, Len(banname) - 1)
           banname1 = Left(message, Len(banname) - 1)
           Form1.cboQueue.AddItem "/ignore " & banname1
       Else
           Form1.cboQueue.AddItem "/ignore " & banname
       End If
       va2 = Split(message, ", ")(1)
       banname = va2
       If Left(banname, 1) = "[" And Right(banname, 1) = "]" And UCase(banname) = banname Then
           banname1 = Right(message, Len(banname) - 1)
           banname1 = Left(message, Len(banname) - 1)
           Form1.cboQueue.AddItem "/ignore " & banname1
       Else
           Form1.cboQueue.AddItem "/ignore " & banname
       End If
   End If


With the Help of dda-trick-e I have come up with this code for "Sweeping" a channel. I keep getting an error on the ops though



   If Left(banname, 1) = "[" And Right(banname, 1) = "]" And UCase(banname) = banname Then
banname1 = Right(message, Len(banname) - 1)
banname1 = Left(message, Len(banname) - 1)

I have alost tried

   If Left(banname, 1) = "[" And Right(banname, 1) = "]" And UCase(banname) = banname Then
banname1 = Right(message, Len(banname) - 1) & Left(message, Len(banname) - 1)


anyone got any suggest i have tried a few other combos but its not looking any closer then the 2 of these

Edit: Fixed the Code tags
Edit(Grok):  Indented so I could read it :)
Title: Re:Sweep Ban Problem
Post by: Newby on May 07, 2004, 12:48 AM
Try using a Mid$() statement. Starting at 2 ending 1 away from the end of the string.
Title: Re:Sweep Ban Problem
Post by: Eli_1 on May 07, 2004, 05:50 AM
Quote from: Gangz on May 07, 2004, 12:38 AM

Dim va1 As String
Dim va2 As String
. . .
va1 = Split(message, ", ")(0)
banname = va1
...
va2 = Split(message, ",")(0)
...


Since your using split, shouldn't those be arrays?

And on a side note, your code is fugly.  >:(
Title: Re:Sweep Ban Problem
Post by: Gangz on May 07, 2004, 09:14 AM
Quote from: Eli_1 on May 07, 2004, 05:50 AM
Quote from: Gangz on May 07, 2004, 12:38 AM

Dim va1 As String
Dim va2 As String
. . .
va1 = Split(message, ", ")(0)
banname = va1
...
va2 = Split(message, ",")(0)
...


Since your using split, shouldn't those be arrays?

And on a side note, your code is fugly.  >:(

Does it matter what it looks like? It gets the job done...
Title: Re:Sweep Ban Problem
Post by: Newby on May 07, 2004, 09:32 AM
Use Mid$()

Mid$(Username, 2, Len(Username) - 2)

And I agree with Eli, your coding is very fucking ugly. :(
Title: Re:Sweep Ban Problem
Post by: Eli_1 on May 07, 2004, 11:21 AM
Quote from: Gangz on May 07, 2004, 09:14 AM
Does it matter what it looks like? It gets the job done...
Yes it does matter. Clean coding is a part of good programming practice, and it will make your code much easier to understand in the future and will be easier to update.
Title: Re:Sweep Ban Problem
Post by: Adron on May 07, 2004, 11:46 AM
Quote from: Gangz on May 07, 2004, 09:14 AM
Does it matter what it looks like? It gets the job done...

As long as you are the only one reading it and you can understand it perfectly, it doesn't matter.

As soon as you show it to other people and ask them to help you with your code, it does matter. If they can understand your code easier, they'll be able to help you more effectively.

I also think that you yourself would be helped by prettier code, although you may not realize it yet.
Title: Re:Sweep Ban Problem
Post by: Gangz on May 07, 2004, 11:58 AM
Thanks for the help eli and newby ill give it a shot...
Title: Re:Sweep Ban Problem
Post by: hismajesty on May 07, 2004, 01:45 PM
Yes, you should work on cleaning up your code. I didn't even read the entire code since I have a headache and it made it worse.  >:(
Title: Re:Sweep Ban Problem
Post by: Gangz on May 07, 2004, 04:36 PM
Sorry, I know im not the best of coders... But i do whats needed to get the job done


Thanks everyone for the help... I got it to work..