Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: WinSocks on May 12, 2003, 06:39 PM

Title: Channel Problems with my Bot...
Post by: WinSocks on May 12, 2003, 06:39 PM
yeah i ben having weird ass runtime errors as it says when i join a channel with more than 10 users in it..... i get this error sometimes when i do join the channel with more than 10 users in it.

--------------------------------------------------------
'Run-time error '5':

Invalid procedure call or argument
--------------------------------------------------------

when i select debug it sends me to this snippet of code.

Private Sub sckBnet_DataArrival(ByVal bytesTotal As Long)
Dim strBuffer As String, strTemp As String, lngLen As Long
   frmMain.sckBnet.GetData strTemp, vbString
       strBuffer = strBuffer & strTemp
   While Len(strBuffer) > 4
       lngLen = Val("&H" & StrToHex(StrReverse(Mid(strBuffer, 3, 2))))
       If Len(strBuffer) < lngLen Then Exit Sub
            Parse (Left(strBuffer, lngLen)) <<<--------- This is the highlighted text when debugged
      strBuffer = Mid(strBuffer, lngLen + 1)
  Wend
 
End Sub


If anyone can help me with this problem it would be greatful...
Title: Re:Channel Problems with my Bot...
Post by: Noodlez on May 12, 2003, 06:48 PM
You're probably not getting the entire packet, so when you attempt to do Left(data,length) Left won't work.
Title: Re:Channel Problems with my Bot...
Post by: WinSocks on May 12, 2003, 07:07 PM
is there any way to remedy this problem?
Title: Re:Channel Problems with my Bot...
Post by: Noodlez on May 12, 2003, 08:16 PM
Compare the length of the buffer with the length the packet should be, if the length is too short, assume the next packet you will be receiving contains more (if not the rest) of your packet.
Title: Re:Channel Problems with my Bot...
Post by: Camel on May 12, 2003, 08:26 PM
Quote from: Noodlez on May 12, 2003, 06:48 PM
You're probably not getting the entire packet, so when you attempt to do Left(data,length) Left won't work.

i don't think left will ever cause a runtime error...it'll just assume you meant the entire string if you put a longer length
Title: Re:Channel Problems with my Bot...
Post by: drivehappy on May 12, 2003, 09:09 PM
Camel, you're correct. You do get an Invalid procedure call or argument if the length is negative though.

Vial, use the Debug.Print for the length and check what the last one is on error.
Title: Re:Channel Problems with my Bot...
Post by: WinSocks on May 12, 2003, 09:19 PM
I talked to Spht on battle.net and he told me that if i put:

On Error Resume Next

it should prevent some of the erros that occur when i join a channel, it don't make the Run-time error anymore though, but the bot crashes now when i have that code in it. I need to take a break i'm wreaking my brain over it..

*Pops some Advil*
Title: Re:Channel Problems with my Bot...
Post by: Camel on May 12, 2003, 11:23 PM
just a commment: On Error Resume Next is sort of a last ditch resort: it absolutely does not solve the problem; it simply prevents vb from reporting the error. if you want to handle the error, you might try On Error Goto <lable>
Title: Re:Channel Problems with my Bot...
Post by: Spht on May 13, 2003, 01:24 PM
Quote from: ViaL on May 12, 2003, 09:19 PM
I talked to Spht on battle.net and he told me that if i put:

On Error Resume Next

it should prevent some of the erros that occur when i join a channel, it don't make the Run-time error anymore though, but the bot crashes now when i have that code in it. I need to take a break i'm wreaking my brain over it..

*Pops some Advil*


...Huh? I wasn't talking to anyone on Battle.net lately about Visual Basic, and I wouldn't suggest you to use that statement [see Camel's reply]. I believe you have me mistaken for someone else.
Title: Re:Channel Problems with my Bot...
Post by: Banana fanna fo fanna on May 14, 2003, 02:53 PM
+1 for linux avatar + vb question