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.
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.
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.
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)~-~
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
'grrzor', your access checking looks fine
Well... something is messed up...
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.
I don't even see why we (or anyone) help people like this.
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.
Yeah, thanks guys ;D
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.
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!
That's okay.
PS. You didn't waste my time at all. I come here on my free time.
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.
If you were to say that where I live someone would probably shoot you with a 22. haah.. (Upstate NY)
Quote from: Warrior on October 17, 2005, 10:18 PM
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.
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 from: Yegg on October 18, 2005, 12:32 PM
Quote from: Warrior on October 17, 2005, 10:18 PM
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.
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?
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.
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)~-~
Hey, cHip!
Trick question. It doesn't actually matter -- he used the vbTextCompare option so it's case-insensitive. :)
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
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.