I'm not gonna post the whole code, just the relevant chunks. This is the loop.
So the problem is, the code completely ignores "If $test = 0 Then" and carries on doing things that should not be done unless $test = 0.
$test is returned by a function but this function never returns zero, because the message box i've set up never shows up.
While 1 $Accept = TCPAccept ($TCPListen) ; Keep accepting connections If $Accept <> -1 Then _ArrayAdd ($Socket, $Accept) ; If a connection is made - it's added to a list. $Max = $Max + 1 ;Number of connections EndIf For $i=1 to $Max ;Keep recieving data from all the connections $Message = TCPRecv ($Socket [$i], 100000) Sleep (10) If @error Then TCPClose ($i);If there is an error - close the connection If $Message <> "" Then ; If the message recieved is not empty $test = LogIn ($Message) ;$test is the return value MsgBox (0, "test", $test) ;Here's the kicker, this messagebox shows a value that is NOT zero. If $test = 0 Then MsgBox (0, "test", $test) ;Even though for some reason the value above was not zero it goes to this stage and the messagebox displays THE SAME value, SendAll ($Message) MsgBox (0, "test", $test) ;Again, same value for $test ElseIf $test = 1 Then TCPSend ($Socket [$i], "Not found") TCPCloseSocket ($Socket[$i]) _ArrayDelete ($Socket, $i) Elseif $test <> 0 and $test <> 1 Then ;This is what should happen but it's just ignored! $SendBack = LogIn ($Message) TCPSend ($Socket [$i], $SendBack) $split = StringSplit ($SendBack, ",") _ArrayAdd ($Users, $split) EndIf EndIf Next WEnd
Func LogIn ($String) If StringLeft ($String, 19) = "SomethingThatHas19Digits" Then $String = StringTrimLeft ($String, 19) Local $Ladder _FileReadToArray("Ladder.txt", $Ladder) $Search = _ArraySearch ($Ladder, $String, 1, 0, 0, 1) If $Search <> -1 Then return $Ladder [$Search] If $Search = -1 Then return 1 Else return 0 MsgBox (0, "test", "returned 0") EndIf EndFunc