Jump to content

OECR


CodyBarrett
 Share

Recommended Posts

well.. i wrote a server that can hand any amount (tested out to a max of 20 clients XD no time to test further...) but you can set it to a max of any thing...

and the clients connect and its one big chatroom with Moderators & Admins... and then the old normal Normal User lol these status can be viewed by the server GUI the server doesn't ahve a GUI to interact with the room... gotta use a client script for that

Features :====== HOW TO USE THEM

*PM messaging ====== Click "UP" and the client list will load in the left input

*Encryption ====== Automatically sends the encryptedpackets

*Spamming Penalty ====== adds a value and.... basically a time and the timer goes up per message and goes down after no messagehas been sent for Xseconds

*Diconnection ====== "UP" -> select a client from the list -> hit "DC selected client" -> then -> send MUST BE MOD or ADMIN

*Banning ====== "UP" -> select a client from the list -> hit "BAN selected client" -> then -> send MUST BE MOD or ADMIN

*UNBanning ====== "Blacklist" -> hit "UNBAN selected client" -> type in the client you want to UNBAN... like this (ex)"UNBAN:Client 1" then -> send MUST BE MOD or ADMIN

*Moderator Password & automatic Mod status upon logon ====== put the password in brackets ( & ) then "OK"

*Administrator Password & automatic Admin status upon logon ====== put the password in brackets ( & ) then "OK"

*Custom GUI

*DNS support OR use ip NOT BOTH won't allow that XD

UPCOMMING FEATURES:

*Suggestion Box ---- Edit & Button control to bring in suggestions

*PVP -> Tick Tack Toe ---- one on one.... pretty much through PM... and results are broadcasted

*ScrollBar ---- for Console

*Function GUI ---- click on the right hand side of the GUI and a popup comes up with the functions

*Account Registration \ Anonomous account ---- registration you get to choose your name... anonomous it randomizes a name for you... MAX 8 characters... NO spaces...

*Singular ---- only one client Per Computer

*Static Port & DNS system ---- implifying it for the user...

*FTP ---- through PM OR BRoadcast....

*BackGround Color ---- Saved into REgistered acc file

*Emoticons ---- need i explain?

=======================================SERVER=======================================

#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=ICON2.ico
#AutoIt3Wrapper_outfile=OECRS.exe
#AutoIt3Wrapper_Res_Comment=Startup the server.. and let the clients connect!!
#AutoIt3Wrapper_Res_Description=Chatroom Server
#AutoIt3Wrapper_Res_Fileversion=1.157.0.0
#AutoIt3Wrapper_Res_LegalCopyright=Cody Barrett
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUICONSTANTS.AU3>
#include <WINDOWSCONSTANTS.AU3>
#include <STATICCONSTANTS.AU3>
#include <EDITCONSTANTS.AU3>
#include <MISC.AU3>
#include <STRING.AU3>
#include <FILE.AU3>
#include <DATE.AU3>
#include <WINAPI.AU3>
#include <ARRAY.AU3>
#include <GUIEDIT.AU3>
#include <GUISTATUSBAR.AU3>
#include <GUICONSTANTSEX.AU3>
#include <SCROLLBARCONSTANTS.AU3>
TCPStartup ()
$GUIStyle = BitOR($WS_POPUP, $WS_VISIBLE)
$GUIStyleEx = $WS_EX_WINDOWEDGE
$LabelStyle = BitOR ($SS_CENTER, $SS_CENTERIMAGE)
$EditStyle = BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_TABSTOP)
$EditStyleEx = BitOR($EditStyle, $ES_READONLY)
$Bk_C = 0xFFFFFF
$F_C = 0x0
$Sent = 0xEFDD01
$SentBk = 0x454545
$Font = 'Tahoma'
$Last_Socket = 0
$M1 = '<MSG><'
$M2 = '></MSG>'
_Reset_Misc_Vars ()
$The_List = @ScriptDir & '\The List.Ini'
$Ini_1 = '###GLOBAL###'
$Ini_2 = '###BLACKLIST###'
$Ini_3 = 'Moderators'
$Ini_4 = 'Administrators'
$Ini_5 = 'Mod_Password'
$Ini_6 = 'Admin_Password'
$Dungeon = 'C:\WINDOWS\Fonts\Dungeon.ttf'
If Not FileExists ($The_List) Then
    For $0 = 1 To 20
        IniWrite ($The_List, $Ini_2, $0,'')
    Next
    IniWrite ($The_List, $Ini_1, $Ini_3, '( )')
    IniWrite ($The_List, $Ini_1, $Ini_4, '( )')
    IniWrite ($The_List, $Ini_1, $Ini_5, '(' & Hex (Random (0, 10000, 1)) & ')')
    IniWrite ($The_List, $Ini_1, $Ini_6, '(' & Hex (Random (0, 10000, 1)) & ')')
EndIf

;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
$Settings = GUICreate ('Settings...', 350, 250)
GUICtrlCreateLabel ('DNS Domain :', 20, 20, 100, 20, $LabelStyle)
GUICtrlCreateLabel ('IP Address :', 20, 50, 100, 20, $LabelStyle)
GUICtrlCreateLabel ('Port Number:', 20, 80, 100, 20, $LabelStyle)
GUICtrlCreateLabel ('Max Connections:', 20, 110, 100, 20, $LabelStyle)
GUICtrlCreateLabel ('If Using IP address... leave DNS Domain EMPTY!!!' & @CRLF & _
    'If Using DNS Domain... leave IP FIELDS EMPTY!!!', 0, 150, 350, 30,$SS_CENTER)
$DNS = GUICtrlCreateInput ('4A012ACE.HomeDNS.Org',130, 20, 200, 20,$LabelStyle)
Dim $ip_IN[4]
$ip_IN[0] = GUICtrlCreateInput ('', 130, 50, 45, 20,$LabelStyle)
$ip_IN[1] = GUICtrlCreateInput ('', 182, 50, 45, 20,$LabelStyle)
$ip_IN[2] = GUICtrlCreateInput ('', 235, 50, 45, 20,$LabelStyle)
$ip_IN[3] = GUICtrlCreateInput ('', 285, 50, 45, 20,$LabelStyle)
$ip = StringSplit (@IPAddress1, '.')
$00 = 0
For $0 = 0 To 3
    $00 += 1
    GUICtrlSetData ($ip_IN[$0], $ip[$00])
    GUICtrlSetLimit ($ip_IN[$0], 3, 1)
