Ritch Posted October 20, 2009 Share Posted October 20, 2009 expandcollapse popup#include <File.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> Global $CurrentSocket = 0 Global $ListenSocket Global $ConnectedSocket[16] Global $AUTH[16] For $INDEX = 0 To 15 $AUTH[$INDEX] = 0 Next $TCP = TCPStartup() If $TCP = 0 Then MsgBox(0, "Error", "Unable to startup TCP Services!") Exit EndIf $ListenSocket = TCPListen(@IPAddress1,1777,16) If $ListenSocket = -1 Then MsgBox(0, "ERROR", "Unable to start listening on port 1777") Exit EndIf While 1 $ConnectedSocket[$CurrentSocket] = TCPAccept($ListenSocket) If $ConnectedSocket[$CurrentSocket] <> -1 Then $CurrentSocket = $CurrentSocket + 1 EndIf For $INDEX = 0 To 15 If $ConnectedSocket[$INDEX] <> -1 Or $ConnectedSocket[$INDEX] <> "" Then $Recv = TCPRecv($ConnectedSocket[$INDEX], 99999999) If $Recv <> "" Then If $AUTH[$INDEX] <> 0 Then For $INDEX = 0 To 15 If $ConnectedSocket[$INDEX] <> - 1 And $AUTH[$INDEX] = 1 Then TCPSend($ConnectedSocket[$INDEX],$Recv) EndIf Next EndIf If StringLeft($Recv,4) = "AUTH" Then $DATA = StringSplit($Recv," ") $USER = $DATA[2] $PASSWORD = $DATA[3] If Verify($USER,$PASSWORD) Then $AUTH[$INDEX] = 1 ToolTip($ConnectedSocket[$INDEX],200,0) TCPSend($ConnectedSocket[$INDEX],"Successful login.") Sleep(500) $char_class = FileOpen(@ScriptDir & "\offsetchar.dat",0) $char_clas_read = FileReadLine($char_class,1) Sleep(100) TCPSend($ConnectedSocket[$INDEX],$char_clas_read) elseIf not Verify($USER,$PASSWORD) Then ToolTip($ConnectedSocket[$INDEX],100,0) TCPSend($ConnectedSocket[$INDEX],"Login Fail.") TCPCloseSocket($ConnectedSocket[$INDEX]) EndIf EndIf If StringLeft($Recv,4) = "CLAS" Then $DATA2 = StringSplit($Recv," ") $NICK = $DATA2[2] $CLAS = $DATA2[3] If Verify_nick($NICK,$CLAS) Then sleep(100) TCPSend($ConnectedSocket[$INDEX],"hi");CRASH in THIS LINE <------------------ ElseIf not Verify_nick($NICK,$CLAS) Then TCPCloseSocket($ConnectedSocket[$INDEX]) Endif Endif EndIf EndIf Next Sleep(100) WEnd Func Verify($USER,$PASSWORD) Local $INDEX Local $DATA $DATABASE = FileOpen(@ScriptDir & "\Database.dat",0) For $INDEX = 1 To _FileCountLines(@ScriptDir & "\Database.dat") $LINE = FileReadLine($DATABASE,$INDEX) $DATA = StringSplit($LINE," ") If $DATA[1]=$USER AND $DATA[2]=$PASSWORD Then Return 1 Next EndFunc Func Verify_nick($NICK,$CLAS) Local $INDEX2 Local $DATA2 $DATABASE2 = FileOpen(@ScriptDir & "\char.dat",0) For $INDEX2 = 1 To _FileCountLines(@ScriptDir & "\char.dat") $LINE2 = FileReadLine($DATABASE2,$INDEX2) $DATA2 = StringSplit($LINE2," ") If $DATA2[1]=$NICK AND $DATA2[2]=$CLAS Then Return 1 Next EndFunc two problen Server crash in tcpsend (i mark line) Array variable has incorrect number of subscripts or subscript dimension range exceeded.: TCPSend($ConnectedSocket[$INDEX],"hi") TCPSend(^ ERROR i not found this error oO!!! other is. how to show ip or name users conecteds? Link to comment Share on other sites More sharing options...
FuryCell Posted October 20, 2009 Share Posted October 20, 2009 Its kind of hard to debug without the client's source code being provided but you should check your data to make sure it is a array to avoid a crash. HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code. Link to comment Share on other sites More sharing options...
Ritch Posted October 20, 2009 Author Share Posted October 20, 2009 if I remove this line I function. to put I utiliso this exactly tcpsend () in other parts of the code and do not happen the error. If somebody will be able to say the reason to me I would be thankful. I read some posts saying that this error can be caused by an error of Loop + did not find this error. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now