When someone else in the channel types a command like.. !say hi, it works, but when I type it in, it shows it on the chat screen, but it doens't actualyl appear (I checked with starcraft). Can anyone help me?
I'm using a sub routine that deals with commands and a subroutine that sends the commands.
Public Sub SendData(strGetIt As String)
frmChat.ws.SendData strGetIt + vbCrLf
frmChat.txtChat.SelStart = Len(frmChat.txtChat.Text)
frmChat.txtChat.SelColor = RGB(0, 0, 255)
frmChat.txtChat.SelText = Time & " "
frmChat.txtChat.SelColor = RGB(0, 255, 255)
frmChat.txtChat.SelText = "<" & strBUsername & "> "
frmChat.txtChat.SelColor = RGB(255, 255, 255)
frmChat.txtChat.SelText = strGetIt + vbCrLf
If Left(strGetIt, 2) Like "!?" Then
modCommands.Command strGetIt, strBUsername, False
End If
Exit Sub
End Sub
Public Sub Command(strCommand As String, strUsername As String, blnWhisper As Boolean)
Dim strManipulate As String
Dim strVoid As String
If InStr(strCommand, " ") = 0 Then
strManipulate = strCommand
Else
strManipulate = LCase(Mid(strCommand, 1, InStr(strCommand, " ") - 1))
End If
Select Case strManipulate
Case "!say"
modIce.SendData Mid(strCommand, 6)
Case "!dc"
Disconnect
Case "!disconnect"
Disconnect
Case "!join"
modIce.SendData "/join " + Mid(strCommand, 7)
End Select
End Sub
can anyone help me with this? thx
Battle.net doesn't echo back text you send it, so you're probably only checking for commands when you recieve a chat packet. You'll have to call your Command() function when you send chat as well.
Try using
If Left(strGetIt, 2) Like "!*" Then
modCommands.Command strGetIt, strBUsername, False
End If
Instead of a "?". ? is any character, where * could be a part of a string or all of it.
Why not just use If Left(strGetIt, 1) = "!" Then
modCommands.Command strGetIt, strBUsername, False
End If
and save the nanoseconds?
Quote from: Camel on July 07, 2003, 03:24 PM
Battle.net doesn't echo back text you send it, so you're probably only checking for commands when you recieve a chat packet. You'll have to call your Command() function when you send chat as well.
Private Sub txtSend_KeyPress(KeyAscii As Integer)
If Len(txtSend.Text) > 254 Then
KeyAscii = 0
End If
If KeyAscii = 13 And frmChat.ws.State <> sckClosed Then
KeyAscii = 0
If txtSend.Text <> "" And Len(txtSend.Text) < 254 Then
modIce.SendData txtSend.Text
txtSend.Text = ""
End If
ElseIf KeyAscii = 13 And frmChat.ws.State = sckClosed Then
KeyAscii = 0
Disconnect
intresponse = MsgBox("You are offline. Do you want to connect?", vbYesNo)
If intresponse = vbYes Then
Connect (frmSetup.cmbServer.Text)
End If
End If
End Sub
I'm calling the SendData sub routine, which calls the commands subroutine every time the user types enter.
Are there any other explanations?
I have another question.. when winsock receives data, does visual basic run through the code in that event immediately, or finish what its doing first?
Try using VB's debugger to step through your SendData function -- that might help you find your problem.
And as long as you're not somehow using threads in VB (ewwwww), it should finish what it's doing first.
Quote from: JoeCool on July 09, 2003, 06:23 PMseems long and complicated
And I suppose your majesty has a better solution?
Quote from: Camel on July 08, 2003, 05:39 PM
Try using VB's debugger to step through your SendData function -- that might help you find your problem.
And as long as you're not somehow using threads in VB (ewwwww), it should finish what it's doing first.
Well I looked into this a little more. I created another program that listened on port 6112, and set the server for my bot to localhost. I'm not sure why, but it seems as if if there is more than one "frmChat.ws.SendData strGetIt + vbCrLf" in a module or in a function or subroutine that it calls, it fuses the things I want to send in one clump. Is this normal, and how can I solve this? Thx.
Found my answer in another post :)
Quote from: Nub on July 15, 2003, 01:28 PM
Try adding a DoEvents before you close the socket
Example:
Socket.Senddata "blah blah blah im leaveing bnet... blah..." & VbCrLf
DoEvents
Socket.Close
Hope that helps...
Uh, you never said anything about closing the connection.
It was the DoEvents part :)