Next
$Port = GUICtrlCreateInput (Random (1, 60000, 1), 130, 80, 200, 20, $LabelStyle)
$Max = GUICtrlCreateInput (Random (1, 1000,1), 130, 110, 200, 20, $LabelStyle)
$StartUp_Button = GUICtrlCreateLabel ('StartUp', 20, 200, 150, 30, $LabelStyle)
    GUICtrlSetBkColor (-1,$F_C )
    GUICtrlSetFont (-1, 15, 600, '', $Font)
    GUICtrlSetColor (-1, $Bk_C)
    GUICtrlSetCursor (-1, 0)
$Cancel_Button = GUICtrlCreateLabel ('Cancel', 180, 200, 150, 30, $LabelStyle)
    GUICtrlSetBkColor (-1,$F_C )
    GUICtrlSetFont (-1, 15, 600, '', $Font)
    GUICtrlSetColor (-1, $Bk_C)
    GUICtrlSetCursor (-1, 0)
GUISetState ()
While 1
    $m = GUIGetMsg ()
    Select
        Case $m = $StartUp_Button
            GUICtrlSetColor ($StartUp_Button, $Sent)
            GUICtrlSetBkColor ($StartUp_Button, $SentBk)
            $ip = GUICtrlRead ($ip_IN[0]) & '.' &  GUICtrlRead ($ip_IN[1]) & '.' &  GUICtrlRead ($ip_IN[2]) & '.' &  GUICtrlRead ($ip_IN[3])
            If GUICtrlRead ($DNS) = '' And  $ip = '...' Or GUICtrlRead ($DNS) <> '' And  $ip <> '...' Then 
                MsgBox (48, 'ERROR', 'Please fill in Either DNS or IP fields!!')
            Else
                If $ip = '...' Then $ip = TCPNameToIP (GUICtrlRead ($DNS))
                $port = GUICtrlRead ($port)
                $Max = GUICtrlRead ($Max)
                GUIDelete ($Settings)
                ExitLoop
            EndIf
            Sleep (100)
            GUICtrlSetColor ($StartUp_Button, $Bk_C)
            GUICtrlSetBkColor ($StartUp_Button, $F_C)
        Case $m = $Cancel_Button Or $m = $GUI_EVENT_CLOSE
            GUICtrlSetColor ($Cancel_Button, $Sent)
            GUICtrlSetBkColor ($Cancel_Button, $SentBk)
            Sleep (100)
            GUICtrlSetColor ($Cancel_Button, $Bk_C)
            GUICtrlSetBkColor ($Cancel_Button, $F_C)
            TCPShutdown ()
            Exit
    EndSelect
WEnd

;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
$GUI = GUICreate ('Server', 300, 400, -1, -1, $GUIStyle, $GUIStyleEx, WinGetHandle ('Program Manager') )
GUISetBkColor ($F_C, $GUI)
GUICtrlSetDefBkColor ($F_C, $GUI)
GUISetFont (8,400, '', $Font, $GUI)
GUICtrlSetColor (-1, $Bk_C)
GUICtrlCreateLabel ($ip & ' -- ' & $port & ' -- ' & $Max, 0, 0, 280, 20,$LabelStyle)
GUICtrlSetColor (-1, $Bk_C)
$On_Top = GUICtrlCreateCheckbox ('', 280, 0, 20,20)
GUICtrlSetState (-1, $GUI_CHECKED)
$list = GUICtrlCreateEdit ('',10, 20, 280, 370,$EditStyleEx)
GUICtrlSetColor (-1, $Bk_C)
GUISetState ()
WinMove ($GUI, '', @DesktopWidth - 300, @DesktopHeight - 430)

;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
HotKeySet ('!+^{ESC}', '_TCPShutdown')

$Main_Socket = TCPListen ($Ip,$Port,$Max)
Dim $Sockets[$Max + 1][5]
ProgressOn ('Sockets...','Reseting Socket List...')
For $0 = 0 To $Max - 1
    For $00 = 0 To 4
        $000 = Round ((($0 + $00) / ($Max + 3)) * 100)
        ProgressSet ($000, $000 & '% Reseting Socket List...')
        $Sockets[$0][$00] = 0
        Sleep (10)
    Next
Next
_Reset_Misc_Vars ()
$Sockets[0][0] = 0
ProgressOff ()
$The_List_Size = FileGetSize ($The_List)

;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
While 1
    If GUICtrlRead ($On_Top) = $GUI_CHECKED Then WinSetOnTop ($GUI, '', 1)
    If GUICtrlRead ($On_Top) <> $GUI_CHECKED Then WinSetOnTop ($GUI, '', 0)    
    If GUIGetMsg () = $GUI_EVENT_CLOSE Then _TCPShutdown ()
    _Accept_Incomming_Socket_Connection ()
    _Receive_Data_From_Sockets ()
        For $0 = 1 to $Max
            If $Sockets[$0][0] <> 0 And $Last_Socket = 1 Then 
                _TCPSend ($Sockets[$0][0],$M1 & '[-Server-] <--- You Are the Only Client online... --->' & $M2)
                $Last_Socket = 0
            EndIf
        Next
    Sleep (100)
WEnd

;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
Func _a_Reset_Socket_list ()
    GUICtrlSetData ($list, '')
    For $0 = 1 To $Max
        If $Sockets[$0][0] <> 0 Then 
        If $Sockets[$0][4] = 0 Then $00 = 'Normal User'
        If $Sockets[$0][4] = 1 Then $00 = 'Moderator'
        If $Sockets[$0][4] = 2 Then $00 = 'Administrator'
            GUICtrlSetData ($list, GUICtrlRead ($list) & @CRLF & '(' & _
                $Sockets[$0][1] & ') -- (' & _
                $Sockets[$0][2] & ') -- (' & _
                $Sockets[$0][3] & ') -- (' & _
                $00 & ')')
        EndIf
    Next
EndFunc

