Jump to content

Random Error, no clue whats causing it or how to fix


Recommended Posts

So I'm editting a IRC engine I found on a topic made by

I then went ahead and edited it to my needs... Thats pretty much, adding new commands, encrypting all of the messages... I removed most of the custom commands I was using because they're not the cause of the error. I left in part of my encryption code... I left in was the code that I might have been causing the problem, cept /cls... because thats just a usefull command and I'm pretty sure it's not the problem.

Anyway... the bug is triggered when...

  • User1 and User2 connect
  • User1 private messages User2
  • User1 quits and rejoins
  • User2 private messages User1
  • User2 quits... server crashes

If you're going to try and debug this, unless you change the code in the program... or follow these steps you can't really preform the bug on your local computer

  • Start client...
  • Change name in settings.ini
  • start another client

and that is how you get two accounts on one server...

Source is in attached files...

Thanks in advance :)

IRC Server.zip

Edited by OneManPen
Link to comment
Share on other sites

When user1 quits, I receive an error message for line 57 in server.au3:

If $SOCKET[$Cx] <> "" Then

"Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded."

Link to comment
Share on other sites

Hi,

I'm not sure but if it is after disconnecting it seems likely $SOCKET is 'unset' (something like $SOCKET = -1) somehwere and therefor $SOCKET[$Cx] will fail, but I did not look at the code so it's pure speculation.

However if it's this line that's causing the error...

If $SOCKET[$Cx] <> "" Then

...just check if $SOCKET is an array...

If IsArray($SOCKET) And $SOCKET[$Cx] <> "" Then

...or even if element $Cx exists...

If IsArray($SOCKET) And $Cx >= 0 And $Cx < UBound($SOCKET) And $SOCKET[$Cx] <> "" Then

Hope this helps.

Link to comment
Share on other sites

The problem is that you're going through the $Socket array forwards, but in some cases you're deleting elements of that array. You need to traverse the $Socket array in reverse so that if you delete elements you don't overshoot the end of your new array with the For...Next loop. Use this in line 48

For $Cx = UBound($SOCKET) - 1 To 0 Step -1

See if that fixes the problem.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

The problem is that you're going through the $Socket array forwards, but in some cases you're deleting elements of that array. You need to traverse the $Socket array in reverse so that if you delete elements you don't overshoot the end of your new array with the For...Next loop. Use this in line 48

For $Cx = UBound($SOCKET) - 1 To 0 Step -1

See if that fixes the problem.

Yay! that fixed it ( I think)... not sure how or why... but thanks anyway :)
Link to comment
Share on other sites

Think of your array this way, the array holds elements 0,1,2,3,4,5,6. As you go through the For...Next loop it's counting from 0 through 6. If you delete elemnt 3 for example, because that user has disconnected, then your array now holds elements 0,1,2,3,4,5 and when your For...Next loop gets to 6 it's not there any longer and you get a subscript error. Plus, you're skipping element 4 because that's now element 3 because you deleted one of them below it.

If you loop in reverse and you delete element 3, the loop won't care because it's now looking at element 2, instead of element 4 the next time around.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...