Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Guild Wars
You last visited: Today at 11:14

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Project]TA-Spike-Team-Script

Discussion on [Project]TA-Spike-Team-Script within the Guild Wars forum part of the MMORPGs category.

Reply
 
Old 04/17/2008, 16:29   #16
 
MasteR GunneR's Avatar
 
elite*gold: 0
Join Date: Dec 2007
Posts: 387
Received Thanks: 188
5903 würde ich vorschlagen.
Vielleicht hilft dir das hier weiter (das gute alte TicTacTo):

Server
Code:
#include <GUIConstants.au3>
#include <ARRAY.AU3>
#include <GUIEdit.au3>
#include <Date.au3>

Global Const $Port = 5903
Global $MaxConc = 3
Global Const $MaxLength = 512
Global $ConnectedSocket[$MaxConc]
Global $CurrentSocket = 0
Global $Connection = 0
Local $Track = 0
Global Const $MaxConnection = ($MaxConc - 1)

For $Track = 0 To $MaxConnection Step 1
    $ConnectedSocket[$Track] = -1
Next

$Form1 = GUICreate("Tic Tac Toe (Server)", 602, 439, 193, 115)
$Edit = GUICtrlCreateEdit("", 8, 8, 585, 393, BitOR($ES_READONLY, $ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL))
$Input1 = GUICtrlCreateInput("", 8, 408, 505, 21)
$Button1 = GUICtrlCreateButton("Send All", 520, 408, 75, 23, 0)
GUISetState(@SW_SHOW)

Global $MainSocket = TCPStartServer($Port, $MaxConc)
If @error <> 0 Then
    Console("Server unable to initialize.", "")
Else
    Console("Server initialized.", "")
EndIf

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $Button1
            $Input = GUICtrlRead($Input1)
            TCPSendMessageAll(1, $Input)
            GUICtrlSetData($Input1, "")
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    $ConnectedSocket[$CurrentSocket] = TCPAccept($MainSocket)
    If $ConnectedSocket[$CurrentSocket] <> -1 Then
        $CurrentSocket = SocketSearch()
    EndIf
    If $Connection = 2 Then
        TCPSendMessageAll(1, "!Ready")
        Sleep(500)
        $Player1 = Random(1, 2, 1)
        If $Player1 = 1 Then
            $Player1 = "!Player-1"
            $Player2 = "!Player-2"
        ElseIf $Player1 = 2 Then
            $Player1 = "!Player-2"
            $Player2 = "!Player-1"
        EndIf
        TCPSend($ConnectedSocket[0], $Player1)
        Console($Player1 & " send " & $ConnectedSocket[0], $ConnectedSocket[0])
        TCPSend($ConnectedSocket[1], $Player2)
        Console($Player2 & " send " & $ConnectedSocket[1], $ConnectedSocket[1])
        $Connection = 3
    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])
                Console($ConnectedSocket[$Track] & " disconnected.", $ConnectedSocket[$Track])
                $ConnectedSocket[$Track] = -1
                $CurrentSocket = SocketSearch()
            ElseIf $Data = "!Connected" Then
                TCPSend($ConnectedSocket[$Track], "!Connected")
                Console($ConnectedSocket[$Track] & " connected.", $ConnectedSocket[$Track])
                $Connection = $Connection + 1
            ElseIf $Data <> "" Then
                TCPSendMessageAll(1, $Data)
            EndIf
        EndIf
    Next
WEnd

Func Console($Dataa, $Con)
    $Editt = GUICtrlRead($Edit)
    If $Editt = "" Then
        GUICtrlSetData($Edit, _NowTime(5) & " - " & GetIP($Con) & " - " & $Dataa)
    Else
        GUICtrlSetData($Edit, $Editt & @CRLF & _NowTime(5) & " - " & GetIP($Con) & " - " & $Dataa)
    EndIf
    _GUICtrlEdit_LineScroll($Edit, 0, _GUICtrlEdit_GetLineCount($Edit))
EndFunc   ;==>Console