;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
Func _Accept_Incomming_Socket_Connection ()
    _Reset_Misc_Vars ()
    $0 = TCPAccept ($Main_Socket)
    If $0 = -1 Or $Sockets[0][0] = $Max Then
        _TCPSend ($0,'<FULL>')
        TCPCloseSocket ($0)
        _Reset_Misc_Vars ()
        Return
    EndIf
    For $00 = 1 To $Max
        If $Sockets[$00][0] = 0 Then
            $Sockets[$00][0] = $0
            _TCPSend ($0, '<[.]>')
            Do
                $Recv = _TCPRecv ($0)
                Sleep (50)
            Until $Recv <> ''
            $Recv = _StringBetween ($Recv, '(',')')
            $Blacklist = IniReadSection ($The_List, $Ini_2)
            For $000 = 1 To $Blacklist[0][0]
                If $Blacklist[$000][1] = $Recv[2] Then 
                    _Reset_Misc_Vars ()
                    Return
                EndIf
            Next
            For $000 = 1 To $Max
                If $Sockets[$000][0] <> 0 Then
                    If $Sockets[$000][1] = $Recv[0] Or $Sockets[$000][3] = $Recv[2] Then 
                        _TCPSend ($0, $M1 & '[-Server-] <--- Goodbye... --->' & $M2)
                        _Reset_Misc_Vars ()
                        Return
                    EndIf
                EndIf
            Next
            $Sockets[$00][1] = $Recv[0]
            $Sockets[$00][2] = $Recv[1]
            $Sockets[$00][3] = $Recv[2]
            $Sockets[$00][4] = 0
            $Sockets[0][0] += 1
            Sleep (100)           
            If StringInStr (IniRead ($The_List, $Ini_1, $Ini_3, ''),'(' & $Sockets[$00][3] & ')') Then 
                _TCPSend ($Sockets[$00][0],$M1 & '<Moderator>'  & $M2)
                $Sockets[$00][4] = 1
            EndIf
            If StringInStr (IniRead ($The_List, $Ini_1, $Ini_4, ''),'(' & $Sockets[$00][3] & ')') Then 
                _TCPSend ($Sockets[$00][0],$M1 & '<Administrator>'  & $M2)
                $Sockets[$00][4] = 2
            EndIf
            If $Sockets[0][0] = 1 Then $Last_Socket = 1
            Sleep (100)
            _BroadCast_To_All_Sockets ($M1 & '[-Server-] <--- New Client! --- ' &  $Sockets[$00][1] & ' --- >' & $M2)
            _a_Reset_Socket_list ()
            _Reset_Misc_Vars ()
            Return
        EndIf
    Next
EndFunc

;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------

;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
Func _BroadCast_To_All_Sockets ($i)
    For $0 = 1 To $Max
        If $Sockets[$0][0] <> 0 Then _TCPSend ($Sockets[$0][0], $i )
    Next
    _Reset_Misc_Vars ()
    Return
EndFunc

;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
Func _Disconnect ($0, $00)
    $Blacklist = IniReadSection ($The_List, $Ini_2)
   If $0 = 2 Then
       For $000 = 1 To $Blacklist[0][0]
            If $Blacklist[$000][1] = $00 Then
                IniWrite ($The_List, $Ini_2, $000, '')
                _Reset_Misc_Vars ()
                Return
            EndIf
        Next
        _Reset_Misc_Vars ()
        Return
    EndIf
    For $000 = 1 To $Max
        If $Sockets[$000][1] = $00 Then
            If $Sockets[$000][4] = 2 And $0 = 1 then Return
            _TCPSend ($Sockets[$000][0],$M1 & '[-Server-] <--- Goodbye... --->' & $M2)
            _BroadCast_To_All_Sockets ( $M1 & '[-Server-] <--- ' & $00 & ' Has left the Chat room... --->' & $M2)
            If $0 = 1 Then
                For $0000 = 1 To $Blacklist[0][0]
                    Select
                        Case $0 = 1 And $Blacklist[$0000][1] = ''
                            IniWrite ($The_List, $Ini_2, $0000, $Sockets[$000][3])
                            ExitLoop
                        Case $0 = 1 And $0000 = $Blacklist[0][0]
                            IniWrite ($The_List, $Ini_2, $Blacklist[0][0] + 1, $Sockets[$000][3])
                            ExitLoop
                    EndSelect
                Next
            EndIf
            $Sockets[$000][0] = 0
            $Sockets[$000][1] = 0
            $Sockets[$000][2] = 0
            $Sockets[$000][3] = 0
            $Sockets[$000][4] = 0
            $Sockets[0][0] -= 1
            _a_Reset_Socket_list ()
            _Reset_Misc_Vars ()
            If $Sockets[0][0] = 1 Then $Last_Socket = 1
            Return
        EndIf
    Next
    _Reset_Misc_Vars ()
    Return
EndFunc

;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
Func _Receive_Data_From_Sockets ()
    For $0 = 1 To $Max
        $Recv = _TCPRecv ($Sockets[$0][0])
        If $Recv <> '' Then 
            Select

;-----------------------------------------------------------------------------------------------------------------
;--------------------------Administrators Password----------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
                Case StringLeft ($Recv,StringLen ('<AP><')) = '<AP><' And StringRight ($Recv,StringLen ('></AP>')) = '></AP>'
                    Sleep (100)
                    $Recv = StringTrimLeft (StringTrimRight ($Recv,StringLen ('></AP>')),StringLen ('<AP><'))
                    If $Recv = IniRead ($The_List, $Ini_1, $Ini_6,'') Then
                        $Administrators_Read = IniRead ($The_List, $Ini_1, $Ini_4,'') & '(' & $Sockets[$0][3] & ')'
                        IniWrite ($The_List, $Ini_1, $Ini_4, $Administrators_Read)
                        _TCPSend ($Sockets[$0][0],$M1 & '<Administrator>' & $M2)
                    EndIf
                    Return

;-----------------------------------------------------------------------------------------------------------------
;-----------------------------Moderators Password-----------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
                Case StringLeft ($Recv,StringLen ('<MP><')) = '<MP><' And StringRight ($Recv,StringLen ('></MP>')) = '></MP>'
                    Sleep (100)
                    $Recv = StringTrimLeft (StringTrimRight ($Recv, StringLen ('></MP>')),StringLen ( '<MP><' ))
                    If $Recv = IniRead ($The_List, $Ini_1, $Ini_5,'') Then
                        $Moderators_Read = IniRead ($The_List, $Ini_1, $Ini_3,'') & '(' & $Sockets[$0][3] & ')'
                        IniWrite ($The_List, $Ini_1, $Ini_3, $Moderators_Read)
                        _TCPSend ($Sockets[$0][0],$M1 & '<Moderator>' & $M2)
                    EndIf
                    Return

