Valhalla Legends Forums Archive | Battle.net Bot Development | [VB6] Say command

AuthorMessageTime
cHip
yO, need some help with this durn thing... I've tried everything I could ponder, even looking through all 300 some fourms.  Please help

Trying to add a basic "say" command.  According to just about everyone I talked too, different programming skills are used, just having trouble putting it all together.  I decided on a basic algor.

This is what I got currently...

[quote]    Private Sub ws_DataArrival(Index As Integer, ByVal bytesTotal As Long)
    On Error Resume Next
    Dim s As String, Data() As String, lne() As String
    Dim i As Integer, c As Integer, n As Integer
   
    Me.ws(Index).GetData s, vbString
   
    If InStr(1, LCase(s), "1009 USER " & Configuration.Username & " 0012", vbTextCompare) > 0 Then
        OpsCount = OpsCount + 1
        Me.Caption = "(" & OpsCount & ") :.: SyNdicage Bot"
        txtStatus.Text = "Got Ops on: " & Configuration.HomeChannel
    End If 

    Dim splt() As String
    splt() = Split(s, " ")
    If Left(s, Len("1005 TALK ")) = "1005 TALK " Then
        Dim Command As String
        Command = Mid(s, InStr(s, "0010") + 5, Len(s))
        Command = Replace(Command, Chr(34), "")
        If clsDatabase.CheckAcceslist(splt(2)) = True Then
            If LCase(Left(Command, 8)) = LCase("?trigger") Then Me.ws(ConnectedWs).SendData "My Trigger: " & Commands.Trigger & vbNewLine: Exit Sub
            If Left(Command, 1) = Commands.Trigger Then
                basParse.ParseCommands splt(2), Command, myIndex, Index
            End If
        End If
    End If
End Sub [/quote]

This code is in my Form1.frm    I get stuck here, doing a debug on this situation does nothing for me.  (It did, but it was because I left an 'End If' off... It's there now)

Please tell me wtf is wrong; I'm tired, it's possible thats the problem.
October 17, 2005, 7:29 AM
Elneroth
First of all, since when are capital letters in lowercase strings? ;)
[code]If InStr(1, LCase(s), "1009 USER " & Configuration.Username & " 0012", vbTextCompare) > 0 Then[/code]
Should be:
[code]If InStr(1, LCase(s), "1009 user " & lcase(Configuration.Username) & " 0012", vbTextCompare) > 0 Then[/code]

[code]Command = Mid(s, InStr(s, "0010") + 5, Len(s))[/code]
On that, you are trying to get it to go past the end of the string considering you are starting at the InStr + 5.
Change that to:
[code]Command = Mid(s, InStr(s, "0010") + 5)[/code]
This will tell it to just go on for the rest of the string.

[code]If Left(s, Len("1005 TALK ")) = "1005 TALK " Then[/code]
You should just manually count the number and put it yourself, you're making the program do more than it needs.
[code]If Left(s, 10) = "1005 TALK " Then[/code]

Also, one last thing. Right now you're telling it to cut off the "1005 " part as you do here:
[code]Command = Mid(s, InStr(s, "0010") + 5, Len(s))[/code]
That would be leaving you with thinking the command is "TALK". You should change that to, using the change I did above, the following:
[code]Command = Mid(s, InStr(s, "0010 TALK ") + 10)[/code]
But even after that the program would think the command is the person's username, so you must take it one step farther.
[code]Command = Mid(s, InStr(s, "0010 TALK ") + 10)
Command = Mid(s, InStr(s, " ") + 1)[/code]

Hope at least some of that helps.
October 17, 2005, 12:59 PM
Myndfyr
[quote author=Elneroth link=topic=13058.msg131325#msg131325 date=1129553941]
First of all, since when are capital letters in lowercase strings? ;)
[code]If InStr(1, LCase(s), "1009 USER " & Configuration.Username & " 0012", vbTextCompare) > 0 Then[/code]
Should be:
[code]If InStr(1, LCase(s), "1009 user " & lcase(Configuration.Username) & " 0012", vbTextCompare) > 0 Then[/code]
[/quote]