Func TCPSendMessageAll($ConnectionLimit, $Data)
    Local $Track = 0
    For $Track = 0 To $ConnectionLimit
        TCPSend($ConnectedSocket[$Track], $Data)
        If StringInStr($Data, "!Button") Then
            $Data2 = StringSplit($Data, "-")
            Console($Data & " ( Player : " & $Data2[2] & " Row : " & $Data2[3] & " Column : " & $Data2[4] & " ) send " & $ConnectedSocket[$Track], $ConnectedSocket[$Track])
        ElseIf $Data <> "" Then
            Console($Data & " send " & $ConnectedSocket[$Track], $ConnectedSocket[$Track])
        EndIf
    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
            ;
        EndIf
    Next
EndFunc   ;==>SocketSearch

Func GetIP($Socket)
    Local $SocketAddress
    $SocketAddress = DllStructCreate("short;ushort;uint;char[8]")
    $IP = DllCall("Ws2_32.dll", "int", "getpeername", "int", $Socket, "ptr", DllStructGetPtr($SocketAddress), "int*", DllStructGetSize($SocketAddress))
    If Not @error And $IP[0] = 0 Then
        $IP = DllCall("Ws2_32.dll", "str", "inet_ntoa", "int", DllStructGetData($SocketAddress, 3))
        If Not @error Then $IP = $IP[0]
    Else
        $IP = @IPAddress1
    EndIf
    $SocketAddress = 0
    Return $IP
EndFunc  ;==>SocketToIp

Func OnAutoItExit()
    TCPSendMessageAll(1, "!Bye")
    Sleep(1000)
    TCPShutdown()
EndFunc   ;==>OnAutoItExit
Client
Code:
#include <GUIConstants.au3>
#include <ARRAY.AU3>

Global $MainSocket, $Server, $Port, $Nick, $Nick2, $Turn, $Shape, $Shape2, $Winner, $Moves, $Player, $Me, $Opponent
Global $Point1 = 0
Global $Point2 = 0
Global $Games = 0
Global $Box[4][4]
Global $Button[4][4]
Global $Checkwin[9]
Global $Connected = 0
Local $MaxLength = 512