;-----------------------------------------------------------------------------------------------------------------
;----------------------------------Personal Messaging-------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
                Case StringLeft ($Recv,StringLen ('<PM><')) = '<PM><' And StringRight ($Recv,StringLen ('></PM>')) = '></PM>'
                    Sleep (100)
                    $000 = $Recv
                    $Recv = _StringBetween ($Recv, '(',')')
                    For $00 = 1 To $Max
                        If $Recv[0] = $Sockets[$00][1] Then
                            _TCPSend ($Sockets[$00][0], $000)
                        EndIf
                    Next
                    Return

;-----------------------------------------------------------------------------------------------------------------
;--------------------------------Request Client Names-------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
                Case $Recv = '<RCN>'
                    Sleep (100)
                    $000 = ''
                    For $00 = 1 To $Max
                        If $Sockets[$00][0] <> 0 Then $000 &= $Sockets[$00][1] & '|'
                    Next
                    _TCPSend ($Sockets[$0][0], $000)
                    Return
                    
;-----------------------------------------------------------------------------------------------------------------
;--------------------------------Black List-------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
                Case $Recv = '<BL>'
                    Sleep (100)
                    $000 = '<BL>'
                    $Blacklist = IniReadSection ($The_List, $Ini_2)
                    For $00 = 1 To $Blacklist[0][0]
                        If $Blacklist[$00][1] <> '' Then $000 &= '(' & $Blacklist[$00][1] & ')' & @CRLF
                    Next
                    _TCPSend ($Sockets[$0][0], $000)
                    Return
                    
;-----------------------------------------------------------------------------------------------------------------
;--------------------------------Client's Changed Name------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
                Case StringLeft ($Recv, StringLen ('<CN><')) = '<CN><' And StringRight ($Recv, StringLen ('></CN>')) = '></CN>'
                    $Recv = StringTrimLeft ( StringTrimRight ($Recv, StringLen (')></CN>')),StringLen ('<CN><('))
                    _BroadCast_To_All_Sockets ($M1 & '[-Server-] <--- ' & $Sockets[$0][1] & ' Has changed their name to "' & $Recv & '" --->'  & $M2)
                    $Sockets[$0][1] = $Recv
                    _a_Reset_Socket_list ()
                    Return
                    
;-----------------------------------------------------------------------------------------------------------------
;----------------------------------Client DisConnection-----------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
                Case $Recv = '<DC>'
                    _Disconnect (0,$Sockets[$0][1])
                    _a_Reset_Socket_list ()
                    _Reset_Misc_Vars ()
                    Return
                    
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------Banning\UnBanning\Disconnecting-----------------------------------------
;-----------------------------------------------------------------------------------------------------------------
                Case StringLeft ($Recv,StringLen ('<DIS><(')) = '<DIS><(' And StringRight ($Recv,StringLen (')></DIS>')) = ')></DIS>'
                     $Recv = StringTrimLeft (StringTrimRight ($Recv, StringLen (')></DIS>')),StringLen ('<DIS><('))
                     For $00 = 1 To $Max
                         If $Sockets[$00][0] <> 0 Then
                            If $Recv = $Sockets[$00][1] Then
                                _Disconnect (0,$Sockets[$00][1])
                                _Reset_Misc_Vars ()
                                Return
                            EndIf
                        EndIf
                    Next
                    _Reset_Misc_Vars ()
                    Return
                     
                Case StringLeft ($Recv,StringLen ('<BAN><(')) = '<BAN><(' And StringRight ($Recv,StringLen (')></BAN>')) = ')></BAN>'
                    $Recv = StringTrimLeft (StringTrimRight ($Recv, StringLen (')></BAN>')),StringLen ('<BAN><('))
                    For $00 = 1 To $Max
                         If $Sockets[$00][0] <> 0 Then
                            If $Recv = $Sockets[$00][1] Then
                                _Disconnect (1,$Sockets[$00][1])
                                _Reset_Misc_Vars ()
                                Return
                            EndIf
                        EndIf
                    Next
                    _Reset_Misc_Vars ()
                    Return
                    
                Case StringLeft ($Recv,StringLen ('<UNBAN><(')) = '<UNBAN><(' And StringRight ($Recv,StringLen (')></UNBAN>')) = ')></UNBAN>' 
                    $Recv = StringTrimLeft (StringTrimRight ($Recv,StringLen (')></UNBAN>')),StringLen ('<UNBAN><('))
                    _Disconnect (2,$Recv)
                    _Reset_Misc_Vars ()
                    Return
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------Normal Message----------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
                Case StringLeft ($Recv, StringLen ($M1)) = $M1 And StringRight ($Recv, StringLen ($M2)) = $M2
                    _BroadCast_To_All_Sockets ($Recv)
                    Return
                    
;-----------------------------------------------------------------------------------------------------------------
;-------------------------------------------------Else------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
                Case Else
                    Return
            EndSelect
        EndIf
    Next
    _Reset_Misc_Vars ()
    Return
EndFunc

;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
Func _Reset_Misc_Vars ()
    $i = 0
    $0 = 0
    $00 = 0
    $000 = 0
    $0000 = 0
    $00000 = 0
    $000000 = 0
    Return
EndFunc

;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
Func _TCPRecv ($0)
    $Recv = TCPRecv ($0, 100000)
    $Recv = _StringEncrypt (0,$Recv,'91287369874125',3)
    Return $Recv
EndFunc

;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
Func _TCPSend ($0, $00)
    $00 = _StringEncrypt (1,$00,'91287369874125',3)
    TCPSend ($0, $00)
    Return
EndFunc

;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
Func _TCPShutdown ()
    If $Sockets[0][0] >= 1 Then
        _BroadCast_To_All_Sockets ($M1 & '[-Server-] <--- Will Commence Shutdown...in 5 Seconds... --->' & $M2)
        Sleep (1000)
        _BroadCast_To_All_Sockets ($M1 & '[-Server-] <--- Will Commence Shutdown...in 4 Seconds... --->' & $M2)
        Sleep (1000)
        _BroadCast_To_All_Sockets ($M1 & '[-Server-] <--- Will Commence Shutdown...in 3 Seconds... --->' & $M2)
        Sleep (1000)
        _BroadCast_To_All_Sockets ($M1 & '[-Server-] <--- Will Commence Shutdown...in 2 Seconds... --->' & $M2)
        Sleep (1000)
        _BroadCast_To_All_Sockets ($M1 & '[-Server-] <--- Will Commence Shutdown...in 1 Seconds... --->' & $M2)
        Sleep (1000)
        _BroadCast_To_All_Sockets ($M1 & '[-Server-] <--- Goodbye... --->' & $M2)
        Sleep (1000)
    EndIf
    For $0 = 1 To $Max
        If $Sockets[$0][0] <> 0 Then TCPCloseSocket ($Sockets[$0][0])
    Next
    TCPShutdown ()
    MsgBox (48, 'Shutdown', 'Server has been ShutDown....')
    Exit