Why is this?  I don't really remember much from the telnet connection protocol, but I seem to remember all Bnet data coming in (besides the username/text) in uppercase.
October 17, 2005, 4:01 PM
HdxBmx27
[quote author=MyndFyre link=topic=13058.msg131338#msg131338 date=1129564880]
Why is this?  I don't really remember much from the telnet connection protocol, but I seem to remember all Bnet data coming in (besides the username/text) in uppercase.
[/quote]
because if you would read the code, He is LCase()ing the message, and then comparing it to a string with upper-case letters.
This would always make it evaluate to 0.
~-~(HDX)~-~
October 17, 2005, 4:31 PM
cHip
hehe, thanx for the helpz0r... most of that code I wrote when I was a lil beat~~

Anyway, i found something out, it wasnt really my "say" feature that was the problem... it's my database. LoLz

(Dunno if i should start a new post...)

[code]    Public Function AddAcces(User, acces)
    Acceslist.Add User & " " & acces
    WriteAcceslist
End Function
Private Function ClearAcceslist()
    Dim i As Integer
    For i = 1 To Acceslist.Count
        Acceslist.Remove 1
    Next i
End Function
Public Function LoadAcceslist()
Dim FileNum As Integer, item As String
On Error GoTo GetAccesList_Error
ClearAcceslist
FileNum = FreeFile
Open App.Path & "\Configuration\Database.txt" For Input As FileNum
    Do Until EOF(FileNum)
        Line Input #FileNum, item
        If Acceslist.Count = 0 Then
        Acceslist.Add item
        Else
        Acceslist.Add item, , , Acceslist.Count
        End If
    Loop
Close FileNum

If Acceslist.Count = 0 Then
Acceslist.Add Master & " A"
Else
Acceslist.Add Master & " A", , , Acceslist.Count
End If

GetAccesList_Error:
If Err.Number <> 0 Then MsgBox "Error in Database(" & Err.Description & ")"
End Function

Public Function CheckAcceslist(strUser) As Boolean
    Dim i As Integer
    Dim splt() As String
    For i = 1 To Acceslist.Count
    splt = Split(Acceslist.item(i), " ")
    If LCase(strUser) = LCase(splt(0)) Then
        CheckAcceslist = True
        Exit Function
    Else
        CheckAcceslist = False
    End If
    Next i
End Function

Public Function WriteAcceslist()
Dim FileNum As Integer, item As String
On Error GoTo WriteAccesList_Error
FileNum = FreeFile
Open App.Path & "\Configuration\Database.txt" For Output As FileNum
    For i = 1 To Acceslist.Count
        Print #FileNum, Acceslist(i)
    Next i
Close FileNum
WriteAccesList_Error:
If Err.Number <> 0 Then MsgBox "Error in WriteDatabase(" & Err.Description & ")"
End Function
[/code]
October 17, 2005, 8:21 PM
Elneroth
'grrzor', your access checking looks fine
October 17, 2005, 8:59 PM
cHip
Well... something is messed up...
October 17, 2005, 9:05 PM
Myndfyr
[quote author=HdxBmx27 link=topic=13058.msg131340#msg131340 date=1129566675]
[quote author=MyndFyre link=topic=13058.msg131338#msg131338 date=1129564880]
Why is this?  I don't really remember much from the telnet connection protocol, but I seem to remember all Bnet data coming in (besides the username/text) in uppercase.
[/quote]
because if you would read the code, He is LCase()ing the message, and then comparing it to a string with upper-case letters.
This would always make it evaluate to 0.
~-~(HDX)~-~
[/quote]

Oh I see it now.  He's got several statements in one line.  I looked for an LCase(expr) above the line where he runs InStr().  L0LL3rsk4t3z.
October 17, 2005, 11:12 PM
Yegg
I don't even see why we (or anyone) help people like this.
October 17, 2005, 11:42 PM
Quarantine
We is a lot of people, don't see you helping.
Also, he shows initiative to want to find a solution to his problem and one is being (if it already has not been) provided for him.
October 18, 2005, 12:27 AM
cHip
Yeah, thanks guys  ;D
October 18, 2005, 12:54 AM
Yegg
[quote author=Warrior link=topic=13058.msg131388#msg131388 date=1129595235]
We is a lot of people, don't see you helping.
Also, he shows initiative to want to find a solution to his problem and one is being (if it already has not been) provided for him.
[/quote]
I also noted "or anyone" to specify that I wasn't referring to myself, because I am often NOT on this website. But I guess I didn't specify that clearly enough. The problem that bothers me with people such as Chip, is when they talk like the following, and I quote directly from what Chip said in his posts:
"thanx for the helpz0r"
"I wrote when I was a lil beat"
"it's my database. LoLz"
"this durn thing"
"looking through all 300 some fourms"

By the way, no offense to you Chip. But these types of statements just annoy me greatly.
October 18, 2005, 1:24 AM
cHip
Yegg, i understand fully...

Sorry for how I worded myself.  I was a little under the weather when I wrote the code and when I posted here. 

I did actually look through about 300 posts on these forums to try and figure out what my problem was.  I did come across a few similar questions about the same topic, but still had no solution for what was wrong with my code.

I'm sorry for being stupid... or using I guess "leet" talk (dunno), or for waisting your time, but thanks to the others that helped me!
October 18, 2005, 1:44 AM
Yegg
That's okay.

PS. You didn't waste my time at all. I come here on my free time.
October 18, 2005, 1:51 AM
Explicit[nK]
[quote author=Yegg link=topic=13058.msg131394#msg131394 date=1129598640]
[quote author=Warrior link=topic=13058.msg131388#msg131388 date=1129595235]
We is a lot of people, don't see you helping.
Also, he shows initiative to want to find a solution to his problem and one is being (if it already has not been) provided for him.
[/quote]
I also noted "or anyone" to specify that I wasn't referring to myself, because I am often NOT on this website. But I guess I didn't specify that clearly enough. The problem that bothers me with people such as Chip, is when they talk like the following, and I quote directly from what Chip said in his posts:
"thanx for the helpz0r"
"I wrote when I was a lil beat"
"it's my database. LoLz"
"this durn thing"
"looking through all 300 some fourms"

By the way, no offense to you Chip. But these types of statements just annoy me greatly.
[/quote]

They annoy all of us.
October 18, 2005, 2:26 AM
Elneroth
If you were to say that where I live someone would probably shoot you with a 22. haah.. (Upstate NY)
October 18, 2005, 2:41 AM
Yegg
[quote author=Warrior link=topic=13058.msg131417#msg131417 date=1129605511]
I just didn't think it would be place for you to speak, you know since you contributed nothing torwards solving the problem. Regardless of how he speaks.
[/quote]
Am I not allowed to speak how I feel about something? I've seen many others on these forms do the same, and nothing was said to them. Why is something said to me however?
October 18, 2005, 5:32 PM
Myndfyr
[quote author=Yegg link=topic=13058.msg131451#msg131451 date=1129656762]
[quote author=Warrior link=topic=13058.msg131417#msg131417 date=1129605511]
I just didn't think it would be place for you to speak, you know since you contributed nothing torwards solving the problem. Regardless of how he speaks.
[/quote]
Am I not allowed to speak how I feel about something? I've seen many others on these forms do the same, and nothing was said to them. Why is something said to me however?
[/quote]
Because typically when we speak up, the people don't show ANY attempt to help themselves.  Or, frequently for example, Kp will give an answer that would work if you'd done everything his way.  Your comment was 100% dry, witless, and entirely negative.
October 18, 2005, 5:42 PM
Stealth
[quote author=HdxBmx27 link=topic=13058.msg131340#msg131340 date=1129566675]
[quote author=MyndFyre link=topic=13058.msg131338#msg131338 date=1129564880]
Why is this?  I don't really remember much from the telnet connection protocol, but I seem to remember all Bnet data coming in (besides the username/text) in uppercase.
[/quote]
because if you would read the code, He is LCase()ing the message, and then comparing it to a string with upper-case letters.
This would always make it evaluate to 0.
~-~(HDX)~-~
[/quote]

Hey, cHip!

Trick question. It doesn't actually matter -- he used the vbTextCompare option so it's case-insensitive. :)
November 4, 2005, 12:29 AM
Null
[quote][/quote]
Kp will give an answer that would work if you'd done everything his way.  Your comment was 100% dry, witless, and entirely negative.
[quote][/quote]

Generally from my readings KP likes to write up paragraphs of bullshit so he can look good.

If he was really helpful he would just give the person in question the answer without the cryptic "im so above u it isnt funny" garble.

BTW: Im not debating his intelligence, im debating that he is an asshole.
November 4, 2005, 2:19 AM

Search