Jump to content

Send Chat To server?


Recommended Posts

hello, i was wondering if it was possible to send a text from a GUI to a game server(through TCP)

i know nothing about TCP so i was wondering if someone was able to start me up with a script?

Thanks.

Depends on the game almost every game has a differend way to connect.

Lots of new games need cd keys to be able to logon also for security.

Link to comment
Share on other sites

It is more then possible. You just need too retreive the data from the GUI and send too the server. Have it store it. ETC. I already have a project dealing with this :P. Just read up the TCP Functionality and check my posts for examples...

AutoIt Smith

Link to comment
Share on other sites

It is more then possible. You just need too retreive the data from the GUI and send too the server. Have it store it. ETC. I already have a project dealing with this :P. Just read up the TCP Functionality and check my posts for examples...

AutoIt Smith

except for te post where you say you cannot send files over tcp functions over te internet.

donot read those all the scary capslock text in there.

For te record it is possible I made a script wich does work (unlike the really slow half working one posted there in the ideas section).

So you could also send binary data to chat (althougt chat almost always is text data)

Link to comment
Share on other sites

That is a bit flawed. Try this too build from:

Global Const $Port = 50911
Global $MaxConc = 100
Global $MainSocket = TCPStartServer($Port, $MaxConc)
If @error <> 0 Then Exit MsgBox(16, "Error", "Server unable to initialize.")
Global Const $MaxLength = 512
Global $ConnectedSocket[$MaxConc]
Global $CurrentSocket = 0
Local $Track = 0
Global Const $MaxConnection = ($MaxConc - 1)
For $Track = 0 To $MaxConnection Step 1
    $ConnectedSocket[$Track] = -1
Next
While 1
    $ConnectedSocket[$CurrentSocket] = TCPAccept($MainSocket)
    If $ConnectedSocket[$CurrentSocket] <> - 1 Then
        $CurrentSocket = SocketSearch()
    EndIf
    $Track = 0
    For $Track = 0 To $MaxConnection Step 1
        If $ConnectedSocket[$Track] <> - 1 Then
            $Data = TCPRecv($ConnectedSocket[$Track], $MaxLength)
            If $Data = "~bye" Then
                TCPCloseSocket($ConnectedSocket[$Track])
                $ConnectedSocket[$Track] = -1
                $CurrentSocket = SocketSearch()
            ElseIf $Data <> "" Then
                TCPSendMessageAll($MaxConnection, $Data)
            EndIf
        EndIf
    Next
WEnd
Func TCPSendMessageAll($ConnectionLimit, $Data)
    Local $Track = 0
    For $Track = 0 To $ConnectionLimit Step 1
        If $ConnectedSocket[$Track] <> - 1 Then TCPSend($ConnectedSocket[$Track], $Data)
    Next
EndFunc  ;==>TCPSendMessageAll
Func TCPStartServer($Port, $MaxConnect = 1)
    Local $Socket
    $Socket = TCPStartup()
    Select
        Case $Socket = 0
            SetError(@error)
            Return -1
    EndSelect
    $Socket = TCPListen(@IPAddress1, $Port, $MaxConnect)
    Select
        Case $Socket = -1
            SetError(@error)
            Return 0
    EndSelect
    SetError(0)
    Return $Socket
EndFunc  ;==>TCPStartServer
Func SocketSearch()
    Local $Track = 0
    For $Track = 0 To $MaxConnection Step 1
        If $ConnectedSocket[$Track] = -1 Then
            Return $Track
        Else
        ; Socket In Use
        EndIf
    Next
EndFunc  ;==>SocketSearch
Link to comment
Share on other sites

MySpacely, if you do not understand something, ask something about it. That server is an EXAMPLE structure which may need too be added to according too what people want. I gave him a base, which is what he needed. Also, you can always figure something out, without knowing the game. I don't know your real name, but I can tell you aren't very logical......

Link to comment
Share on other sites

  • 3 weeks later...

That is a bit flawed. Try this too build from:

Global Const $Port = 50911
Global $MaxConc = 100
Global $MainSocket = TCPStartServer($Port, $MaxConc)
If @error <> 0 Then Exit MsgBox(16, "Error", "Server unable to initialize.")
Global Const $MaxLength = 512
Global $ConnectedSocket[$MaxConc]
Global $CurrentSocket = 0
Local $Track = 0
Global Const $MaxConnection = ($MaxConc - 1)
For $Track = 0 To $MaxConnection Step 1
    $ConnectedSocket[$Track] = -1
Next
While 1
    $ConnectedSocket[$CurrentSocket] = TCPAccept($MainSocket)
    If $ConnectedSocket[$CurrentSocket] <> - 1 Then
        $CurrentSocket = SocketSearch()
    EndIf
    $Track = 0
    For $Track = 0 To $MaxConnection Step 1
        If $ConnectedSocket[$Track] <> - 1 Then
            $Data = TCPRecv($ConnectedSocket[$Track], $MaxLength)
            If $Data = "~bye" Then
                TCPCloseSocket($ConnectedSocket[$Track])
                $ConnectedSocket[$Track] = -1
                $CurrentSocket = SocketSearch()
            ElseIf $Data <> "" Then
                TCPSendMessageAll($MaxConnection, $Data)
            EndIf
        EndIf
    Next
WEnd
Func TCPSendMessageAll($ConnectionLimit, $Data)
    Local $Track = 0
    For $Track = 0 To $ConnectionLimit Step 1
        If $ConnectedSocket[$Track] <> - 1 Then TCPSend($ConnectedSocket[$Track], $Data)
    Next
EndFunc ;==>TCPSendMessageAll
Func TCPStartServer($Port, $MaxConnect = 1)
    Local $Socket
    $Socket = TCPStartup()
    Select
        Case $Socket = 0
            SetError(@error)
            Return -1
    EndSelect
    $Socket = TCPListen(@IPAddress1, $Port, $MaxConnect)
    Select
        Case $Socket = -1
            SetError(@error)
            Return 0
    EndSelect
    SetError(0)
    Return $Socket
EndFunc ;==>TCPStartServer
Func SocketSearch()
    Local $Track = 0
    For $Track = 0 To $MaxConnection Step 1
        If $ConnectedSocket[$Track] = -1 Then
            Return $Track
        Else
    ; Socket In Use
        EndIf
    Next
EndFunc ;==>SocketSearch
Pardon my noobishness, but where did you find the documentation for these functions (like, TCPStartServer and all). I'm trying to create my own chat, but I would like to read the documentation first.

Please point me in the right direction thanks.

---"Educate the Mind, Make Savage the Body" -Mao Tse Tung

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