$Form1 = GUICreate("Tic Tac Toe", 217, 359, 193, 115)
$Group1 = GUICtrlCreateGroup("Login", 16, 224, 185, 121)
$Input1 = GUICtrlCreateInput(@IPAddress1, 72, 244, 105, 21)
$Input2 = GUICtrlCreateInput(5903, 72, 276, 105, 21)
$Label2 = GUICtrlCreateLabel("IP :", 32, 252, 20, 17)
$Label3 = GUICtrlCreateLabel("Port :", 32, 284, 29, 17)
$Connect = GUICtrlCreateButton("Connect !", 32, 308, 147, 25, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button[1][1] = GUICtrlCreateButton("", 36, 17, 49, 49, 0)
GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif")
$Button[1][2] = GUICtrlCreateButton("", 84, 17, 49, 49, 0)
GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif")
$Button[1][3] = GUICtrlCreateButton("", 132, 17, 49, 49, 0)
GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif")
$Button[2][1] = GUICtrlCreateButton("", 36, 65, 49, 49, 0)
GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif")
$Button[2][2] = GUICtrlCreateButton("", 84, 65, 49, 49, 0)
GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif")
$Button[2][3] = GUICtrlCreateButton("", 132, 65, 49, 49, 0)
GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif")
$Button[3][1] = GUICtrlCreateButton("", 36, 113, 49, 49, 0)
GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif")
$Button[3][2] = GUICtrlCreateButton("", 84, 113, 49, 49, 0)
GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif")
$Button[3][3] = GUICtrlCreateButton("", 132, 113, 49, 49, 0)
GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif")
$Label4 = GUICtrlCreateLabel("Status :", 24, 176, 192, 17)
$Label5 = GUICtrlCreateLabel("Games : 0  You : 0  Opponent : 0", 24, 200, 192, 17)
GUISetState()

For $i = 1 To 3
    For $j = 1 To 3
        $Box[$i][$j] = 0
    Next
Next

While 1
    Checktcp()
    $msg = GUIGetMsg()
    Switch $msg
        Case $Connect
            TCPStartup()
            Check()
            $MainSocket = TCPConnect($Server, $Port)
            If $MainSocket = -1 Then
                GUICtrlSetData($Label4, "Status : Unable to connect.")
            Else
                GUICtrlSetData($Label4, "Status : Connecting...")
                TCPSend($MainSocket, "!Connected")
            EndIf
        Case $Button[1][1]
            Checkbutton(1, 1)
        Case $Button[1][2]
            Checkbutton(1, 2)
        Case $Button[1][3]
            Checkbutton(1, 3)
        Case $Button[2][1]
            Checkbutton(2, 1)
        Case $Button[2][2]
            Checkbutton(2, 2)
        Case $Button[2][3]
            Checkbutton(2, 3)
        Case $Button[3][1]
            Checkbutton(3, 1)
        Case $Button[3][2]
            Checkbutton(3, 2)
        Case $Button[3][3]
            Checkbutton(3, 3)
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func Checkbutton($row, $column)
    TCPSend($MainSocket, "!Button-" & $Player & "-" & $row & "-" & $column)
EndFunc   ;==>Checkbutton

Func Click($Player, $row, $column)
    If $Player = $Me Then
        If $Box[$row][$column] = 0 And $Turn = True Then
            GUICtrlSetData($Button[$row][$column], $Shape)
            GUICtrlSetState($Button[$row][$column], $GUI_DISABLE)
            $Box[$row][$column] = 5
            Checkwin()
            Checkturn()
        EndIf
    ElseIf $Player = $Opponent Then
        If $Box[$row][$column] = 0 And $Turn = False Then
            GUICtrlSetData($Button[$row][$column], $Shape2)
            GUICtrlSetState($Button[$row][$column], $GUI_DISABLE)
            $Box[$row][$column] = 1
            Checkwin()
            Checkturn()
        EndIf
    EndIf
EndFunc   ;==>Click

Func Check()
    $Server = GUICtrlRead($Input1)
    $Port = GUICtrlRead($Input2)
EndFunc   ;==>Check

Func Checktcp()
    $Data = TCPRecv($MainSocket, $MaxLength)
    If StringInStr($Data, "!Player") Then
        If $Connected = 2 Then
            $Data = StringSplit($Data, "-")
            $Player = $Data[2]
            $Me = $Player
            If $Me = 1 Then
                $Opponent = 2
                $Shape = "X"
                $Shape2 = "O"
                $Turn = True
            Else
                $Opponent = 1
                $Shape = "O"
                $Shape2 = "X"
                $Turn = False
            EndIf
            Checkturn2()
            $Connected = 3
        EndIf
    ElseIf $Data = "!Ready" Then
        If $Connected = 1 Then
            GUICtrlSetData($Label4, "Status : Your Opponent ready.")
            $Connected = 2
        EndIf
    ElseIf $Data = "!Bye" Then
        MsgBox(16, "Session Ended", "Connection Terminated.")
        Exit
    ElseIf $Data = "!Connected" Then
        If $Connected = 0 Then
            GUICtrlSetState($Connect, $GUI_DISABLE)
            GUICtrlSetData($Label4, "Status : Waiting for Opponent.")
            $Connected = 1
        EndIf
    ElseIf StringInStr($Data, "!Button") Then
        $Data = StringSplit($Data, "-")
        Click($Data[2], $Data[3], $Data[4])
    ElseIf $Data <> "" Then
        MsgBox("", "", $Data)
    EndIf
EndFunc   ;==>Checktcp

Func Checkwin()
    For $j = 1 To 8
        $Checkwin[$j] = 0
    Next
    For $j = 1 To 3
        $Checkwin[1] += $Box[1][$j]
        $Checkwin[2] += $Box[2][$j]
        $Checkwin[3] += $Box[3][$j]
        $Checkwin[4] += $Box[$j][1]
        $Checkwin[5] += $Box[$j][2]
        $Checkwin[6] += $Box[$j][3]
    Next
    $Checkwin[7] = $Box[1][1] + $Box[2][2] + $Box[3][3]
    $Checkwin[8] = $Box[1][3] + $Box[2][2] + $Box[3][1]
    For $i = 1 To 8
        If $Checkwin[$i] = 15 Then
            $Winner = 1
            $Point1 += 1
            GUICtrlSetData($Label4, "Status : Winner You !")
        ElseIf $Checkwin[$i] = 3 Then
            $Winner = 1
            $Point2 += 1
            GUICtrlSetData($Label4, "Status : Winner Opponent !")
        EndIf
    Next
EndFunc   ;==>Checkwin

Func Reset()
    $Games += 1
    GUICtrlSetData($Label5, "Games : " & $Games & "  You : " & $Point1 & "  Opponent : " & $Point2)
    Sleep(2000)
    For $i = 1 To 3
        For $j = 1 To 3
            $Box[$i][$j] = 0
            GUICtrlSetData($Button[$i][$j], "")
            GUICtrlSetState($Button[$i][$j], $GUI_ENABLE)
        Next
    Next
    If $Shape = "X" Then
        $Shape = "O"
        $Shape2 = "X"
        $Turn = False
    Else
        $Shape = "X"
        $Shape2 = "O"
        $Turn = True
    EndIf
    $Winner = 0
    $Moves = 0
    Checkturn2()
EndFunc   ;==>Reset

Func Checkturn()
    If $Winner <> 1 Then
        $Moves += 1
        If $Moves = 9 Then
            GUICtrlSetData($Label4, "Status : Draw...")
            Reset()
        Else
            If $Turn = True Then
                $Turn = False
                GUICtrlSetData($Label4, "Status : Opponent Turn!  (  " & $Shape2 & "  )")
            Else
                $Turn = True
                GUICtrlSetData($Label4, "Status : Your Turn!  (  " & $Shape & "  )")
            EndIf
        EndIf
    Else
        Reset()
    EndIf
EndFunc   ;==>Checkturn

Func Checkturn2()
    If $Turn = True Then
        GUICtrlSetData($Label4, "Status : Your Turn!  (  " & $Shape & "  )")
    Else
        GUICtrlSetData($Label4, "Status : Opponent Turn!  (  " & $Shape2 & "  )")
    EndIf
EndFunc   ;==>Checkturn2

Func OnAutoItExit()
    If $MainSocket <> -1 Then
        TCPSend($MainSocket, "!Bye")
        TCPCloseSocket($MainSocket)
    EndIf
    TCPShutdown()
EndFunc   ;==>OnAutoItExit
MasteR GunneR is offline  
Old 04/17/2008, 16:32   #17
 
elite*gold: 0
Join Date: Jan 2007
Posts: 1,753
Received Thanks: 443
nur wenn du den code nocheinmal postest :P und dann bitte mit den variablen xD

btw, soll das ein spiel sein? xD
Azunai is offline  
Old 04/17/2008, 16:34   #18
 
MasteR GunneR's Avatar
 
elite*gold: 0
Join Date: Dec 2007
Posts: 387
Received Thanks: 188
Ich denke mal das Spiel kennt jeder :>
Und bevor wer fragt: Nein, nicht von mir.
MasteR GunneR is offline  
Old 04/17/2008, 17:14   #19
 
elite*gold: 0
Join Date: Jan 2007
Posts: 1,753
Received Thanks: 443
hm des ding bringt nicht viel, so wie ich das jetzt überblickt habe, gibt es dort nur eine verbindung oder? o0
außerdem sind die funktionen veraltet, so wie in dem script gibt es einige garnichtmehr xD

naja trotzdem danke!
Azunai is offline  
Old 04/17/2008, 19:17   #20
 
elite*gold: 0
Join Date: Jan 2007
Posts: 1,753
Received Thanks: 443
hm ok ich denke die erste "Caller" version ist soweit fertig was TCP angeht!
am sammstag bräuchte ich jemanden der mal auf meinen "Server" connecten könnte

Port = 6112 (ja 6112 ist auch der GW port )
Azunai is offline  
Old 04/17/2008, 19:27   #21
 
elite*gold: 0
Join Date: Dec 2007
Posts: 680
Received Thanks: 141
wenn du mir alles gibst was ich brauch mach ich mit ^^
xSharkoonX is offline  
Old 04/18/2008, 21:26   #22
 
elite*gold: 0
Join Date: Jan 2007
Posts: 1,753
Received Thanks: 443
also master und slave ist soweit fertig...
aber ich bekomm keine connection ... der client gibt immer ein connection failed°!°

ich find nur nicht den fehler o0 port 6112 sollte ja bei jedem gw spieler offen sein...
Azunai is offline  
Old 04/18/2008, 21:43   #23
 
elite*gold: 0
Join Date: Jan 2007
Posts: 1,753
Received Thanks: 443
fehler gefunden! lösung noch nicht!
Azunai is offline  
Old 04/18/2008, 22:16   #24
 
elite*gold: 0
Join Date: Jan 2007
Posts: 1,753
Received Thanks: 443
also, kuzer zwischenstand, von dieser sekunde an ist meine arbeit technisch getan

server und client connecten, und führen gespräche

jetzt kommt nurnoch der GW interne bereich den ich coden muss!

btw: vorerst klappt des TCP aber nur über hamachi! weiß der teufel warum
ich werd mich aber noch dahinter setzen!
Azunai is offline  
Old 04/19/2008, 17:03   #25
 
-Anthrax-'s Avatar
 
elite*gold: 0
Join Date: Apr 2007
Posts: 543
Received Thanks: 112
lol........wie wärs mal mit der edit funktion? xD
-Anthrax- is offline  
Old 04/19/2008, 17:45   #26
 
elite*gold: 0
Join Date: Jan 2007
Posts: 1,753
Received Thanks: 443
nöö ^^ lag ja immer ne halbe stunde zwischen ^^
Azunai is offline  
Old 04/19/2008, 18:35   #27
 
elite*gold: 0
Join Date: Jan 2007
Posts: 1,753
Received Thanks: 443
so wird das nichts... ich brauche mehr tester!
momentan hilft mir nur ninja
ich brauche aber immer 3 tester ...
Azunai is offline  
Old 04/19/2008, 18:51   #28
 
elite*gold: 0
Join Date: Dec 2007
Posts: 680
Received Thanks: 141
ich helf dir..schick mir einfach das was ich brauch und ich mach mit
xSharkoonX is offline  
Old 04/19/2008, 18:54   #29
 
Gabba2's Avatar
 
elite*gold: 0
Join Date: Jan 2008
Posts: 1,403
Received Thanks: 918
Naja also ich würde gerne mit testen sag mir was ich machen soll/darf und ich machs^^
Gabba2 is offline  
Old 04/19/2008, 19:40   #30
 
elite*gold: 0
Join Date: Jan 2007
Posts: 1,753
Received Thanks: 443
test vorerst abgeschossen, der erste spike ist geglückt
Azunai is offline  
Reply


Similar Threads Similar Threads
[PROJECT - X2G4] Suche Team.
11/17/2009 - Metin2 Private Server - 2 Replies
Hallo. Ich suche Leute, die mit mir einen Metin2 Privat Server hosten wollen. Wir hosten vorerst mit Hamachi, nach 2 Wochen wenn die Beta - Phase zu ende ist werden wir auf einen Russischen Root umsteigen. Dieser wird in Omsk gehostet. Dann fange ich mal an: In der Beta Phase wird unser Server ein GM - Server sein, es werden aber Befehle wie /kill, /dc, /x1 u.v.m gesperrt. Nach der Beta, wird es ein Clubmt2 änlicher Server. Die Rates werden, eventuell ein Klick besser als bei DE. Pro...
[Team,Coding project]
07/12/2009 - CO2 Private Server - 0 Replies
To all the users of EPVP i have decided to come back out of retirement and start coding once again. - I may not have released much of my work to the EPVP community but i helped alot of servers while they were being worked on. - I'm looking for either an existing team, or to start a new one. I'm also looking for good hints on the best source to start with right now because i know their is a good baseline source out their can use and add to rather than make my own fresh.
L2JCTeam Dev Team Project
03/14/2009 - Lin2 Private Server - 8 Replies
I like to introduce to you our new Dev Team. We work with Gracia part2 based on L2J with many custom stuff and performance cleanup. Also we try to correct the "wholes" in server packs to make it secure from 3rd party programs. We have a lot of implemented skills not only custom stuff like others do. Just give it a try you find every info in the timeline or ask in our forum. The team is: GoDofAdeN Owner AKA ME Intrepid Core-DP Dev



All times are GMT +1. The time now is 11:16.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.