EndFunc

=======================================Client=======================================

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=ICON.ico
#AutoIt3Wrapper_outfile=OECRC.exe
#AutoIt3Wrapper_Res_Comment=Connects to a main server and Chat.
#AutoIt3Wrapper_Res_Description=Chatroom Client
#AutoIt3Wrapper_Res_Fileversion=1.157
#AutoIt3Wrapper_Res_LegalCopyright=Cody Barrett
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUICONSTANTS.AU3>
#include <WINDOWSCONSTANTS.AU3>
#include <STATICCONSTANTS.AU3>
#include <EDITCONSTANTS.AU3>
#include <MISC.AU3>
#include <STRING.AU3>
#include <FILE.AU3>
#include <DATE.AU3>
#include <WINAPI.AU3>
#include <ARRAY.AU3>
#include <GUIEDIT.AU3>
#include <GUISTATUSBAR.AU3>
#include <GUICONSTANTSEX.AU3>
#include <SCROLLBARCONSTANTS.AU3>
$GUIStyle = BitOR($WS_POPUP, $WS_VISIBLE, $WS_SIZEBOX)
$GUIStyleEx = $WS_EX_WINDOWEDGE
$LabelStyle = BitOR ($SS_CENTER, $SS_CENTERIMAGE)
$EditStyle = BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_TABSTOP)
$EditStyleEx = BitOR($EditStyle, $ES_READONLY)
$Bk_C = 0xFFFFFF
$F_C = 0x0
$Sent = 0xEFDD01
$SentBk = 0x454545
$Moderator_Status = 0
$Administrator_Status = 0
$Send_Status = 0
$M1 = '<MSG><'
$M2 = '></MSG>'
$Font = 'Tahoma'
$Title = 'Client.NE.G'
TCPStartup ()


;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
$Settings = GUICreate ('Settings...', 350, 250)
GUICtrlCreateLabel ('DNS Domain :', 20, 20, 100, 20, $LabelStyle)
GUICtrlCreateLabel ('IP Address :', 20, 50, 100, 20, $LabelStyle)
GUICtrlCreateLabel ('Port Number:', 20, 80, 100, 20, $LabelStyle)
GUICtrlCreateLabel ('User Name  :', 20, 110, 100, 20, $LabelStyle)
GUICtrlCreateLabel ('If Using IP address... leave DNS Domain EMPTY!!!' & @CRLF & _
    'If Using DNS Domain... leave IP FIELDS EMPTY!!!', 0, 150, 350, 30,$SS_CENTER)
    
    
$DNS = GUICtrlCreateInput ('4A012ACE.HomeDNS.Org',130, 20, 200, 20,$LabelStyle)
Dim $ip_IN[4]
$ip_IN[0] = GUICtrlCreateInput ('', 130, 50, 45, 20,$LabelStyle)
$ip_IN[1] = GUICtrlCreateInput ('', 182, 50, 45, 20,$LabelStyle)
$ip_IN[2] = GUICtrlCreateInput ('', 235, 50, 45, 20,$LabelStyle)
$ip_IN[3] = GUICtrlCreateInput ('', 285, 50, 45, 20,$LabelStyle)
$ip = StringSplit (@IPAddress1, '.')
$00 = 0
For $0 = 0 To 3
    $00 += 1
    GUICtrlSetData ($ip_IN[$0], $ip[$00])
    GUICtrlSetLimit ($ip_IN[$0], 3, 1)
Next
$Port = GUICtrlCreateInput (Random (1, 60000, 1), 130, 80, 200, 20, $LabelStyle)
$Username = GUICtrlCreateInput (_Random (Random (1, 26,1)), 130, 110, 200, 20, $LabelStyle)
$Connect_Button = GUICtrlCreateLabel ('Connect', 20, 200, 150, 30, $LabelStyle)
    GUICtrlSetBkColor (-1,$F_C )
    GUICtrlSetFont (-1, 15, 600, '', $Font)
    GUICtrlSetColor (-1, $Bk_C)
    GUICtrlSetCursor (-1, 0)
$Cancel_Button = GUICtrlCreateLabel ('Cancel', 180, 200, 150, 30, $LabelStyle)
    GUICtrlSetBkColor (-1,$F_C )
    GUICtrlSetFont (-1, 15, 600, '', $Font)
    GUICtrlSetColor (-1, $Bk_C)
    GUICtrlSetCursor (-1, 0)
GUISetState ()
While 1
    $m = GUIGetMsg ()
    Select
        Case $m = $Connect_Button
            GUICtrlSetColor ($Connect_Button, $Sent)
            GUICtrlSetBkColor ($Connect_Button, $SentBk)
            $ip = GUICtrlRead ($ip_IN[0]) & '.' &  GUICtrlRead ($ip_IN[1]) & '.' &  GUICtrlRead ($ip_IN[2]) & '.' &  GUICtrlRead ($ip_IN[3])
            If GUICtrlRead ($DNS) = '' And  $ip = '...' Or GUICtrlRead ($DNS) <> '' And  $ip <> '...' Then 
                MsgBox (48, 'ERROR', 'Please fill in Either DNS or IP fields!!')
            Else
                If $ip = '...' Then $ip = TCPNameToIP (GUICtrlRead ($DNS))
                $port = GUICtrlRead ($port)
                $Name = GUICtrlRead ($Username)
                GUIDelete ($Settings)
                ExitLoop
            EndIf
            Sleep (100)
            GUICtrlSetColor ($Connect_Button, $Bk_C)
            GUICtrlSetBkColor ($Connect_Button, $F_C)

        Case $m = $Cancel_Button Or $m = $GUI_EVENT_CLOSE
            GUICtrlSetColor ($Cancel_Button, $Sent)
            GUICtrlSetBkColor ($Cancel_Button, $SentBk)
            Sleep (100)
            GUICtrlSetColor ($Cancel_Button, $Bk_C)
            GUICtrlSetBkColor ($Cancel_Button, $F_C)
            TCPShutdown ()
            Exit
    EndSelect
