• Welcome to Valhalla Legends Archive.
 

[VB6] Say command

Started by cHip, October 17, 2005, 02:29 AM

Previous topic - Next topic

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

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.

Elneroth

First of all, since when are capital letters in lowercase strings? ;)
If InStr(1, LCase(s), "1009 USER " & Configuration.Username & " 0012", vbTextCompare) > 0 Then
Should be:
If InStr(1, LCase(s), "1009 user " & lcase(Configuration.Username) & " 0012", vbTextCompare) > 0 Then

Command = Mid(s, InStr(s, "0010") + 5, Len(s))
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:
Command = Mid(s, InStr(s, "0010") + 5)
This will tell it to just go on for the rest of the string.

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

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


Hope at least some of that helps.

MyndFyre

Quote from: Elneroth on October 17, 2005, 07:59 AM
First of all, since when are capital letters in lowercase strings? ;)
If InStr(1, LCase(s), "1009 USER " & Configuration.Username & " 0012", vbTextCompare) > 0 Then
Should be:
If InStr(1, LCase(s), "1009 user " & lcase(Configuration.Username) & " 0012", vbTextCompare) > 0 Then

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.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Hdx

Quote from: MyndFyre on October 17, 2005, 11:01 AM
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.
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)~-~

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

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...)

    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

Elneroth

'grrzor', your access checking looks fine

cHip

Well... something is messed up...

MyndFyre

Quote from: HdxBmx27 on October 17, 2005, 11:31 AM
Quote from: MyndFyre on October 17, 2005, 11:01 AM
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.
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)~-~

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.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Yegg

I don't even see why we (or anyone) help people like this.

Warrior

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 from: effect on March 09, 2006, 11:52 PM
Islam is a steaming pile of fucking dog shit. Everything about it is flawed, anybody who believes in it is a terrorist, if you disagree with me, then im sorry your wrong.

Quote from: Rule on May 07, 2006, 01:30 PM
Why don't you stop being American and start acting like a decent human?

cHip


Yegg

Quote from: Warrior on October 17, 2005, 07:27 PM
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.
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.

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!

Yegg

That's okay.

PS. You didn't waste my time at all. I come here on my free time.

Explicit

Quote from: Yegg on October 17, 2005, 08:24 PM
Quote from: Warrior on October 17, 2005, 07:27 PM
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.
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.

They annoy all of us.
I'm awake in the infinite cold.

[13:41:45]<@Fapiko> Why is TehUser asking for wang pictures?
[13:42:03]<@TehUser> I wasn't asking for wang pictures, I was looking at them.
[13:47:40]<@TehUser> Mine's fairly short.