TCP - was mache ich falsch ?
Übersicht

![]() |
ToeBBetreff: TCP - was mache ich falsch ? |
![]() Antworten mit Zitat ![]() |
---|---|---|
Code: [AUSKLAPPEN] Graphics 800,600,16,2
SetBuffer BackBuffer() AppTitle "UPD Chat" ;*** Globals : *** Global make = 0 Global nam,pot Global name$="Heinz",port=21,SpielName$="Heinz Spiel",IP$ = "192.168.0.2" Global Pointer_frame = 0,Pms = MilliSecs() Global TFB,TFMS = MilliSecs() Global Chat$,yy,ScrollY Type s Field y Field Text$ Field Name$ End Type Global s.s ;*** Grafiken : *** Global Button = LoadAnimImage("gfx\Button.bmp",135,28,0,3) MaskImage Button,255,0,255 Global Schild = LoadImage("gfx\Schild.bmp") MaskImage Schild,255,0,255 Global Pointer = LoadAnimImage("gfx\Pointer.bmp",29,29,0,8) MaskImage Pointer,255,0,255 ;*** Fonts : *** Global Schrift = LoadFont("Secret Service Typewriter",20,1,0,0) SetFont Schrift ClsColor 160,160,255 Dim B(10) Dim CB(10) Dim TF(10) HidePointer() Repeat ;*** ALGEMEIN *** g=GetKey() If TFMS <= MilliSecs() - 1000 Then TFB = 1 - TFB:TFMS = MilliSecs() If pms <= MilliSecs() - 100 Then Pointer_frame = (Pointer_frame + 1) Mod 8 Pms = MilliSecs() EndIf ;*** Make = 0 *** If make = 0 Then Color 255,0,0 InfoText(300,150,200,300,"MENÜ",1) B(1) = CreateButton(400,230,"HOST GAME",1,0) B(2) = CreateButton(400,260,"JOIN GAME",1,0) B(3) = CreateButton(400,290,"OPTIONS",1,0) B(4) = CreateButton(400,400,"EXIT GAME",1,0) If CB(1) = 1 Then stream = CreateTCPServer(Port):make = 1 If CB(2) = 1 Then stream = OpenTCPStream(IP$,port):Make = 1 If CB(3) = 1 Then make = 2 If CB(4) = 1 Then End For i = 1 To 4 CB(i) = CheckButton(B(i),CB(i)) Next EndIf ;*** Make = 1 *** If make = 1 empfang = AcceptTCPStream(stream) InfoText(0,400,800,200,"Chat : ") If g <> 0 And g <> 13 And g <> 8 Then Chat$ = Chat$ + Chr(g) If g = 8 Then Chat$ = Mid(chat$,1,Len(Chat$)-1) If empfang <> 0 If g = 13 Then WriteLine stream,Chat$:CreateText(Name$,Chat$):Chat$ = "" EndIf If TFB Then Rect 100+StringWidth(Chat$),422,1,16 Text 100,420,Chat$ Text 1,1,stream Text 1,20,empfang UpdateText() EndIf ;*** Make = 2 *** If make = 2 InfoText(100,100,600,50," Name : ") InfoText(100,200,600,50," IP :") InfoText(100,300,600,50,"SpielName : ") Text 300,120,Name$ Text 300,220,IP$ Text 300,320,SpielName$ If MouseHit(1) TF(1) = 0:TF(2) = 0:TF(3) = 0 If RectsOverlap(MouseX(),MouseY(),1,1,100,100,600,50)Then TF(1) = 1:TF(2) = 0:TF(3) = 0 If RectsOverlap(MouseX(),MouseY(),1,1,100,200,600,50)Then TF(1) = 0:TF(2) = 1:TF(3) = 0 If RectsOverlap(MouseX(),MouseY(),1,1,100,300,600,50)Then TF(1) = 0:TF(2) = 0:TF(3) = 1 EndIf If TF(1) = 1 Then If TFB Then Rect 300+StringWidth(Name$),122,1,16 If g <> 0 And g <> 13 And g <> 8 Then Name$ = Name$ + Chr(g) If g = 8 Then Name$ = Mid(Name$,1,Len(Name$)-1) If g = 13 Then TF(1) = 0 EndIf If TF(2) = 1 Then If TFB Then Rect 300+StringWidth(IP$),222,1,16 If g <> 0 And g <> 13 And g <> 8 Then IP$ = IP$ + Chr(g) If g = 8 Then IP$ = Mid(IP$,1,Len(IP$)-1) If g = 13 Then TF(2) = 0 EndIf If TF(3) = 1 Then If TFB Then Rect 300+StringWidth(SpielName$),322,1,16 If g <> 0 And g <> 13 And g <> 8 Then SpielName$ = SpielName$ + Chr(g) If g = 8 Then SpielName$ = Mid(SpielName$,1,Len(SpielName$)-1) If g = 13 Then TF(3) = 0 EndIf B(5) = CreateButton(0,0,"BACK") If CB(5) = 1 Then make = 0 CB(5) = CheckButton(B(5),CB(5)) EndIf DrawImage Pointer,MouseX(),MouseY(),pointer_frame Flip Cls Until KeyHit(1) End ;********* FUNCTIONEN *********** Function CreateButton(x,y,Text$,xmid=0,ymid=0,I$="") If xmid = 1 Then x = x - ImageWidth(Button)/2 If xmid = 2 Then x = x - ImageWidth(Button) If ymid = 1 Then y = y - ImageHeight(button)/2 If ymid = 2 Then y = y - ImageHeight(button) Local Wert = 0 DrawImage Button,x,y,0 If ImageRectCollide(Button,x,y,0,MouseX(),MouseY(),1,1) Then Wert = 2 DrawImage Button,x,y,1 If MouseDown(1) Then DrawImage Button,x,y,2 Wert = 1 EndIf If I$ <> "" Then Info(MouseX(),MouseY(),I$) EndIf Color 250,150,190 Text x+135/2,y+14,Text$,1,1 Color 255,255,255 Return Wert End Function Function CheckButton(But,cb) If but = 1 Then cb = 2 If cb = 2 If Not MouseDown(1) Then cb=0:Return 1 EndIf If but = 0 Then cb = 0 Return cb End Function Function InfoText(x,y,width,height,Text$,xmid=0) If width < 22 Or height < 22 Then RuntimeError "Graphikeinstellungen zu klein !" DrawImageRect Schild,x,y,0,0,11,11 DrawImageRect Schild,x+width-11,y,124,0,11,11 DrawImageRect Schild,x,y+height-11,0,19,11,11 DrawImageRect Schild,x+width-11,y+height-11,124,19,11,11 For xx = 11 To width-11 DrawImageRect Schild,x+xx,y,20,0,1,11 DrawImageRect Schild,x+xx,y+height-11,20,19,1,11 Next For yy = 11 To height-11 DrawImageRect Schild,x,y+yy,0,15,11,1 DrawImageRect Schild,x+width-11,y+yy,124,15,11,1 Next For xx = 1 To (width-20)/10 For yy = 1 To (height-20)/10 DrawImageRect Schild,x+xx*10,y+yy*10,55,15,10,10 Next Next While Instr(Text$,"\")-1 > 0 If xmid = 0 Then Text 20+x,20+y,Left(Text$,Instr(Text$,"\")-1) Text$ = Mid(Text$,Instr(Text$,"\")+1,-1) y = y + FontHeight() EndIf If xmid = 1 Then Text x+width/2,20+y,Left(Text$,Instr(Text$,"\")-1),1 Text$ = Mid(Text$,Instr(Text$,"\")+1,-1) y = y + FontHeight() EndIf Wend If xmid = 0 Then Text 20+x,20+y,Text$ If xmid = 1 Then Text x+width/2,20+y,Text$,1 End Function Function Input2$(x,y,i2$,vor$="") g = GetKey() If g > 0 And g <> 13 And g <> 8 i2 = i2 + Chr(g) If g = 8 Then i2 = Mid(i2,1,Len(i2)-1) Text x,y,vor$+i2$ Return i2$ End Function Function Mat(x,y,Text$,xmid=0,ymid=0,modus=0) If xmid=0 And ymid = 0 If MouseX() > x And MouseY() > y If MouseX() < x+StringWidth(Text$) And MouseY() < y + StringHeight(Text$) Then If Modus = 1 If MouseDown(1) Then Return 1 Else Return 1 EndIf EndIf EndIf EndIf If xmid = 1 And ymid = 0 If MouseX() > x-StringWidth(Text$)/2 And MouseY() > y If MouseX() < x+StringWidth(Text$)/2 And MouseY() < y + StringHeight(Text$) Then If Modus = 1 If MouseDown(1) Then Return 1 Else Return 1 EndIf EndIf EndIf EndIf If xmid = 0 And ymid = 1 If MouseX() > x And MouseY() > y-StringHeight(Text$)/2 If MouseX() < x+StringWidth(Text$) And MouseY() < y + StringHeight(Text$)/2 Then If Modus = 1 If MouseDown(1) Then Return 1 Else Return 1 EndIf EndIf EndIf EndIf If xmid = 1 And ymid = 1 If MouseX() > x-StringWidth(Text$)/2 And MouseY() > y-StringHeight(Text$)/2 If MouseX() < x+StringWidth(Text$)/2 And MouseY() < y + StringHeight(Text$)/2 Then If Modus = 1 If MouseDown(1) Then Return 1 Else Return 1 EndIf EndIf EndIf EndIf End Function Function ConstString$(String$,Anzahl,mode=0) If mode = 0 Then If Len(String$) > Anzhal Then String$ = Mid(String$,1,Len(String$)-1) ElseIf mode = 1 If StringWidth(String$) > Anzahl Then String$ = Mid(String$,1,Len(String$)-1) EndIf Return String$ End Function Function ConstVar(Var,min,max) If Var < min Then Var = min If Var > max Then Var = max Return Var End Function Function ColorText(x,y,Text$) anf$ = Left(Text$,Instr(Text$,"[")-1) Text$ = Right(Text$,Len(Text$)-Instr(Text$,"[")+1) Text x,y,anf x = x + StringWidth(anf) While Instr(Text$,"]") > 0 t$ = Mid(Text$,Instr(Text$,"[")+1,Instr(Text$,"]")-Instr(Text$,"[")-1) r = Left ( t$, Instr( t$,",")) t$ = Right( t$,Len(t$)-Instr( t$,",")) g = Left ( t$, Instr( t$,",")) t$ = Right( t$,Len(t$)-Instr( t$,",")) bl = Left ( t$, Len(t$)) Color r,g,bl Text$ = Right(Text$,Len(Text$)-Instr(Text$,"]")) n$ = Mid(Text$,1,Instr(Text$,"[")-1) Text x,y,n$ x = x + StringWidth(n$) Wend Color 255,255,255 End Function Function CreateTransImage(Image) MidHandle Image Local sx = ImageWidth(Image) Local sy = ImageHeight(Image) img = CreateImage(sx,sy,2) MidHandle img mask = CreateImage(100,100) For bl = 0 To 1 SetBuffer ImageBuffer(img,bl) DrawImage Image,sx/2,sy/2 Color 255,0,255 For x = 0 To sx For y = 0 + (x Mod 2) - bl To sy Step 2 Plot x,y Next Next Next MaskImage img,255,0,255 SetBuffer BackBuffer() Return CopyImage(img) End Function Function Info(x,y,Text$) Color 255,180,150 Rect x,y,StringWidth(Text$)+20,StringHeight(Text$)+20 Color 0,0,0 Rect x,y,StringWidth(Text$)+20,StringHeight(Text$)+20,0 Text x+10,y+10,Text$ Color 255,255,255 End Function Function MIR(x,y,width,height,open=1) If MouseX() > x And MouseY() > y And MouseX() < x+width And MouseY() < y+height Color 255,255,255:Rect x,y,width,height,open If MouseHit(1) Then Color 255,255,255:Return 1 EndIf End Function Function CreateText(Name$,Text$) s.s = New s s\y = yy*20:yy = yy + 1 If yy*20-ScrollY > 160 Then ScrollY = ScrollY + 20 s\Name$ = NAme$ s\Text$ = Text$ End Function Function UpdateText() Viewport 20,420,760,160 For s.s = Each s ColorText(20,s\y-ScrollY,"[0,0,255]"+s\Name$+"[255,255,0]"+s\Text$) Next Viewport 0,0,800,600 End Function Was mache ich hier falsch ? Der bekommt die verbindung nicht hin oda sagt bei "AcceptTCPStream(stream)" TCP Stream does not exist oda so... thx und mfg ![]() Crackyy |
||
Religiöse Kriege sind Streitigkeiten erwachsener Männer darum, wer den besten imaginären Freund hat.
Race-Project - Das Rennspiel der etwas anderen Art SimpleUDP3.0 - Neuste Version der Netzwerk-Bibliothek Vielen Dank an dieser Stelle nochmal an Pummelie, welcher mir einen Teil seines VServers für das Betreiben meines Masterservers zur verfügung stellt! |
Dreamora |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
tut er ja auch nicht. du kannst nicht einfach so AcceptTCPStream
wenn nämlich grad keiner Verbindet kommt da 0 raus und das wars ... das wartet nicht bis man versucht eine TCP verbindung aufzubauen. |
||
Ihr findet die aktuellen Projekte unter Gayasoft und könnt mich unter @gayasoft auf Twitter erreichen. |
![]() |
ToeB |
![]() Antworten mit Zitat ![]() |
---|---|---|
aso ^^
Aber wie finde ich z.b. heraus, welche spiele schon laufen(sodass ich ne liste erstellen kann) ? thx und mfg Crackyy ![]() |
||
Religiöse Kriege sind Streitigkeiten erwachsener Männer darum, wer den besten imaginären Freund hat.
Race-Project - Das Rennspiel der etwas anderen Art SimpleUDP3.0 - Neuste Version der Netzwerk-Bibliothek Vielen Dank an dieser Stelle nochmal an Pummelie, welcher mir einen Teil seines VServers für das Betreiben meines Masterservers zur verfügung stellt! |
Shark |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Wenn du ein Spiel eröffnest dann speicherst du dies einfach extern auf einem Server ab,
dann kannst du abfrage ob ein Spiel eröffnet ist und schon hast du eine Liste mfg Shark |
||
![]() |
Nooby |
![]() Antworten mit Zitat ![]() |
---|---|---|
Lies dir das mal durch:Direct Play - Dialogbox
Achja und gibt es da nicht Probleme mit der Funktion "CreateButton"? |
||
DAS PERPETUOMOBILE!!!
http://www.sax.de/~stalker/pad/199801/ |
Dreamora |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
directplay ist keine sinnvolle lösung denn damit musst du die zieladresse immer noch kennen.
Am besten via PHP auf einer Website eine liste der laufenden spiele wo sich leute einloggen könnten oder einen masterserver schreiben der nix macht ausser die laufenden spiele für andere die connecten wollen zu verwalten (match making server in RTS zb) |
||
Ihr findet die aktuellen Projekte unter Gayasoft und könnt mich unter @gayasoft auf Twitter erreichen. |
![]() |
ToeB |
![]() Antworten mit Zitat ![]() |
---|---|---|
erstmal thx euch allen ![]() @ shark : Ich check das nich wie du das meinst... also einen anderen server erstellen und darauf dann SpielName$ Speichern oda ? warum probleme ? nein... |
||
Religiöse Kriege sind Streitigkeiten erwachsener Männer darum, wer den besten imaginären Freund hat.
Race-Project - Das Rennspiel der etwas anderen Art SimpleUDP3.0 - Neuste Version der Netzwerk-Bibliothek Vielen Dank an dieser Stelle nochmal an Pummelie, welcher mir einen Teil seines VServers für das Betreiben meines Masterservers zur verfügung stellt! |
Dreamora |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Anderen Server erstellen der die Spiele verwaltet ja, oder matchmaking server via PHP wie es CS2D macht und andere. | ||
Ihr findet die aktuellen Projekte unter Gayasoft und könnt mich unter @gayasoft auf Twitter erreichen. |
![]() |
Nooby |
![]() Antworten mit Zitat ![]() |
---|---|---|
Ich meine in dem Link auch nur die Idee mit den verschachtelten For-Schleifen, um Spiele zu suchen. Aber wenn man nützlichen Webspace hat ist natürlich die Idee auch nicht schlecht. | ||
DAS PERPETUOMOBILE!!!
http://www.sax.de/~stalker/pad/199801/ |
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group