WEnd

;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------

Opt ('GUIoneventmode', 1)
ProgressOn ('Connecting...', 'Connecting to Server...')
Do 
    $Socket = TCPConnect ($ip, $port)
    If $Socket = -1 Then TCPCloseSocket ($Socket)
    Sleep (50)
Until $Socket <> -1
ProgressSet (33, 'Connected... Waiting For Response...')
Do
    $Recv = _TCPRecv ()
    Sleep (50)
    If $Recv = '<FULL>' Then 
        ProgressOff ()
        MsgBox (48, 'Server...', 'Server Is Full Try Again Later...')
        _Exit ()
    EndIf
Until $Recv = '<[.]>'
$Recv = ''
ProgressSet (66, 'Sending Data...')
_TCPSend ('(' & $Name & ')(' & $ip & ')(' & @UserName & ')')
Sleep (200)
ProgressSet (100,'Complete')
ProgressOff ()




;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------

$GUI = GUICreate ($Title, 600, 300, -1, -1,$GUIStyle ,$GUIStyleEx)
GUISetBkColor ($Bk_C, $GUI)
$Title = 'Client.NE.G' & ' --- ' & $ip & ' --- ' & $port
$lTitleBar = GUICtrlCreateLabel ($Title, 20, 0, 580, 20,$LabelStyle )
GUICtrlSetOnEvent (-1, '_Win_Move')
    GUICtrlSetBkColor (-1,$Bk_C )
    GUICtrlSetFont (-1, 10, 600, '', $Font)
    GUICtrlSetColor (-1, $F_C)
$lExit = GUICtrlCreateLabel ('X', 1, 1, 18, 18,$LabelStyle )
GUICtrlSetOnEvent (-1, '_Exit')
    GUICtrlSetBkColor (-1,$Bk_C )
    GUICtrlSetFont (-1, 15, 600, '', $Font)
    GUICtrlSetColor (-1, $F_C)
    GUICtrlSetCursor (-1, 0)
$Console = GUICtrlCreateEdit ('', 10, 30,440,180, $EditStyleEx)
GUICtrlSetFont (-1, 10, 800, '', $Font)
$Send = GUICtrlCreateEdit ('', 10, 220, 360, 70, $EditStyle)
GUICtrlSetFont (-1, 10, 800, '', $Font)
$Send_Button = GUICtrlCreateLabel ('Send',380, 220, 70, 70, $LabelStyle)
GUICtrlSetOnEvent (-1, '_Send')
    GUICtrlSetBkColor (-1,$F_C )
    GUICtrlSetFont (-1, 15, 600, '', $Font)
    GUICtrlSetColor (-1, $Bk_C)
    GUICtrlSetCursor (-1, 0)
    
$Admin_Input = GUICtrlCreateInput ('Admins Pass',460,30,100,20)
$A_P_Button = GUICtrlCreateLabel ('Ok',560, 30, 30, 20, $LabelStyle)
GUICtrlSetOnEvent (-1,'_Admin_Pass')
    GUICtrlSetBkColor (-1,$F_C )
    GUICtrlSetColor (-1, $Bk_C)
    GUICtrlSetCursor (-1, 0)
$Mod_Input = GUICtrlCreateInput ('Mods Pass',460,50,100,20)
$M_P_Button = GUICtrlCreateLabel ('Ok',560, 50, 30, 20, $LabelStyle)
GUICtrlSetOnEvent (-1,'_Mod_Pass')
    GUICtrlSetBkColor (-1,$F_C )
    GUICtrlSetColor (-1, $Bk_C)
    GUICtrlSetCursor (-1, 0)
$Name_Input = GUICtrlCreateInput ($Name,460,70,100,20)
$C_U_Button = GUICtrlCreateLabel ('Ok',560, 70, 30, 20, $LabelStyle)
GUICtrlSetOnEvent (-1,'_Change_Name')
    GUICtrlSetBkColor (-1,$F_C )
    GUICtrlSetColor (-1, $Bk_C)
    GUICtrlSetCursor (-1, 0)



$Client_List = GUICtrlCreateCombo ('None',460,90,100,20)
$C_L_Button = GUICtrlCreateLabel ('UP',560, 90, 30, 21, $LabelStyle)
GUICtrlSetOnEvent (-1,'_Up_Date')
    GUICtrlSetBkColor (-1,$F_C )
    GUICtrlSetColor (-1, $Bk_C)
    GUICtrlSetCursor (-1, 0)
$P_M_Button = GUICtrlCreateLabel ('P.M Selected Client',460, 120, 130, 20, $LabelStyle)
GUICtrlSetOnEvent (-1, '_P_M_Client')
    GUICtrlSetBkColor (-1,$F_C )
    GUICtrlSetColor (-1, $Bk_C)
    GUICtrlSetCursor (-1, 0)
$D_C_Button = GUICtrlCreateLabel ('D.C Selected Client',460, 145, 130, 20, $LabelStyle)
GUICtrlSetOnEvent (-1, '_D_C_Client')
    GUICtrlSetBkColor (-1,$F_C )
    GUICtrlSetColor (-1, $Bk_C)
    GUICtrlSetCursor (-1, 0)
    GUICtrlSetState (-1, $GUI_DISABLE)
$BAN_Button = GUICtrlCreateLabel ('BAN Selected Client',460, 170, 130, 20, $LabelStyle)
GUICtrlSetOnEvent (-1, '_BAN_Client')
    GUICtrlSetBkColor (-1,$F_C )
    GUICtrlSetColor (-1, $Bk_C)
    GUICtrlSetCursor (-1, 0)
    GUICtrlSetState (-1, $GUI_DISABLE)
$UN_BAN_Button = GUICtrlCreateLabel ('Un BAN Selected Client',460, 195, 130, 20, $LabelStyle)
GUICtrlSetOnEvent (-1, '_UN_BAN_Client')
    GUICtrlSetBkColor (-1,$F_C )
    GUICtrlSetColor (-1, $Bk_C)
    GUICtrlSetCursor (-1, 0)
    GUICtrlSetState (-1, $GUI_DISABLE)
