Author | Message | Time |
---|---|---|
-kP-FuZioN | 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. [code]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[/code] [code]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[/code] can anyone help me with this? thx | July 7, 2003, 8:04 PM |
Camel | 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. | July 7, 2003, 8:24 PM |
UserLoser | Try using [code] If Left(strGetIt, 2) Like "!*" Then modCommands.Command strGetIt, strBUsername, False End If [/code] Instead of a "?". ? is any character, where * could be a part of a string or all of it. | July 7, 2003, 8:54 PM |
Camel | Why not just use [code] If Left(strGetIt, 1) = "!" Then modCommands.Command strGetIt, strBUsername, False End If[/code] and save the nanoseconds? | July 8, 2003, 5:16 AM |
-kP-FuZioN | [quote author=Camel link=board=17;threadid=1825;start=0#msg14095 date=1057609473] 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. [/quote] [code]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[/code] 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? | July 8, 2003, 5:43 PM |
Camel | 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. | July 8, 2003, 10:39 PM |
Camel | [quote author=JoeCool link=board=17;threadid=1825;start=0#msg14360 date=1057793018]seems long and complicated[/quote] And I suppose your majesty has a better solution? | July 9, 2003, 11:43 PM |
-kP-FuZioN | [quote author=Camel link=board=17;threadid=1825;start=0#msg14198 date=1057703989] 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] 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. | July 17, 2003, 3:12 AM |
-kP-FuZioN | Found my answer in another post :) [quote author=Nub link=board=17;threadid=1915;start=0#msg14898 date=1058293694] Try adding a DoEvents before you close the socket Example: [code] Socket.Senddata "blah blah blah im leaveing bnet... blah..." & VbCrLf DoEvents Socket.Close [/code] Hope that helps... [/quote] | July 17, 2003, 3:34 AM |
Camel | Uh, you never said anything about closing the connection. | July 17, 2003, 8:10 AM |
-kP-FuZioN | It was the DoEvents part :) | July 17, 2003, 1:27 PM |