$Black_List_Button = GUICtrlCreateLabel ('Black List',460, 220, 130, 20, $LabelStyle)
GUICtrlSetOnEvent (-1, '_Black_List')
    GUICtrlSetBkColor (-1,$F_C )
    GUICtrlSetColor (-1, $Bk_C)
    GUICtrlSetCursor (-1, 0)
    GUICtrlSetState (-1, $GUI_DISABLE)



GUISetOnEvent ($GUI_EVENT_CLOSE, '_Exit', $GUI)
GUISetState ()

;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
While 1
    $R_C = GUICtrlRead ($Console)
    _GUICtrlEdit_Scroll($Console, $SB_SCROLLCARET )
    If _IsPressed ('0D') And Not _IsPressed ('10') And ControlGetFocus ($GUI, '') = 'Edit2' Then _Send ()
    If _IsPressed ('0D') And _IsPressed ('10') And ControlGetFocus ($GUI, '') = 'Edit2' And $Send_Status < 600 Then 
        GUICtrlSetData ($Send ,GUICtrlRead ($Send) & @CRLF)
        $Send_Status += 50
    EndIf
    If $Send_Status >= 1 Then $Send_Status -= 1
    If $Moderator_Status = 1 Or $Administrator_Status = 1 Then
        If $Moderator_Status = 1 Then $Moderator_Status = 0
        If $Administrator_Status = 1 Then $Administrator_Status = 0
        GUICtrlSetState ($D_C_Button ,$GUI_ENABLE)
        GUICtrlSetState ($BAN_Button ,$GUI_ENABLE)
        GUICtrlSetState ($UN_BAN_Button ,$GUI_ENABLE)
        GUICtrlSetState ($Black_List_Button ,$GUI_ENABLE)
    EndIf
    _Recieve_From_Server ()
    Sleep (50)
WEnd
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
Func _Change_Name ()
    GUICtrlSetColor ($C_U_Button, $Sent)
    GUICtrlSetBkColor ($C_U_Button, $SentBk)
    _TCPSend ('<CN><(' & GUICtrlRead ($Name_Input) & ')></CN>')
    $Name = GUICtrlRead ($Name_Input)
    Sleep (100)
    GUICtrlSetColor ($C_U_Button, $Bk_C)
    GUICtrlSetBkColor ($C_U_Button, $F_C)
EndFunc
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
Func _P_M_Client ()
    GUICtrlSetColor ($P_M_Button, $Sent)
    GUICtrlSetBkColor ($P_M_Button, $SentBk)
    GUICtrlSetData ($Send, 'PM:')
    Sleep (100)
    GUICtrlSetColor ($P_M_Button, $Bk_C)
    GUICtrlSetBkColor ($P_M_Button, $F_C)
EndFunc
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
Func _D_C_Client ()
    GUICtrlSetColor ($D_C_Button, $Sent)
    GUICtrlSetBkColor ($D_C_Button, $SentBk)
    GUICtrlSetData ($Send, 'DC:')
    Sleep (100)
    GUICtrlSetColor ($D_C_Button, $Bk_C)
    GUICtrlSetBkColor ($D_C_Button, $F_C)
EndFunc
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
Func _BAN_Client ()
    GUICtrlSetColor ($BAN_Button, $Sent)
    GUICtrlSetBkColor ($BAN_Button, $SentBk)
    GUICtrlSetData ($Send, 'BAN:')
    Sleep (100)
    GUICtrlSetColor ($BAN_Button, $Bk_C)
    GUICtrlSetBkColor ($BAN_Button, $F_C)
EndFunc
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
Func _UN_BAN_Client ()
    GUICtrlSetColor ($UN_BAN_Button, $Sent)
    GUICtrlSetBkColor ($UN_BAN_Button, $SentBk)
    GUICtrlSetData ($Send, 'UNBAN: Offline Client Username')
    Sleep (100)
    GUICtrlSetColor ($UN_BAN_Button, $Bk_C)
    GUICtrlSetBkColor ($UN_BAN_Button, $F_C)
EndFunc
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
Func _Black_List ()
    GUICtrlSetColor ($Black_List_Button, $Sent)
    GUICtrlSetBkColor ($Black_List_Button, $SentBk)
    _TCPSend ('<BL>')
    Sleep (100)
    GUICtrlSetColor ($Black_List_Button, $Bk_C)
    GUICtrlSetBkColor ($Black_List_Button, $F_C)
EndFunc
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
Func _Mod_Pass ()
    GUICtrlSetColor ($M_P_Button, $Sent)
    GUICtrlSetBkColor ($M_P_Button, $SentBk)
    _TCPSend ('<MP><(' & GUICtrlRead ($Mod_Input) & ')></MP>')
    Sleep (100)
    GUICtrlSetColor ($M_P_Button, $Bk_C)
    GUICtrlSetBkColor ($M_P_Button, $F_C)
    Return
EndFunc
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
Func _Admin_Pass ()
    GUICtrlSetColor ($A_P_Button, $Sent)
    GUICtrlSetBkColor ($A_P_Button, $SentBk)
    _TCPSend ('<AP><(' & GUICtrlRead ($Admin_Input) & ')></AP>')
    Sleep (100)
    GUICtrlSetColor ($A_P_Button, $Bk_C)
    GUICtrlSetBkColor ($A_P_Button, $F_C)
    Return
EndFunc
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
Func _Up_Date ()
    GUICtrlSetColor ($C_L_Button, $Sent)
    GUICtrlSetBkColor ($C_L_Button, $SentBk)
    _TCPSend ('<RCN>')
    Sleep (100)
    GUICtrlSetColor ($C_L_Button, $Bk_C)
    GUICtrlSetBkColor ($C_L_Button, $F_C)
    Do
        $Recv = _TCPRecv ()
        Sleep (50)
    Until $Recv <> ''
    GUICtrlSetData ($Client_List, '')
    GUICtrlSetData ($Client_List, $Recv)
    Return
EndFunc
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
Func _Win_Move ()
    $MouseXY = MouseGetPos ()
    $WinXY = WinGetPos ($GUI)
    While _IsPressed ('01')
        WinMove ($GUI, '',MouseGetPos (0) - ($MouseXY[0] - $WinXY[0]),MouseGetPos (1) - ($MouseXY[1] - $WinXY[1]))
        Sleep (10)
    WEnd
    Return
EndFunc
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
Func _Send ()
    If GUICtrlRead ($Send) = '' Or StringIsSpace (GUICtrlRead ($Send)) = 1 Or $Send_Status >= 600 Then Return
    GUICtrlSetColor ($Send_Button, $Sent)
    GUICtrlSetBkColor ($Send_Button, $SentBk)
    $0 = GUICtrlRead ($Send)
    Select
        Case StringLeft ($0, StringLen ('PM:')) = 'PM:' And GUICtrlRead ($Client_List) <> 'None' _
                And GUICtrlRead ($Client_List) <> $Name And StringIsSpace (StringTrimLeft (GUICtrlRead ($Send), StringLen ('PM:'))) = 0
            $0 = '<PM><(' & GUICtrlRead ($Client_List) & ')(' & StringTrimLeft (GUICtrlRead ($Send), 3) & ')(' & $Name & ')></PM>'
            _TCPSend ($0)
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
        Case StringLeft ($0, StringLen ('DC:')) = 'DC:' And GUICtrlRead ($Client_List) <> 'None' And GUICtrlRead ($Client_List) <> $Name
            $0 = '<DIS><(' & GUICtrlRead ($Client_List) & ')></DIS>'
            _TCPSend ($0)
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
        Case StringLeft ($0, StringLen ('BAN:')) = 'BAN:' And GUICtrlRead ($Client_List) <> 'None' And GUICtrlRead ($Client_List) <> $Name
            $0 = '<BAN><(' & GUICtrlRead ($Client_List) & ')></BAN>'
            _TCPSend ($0)
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
        Case StringLeft ($0, StringLen ('UNBAN:')) = 'UNBAN:'
            $0 = '<UNBAN><(' & StringMid (GUICtrlRead ($Send),StringLen ('UNBAN:') + 1) & ')></UNBAN>'
            _TCPSend ($0)
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
        Case Else
            $0 = $M1 & $Name & ' --- ' & $0 & $M2
            _TCPSend ($0)
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
    EndSelect
    GUICtrlSetData ($Send, '')
    Sleep (100)
    GUICtrlSetColor ($Send_Button, $Bk_C)
    GUICtrlSetBkColor ($Send_Button, $F_C)
    $Send_Status += 200
    Return
EndFunc
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
Func _Recieve_From_Server ()
    $Recv = _TCPRecv ()
    Select
        Case $Recv = ''
            Return
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
        Case StringLeft ($Recv, StringLen ('<PM><')) = '<PM><' And StringRight ($Recv, StringLen ('></PM>')) = '></PM>'
            $Recv = StringTrimLeft (StringTrimRight ($Recv, StringLen ('></PM>')), StringLen ('<PM><'))
            $Recv = _StringBetween ($Recv, '(',')')
            If $Recv[0] <> $Name Then Return
            GUICtrlSetData ($Console, $R_C & @CRLF & 'PM From: ' & $Recv[2] & @CRLF & @TAB & $Recv[1] & @CRLF)
            Return
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
        Case StringLeft ($Recv, StringLen ($M1)) = $M1 And StringRight ($Recv, StringLen ($M2)) = $M2
            Select
                Case $Recv = $M1 & '<Administrator>' & $M2
                    $Administrator_Status = 1
                    Return
                Case $Recv = $M1 & '<Moderator>' & $M2
                    $Moderator_Status = 1
                    Return
                Case $Recv = $M1 & '[-Server-] <--- Goodbye... --->' & $M2
                    TCPCloseSocket ($Socket)
                    TCPShutdown ()
                    Exit
 
            EndSelect
            GUICtrlSetData ($Console, $R_C & @CRLF & StringTrimLeft (StringTrimRight ($Recv,StringLen ($M2)), StringLen ($M1)) & @CRLF)
            Return  
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
        Case StringLeft ($Recv,StringLen ('<BL>')) = '<BL>'
            $Recv = StringTrimLeft ($Recv, StringLen ('<BL>'))
            GUICtrlSetData ($Console, $R_C & @CRLF & $Recv)
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
        Case Else
            Return
    EndSelect
    Return
EndFunc
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
Func _Random ($0)
    $Random = ''
    For $i = 0 To $0 - 1
        $Random &= _Random_Chr ()
    Next
    If $Random = ' ' Then $Random = _Random ($0)
    Return $Random 
EndFunc
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
Func _Random_Chr ()
    Dim $0[3]
    $0[0] = Chr (32)
    $0[1] = Chr (Random (65, 90, 1))
    $0[2] = Chr (Random (97, 122, 1))
    Return $0[Random (0, 2,1)]
EndFunc
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
Func _TCPRecv ()
    $Recv = TCPRecv ($Socket,1000000)
    $Recv = _StringEncrypt (0,$Recv, '91287369874125',3)
    Return $Recv
EndFunc

;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
Func _TCPSend ($0)
    $0 = _StringEncrypt (1,$0,'91287369874125',3)
    TCPSend ($Socket, $0)
    Return
EndFunc
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
Func _Exit ()
    _TCPSend ('<DC>')
    Sleep (500)
    TCPCloseSocket ($Socket)
    TCPShutdown ()
    Exit
EndFunc
Link to comment
Share on other sites

  • 3 weeks later...

works fine for me.... what are you doing to make it close automatically?

Link to comment
Share on other sites

like i said.. its working fine on mine...and my script testers computers.... so it must be something your doing.. or not doing

it connecting? port correct? ip correct?

is your @username on the blacklist of the server?

does the main Client GUI start up?

Nothing, i just load up the CLient ANfd server on my PC and when the client loads, bam in a flash its gone, with no Errors,just an exit code

just doesnt replicate your problems... there is too little information here to help with whats happening
Link to comment
Share on other sites

  • 3 months later...

Same thing is happening to me. I don't know what to tell you but I am using windows 7 64 bit. I have tried running in 32 bit but didnt help. I also tried running them as admin and didn't help. when its ran it gives no error codes or anything even when run in sciti it just says script finished or whatever it is. I do see the gui flash and go away. I did make sure port numbers are correct. Also just to let you know its being tested on one computer I don't know if its not suppose to have the client and server on same computer but that might be the reason.

Link to comment
Share on other sites

  • 4 weeks later...
  • 2 weeks later...

wow i haven't been on here in a while...

hmm

alright, uh:

(a) it should work on one computer.. and separated computers.

(:D having Ports different would only freeze the program but it wouldn't close the GUI.

© the server auto disconnects clients who are on the blacklist

-- could you have banned yourself? or did it close even before you did anything?

(d) the no error means that it is a CONTROLLED closing of the program.. gotta find out what is triggering the abrupt exit.

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...