UDP-Chat funzt net :(

Übersicht BlitzBasic Beginners-Corner

Dieses Thema ist gesperrt, du kannst keine Beiträge editieren oder beantworten.

ToeB

Betreff: UDP-Chat funzt net :(

BeitragSa, Dez 08, 2007 18:38
Antworten mit Zitat
Benutzer-Profile anzeigen
Code: [AUSKLAPPEN]
Graphics 800,600,16,2
SetBuffer BackBuffer()
AppTitle("Chääät")

Global stream = CreateUDPStream(8000)
Global ip_count
Global IP = INT_IP(Input("IP : "))
Global Chat_an$="[ENTER HERE YOUR MESSAGE]",Chat$,Chat_a=0,blink,blink_ms=MilliSecs(),Name$ = Input("Name : "),y
HidePointer()
ClsColor 120,150,200

Type c
Field Text$,IP$,y
End Type
Global c.c
Repeat
g =GetKey()
Text 1,1,"IP : "+DottedIP(IP)
If Chat_a = 1
If g<>0 And g <> 8 And g<> 13 Then Chat$ = Chat$ + Chr(g)
If g=8 Then Chat$ = Mid(Chat$,1,Len(Chat$)-1)
If g=13 Then
c.c = New c:c\Text$ = Chat$:c\IP$ = Name$:c\y = y:y=y+1
If IP<>"" Then
WriteLine(stream,Name$+"[/]"+Chat$)
SendUDPMsg(stream,IP)
EndIf 
Chat$=""
EndIf
If BLink = 1 Then Rect StringWidth("SEND : "+Chat$)+3,560,1,13
EndIf
IP_rv = RecvUDPMsg(stream)
If IP_rv <> 0
Avail = ReadAvail(stream)
If Avail <> 0 Then
tt$ = ReadLine(stream)
c.c = New c
c\IP$ = Mid(tt$,1,Instr(tt$,"[/]")-1)
c\Text$ = Mid(tt$,Instr(tt$,"[/]")+3)
c\y = y:y = y + 1
EndIf
EndIf
If Chat_a = 0
Chat$=Chat_an$
If MAT(0,560,"SEND : "+Chat$) Chat_a=1:Chat$ = ""
EndIf
Color 255,255,255
Plot MouseX(),MouseY()
Oval MouseX()-10,MouseY()-10,20,20,0
Text 0,560,"SEND : "+Chat$:Rect 50,555,549,25,0
For c.c = Each c
ColorText(150,20+c\y*20,"[255,0,0]"+c\IP$+"[255,255,255] : [0,0,255]"+c\Text$)
Next
Delay 10
Flip
Cls
Until KeyHit(1)
End

Function Mat(x,y,Text$,xmid=0,ymid=0,modus=1)
Color 255,255,255
If xmid=0 And ymid = 0
  If MouseX() > x And MouseY() > y
    If MouseX() < x+StringWidth(Text$) And MouseY() < y + StringHeight(Text$) Then 
      Color 255,0,0
      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 
      Color 255,0,0
      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 
      Color 255,0,0
      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 
      Color 255,0,0
      If Modus = 1
        If MouseDown(1) Then Return 1
      Else
        Return 1
      EndIf
    EndIf
  EndIf
EndIf
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$,","))
b = Left ( t$, Len(t$))
Color r,g,b
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 INT_IP(IP$)
   A1 = Int(Left(IP$,Instr(IP$,".")-1)) : IP$ = Right(IP$,Len(IP$)-Instr(IP$,"."))
   A2 = Int(Left(IP$,Instr(IP$,".")-1)) : IP$ = Right(IP$,Len(IP$)-Instr(IP$,"."))
   A3 = Int(Left(IP$,Instr(IP$,".")-1)) : IP$ = Right(IP$,Len(IP$)-Instr(IP$,"."))
   A4 = Int(IP$)
   Return (A1 Shl 24) + (A2 Shl 16) + (A3 Shl 8 ) + A4
End Function


Warum kann ich keine Texte senden geschweige denn empfangen ?
Was mache ich Falsch ? Ich blick nich mehr durch Sad ....


thx und mfg Crack93
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!

ToeB

BeitragSa, Dez 08, 2007 19:06
Antworten mit Zitat
Benutzer-Profile anzeigen
Okay funzt jetzt... hab aber noch ne andere Frage :

Wie kann ich das machen, dass alle spieler angezeigt werden, die Online sind, und zwar so, dass man sie auswählen kann, zu wem man die Nachricht sendet ?


thx und mfg Crack93


[EDIT]

Wieso antwortet mir keiner ? Es ist dringent !

thx und mfg Crack93

ToeB

BeitragSa, Dez 08, 2007 22:51
Antworten mit Zitat
Benutzer-Profile anzeigen
Ich bin jetzt ein wenig weiter..... Ich hab das grad mit jemanden getestet, aber nur ER kann mich sehen, aber ich ihn nich.... warum ?

Code: [AUSKLAPPEN]
Graphics 800,600,16,2
Global s = CreateImage(10,10)
SetBuffer ImageBuffer(s)
Oval 0, 0, 10, 10, 0
Plot 3,3 : Plot 6,3
Plot 3,6 : Plot 4,7 : Plot 5,7 : Plot 6,6
SetBuffer BackBuffer()
AppTitle("Chääät")
Global Port = 8000
Global Port2= 8001
Global Stream = CreateUDPStream(Port)
Global x1=200,y1=200,x2,y2,T1$,T2$
Global ip_count,back_ms = MilliSecs()
Global IP = INT_IP(Input("IP : "))
Global Chat_an$="[ENTER HERE YOUR MESSAGE]",Chat$,Chat_a=1,blink,blink_ms=MilliSecs(),Name$ = Input("Name : "),Name_$
HidePointer()
ClsColor 0,0,0



Repeat
If KeyDown(200) Then y1 = y1 - 2
If KeyDown(208) Then y1 = y1 + 2
If KeyDown(203) Then x1 = x1 - 2
If KeyDown(205) Then x1 = x1 + 2
If x1 < 0 Then x1 = 0
If x1 > 790 Then x1 = 790
If y1 < 0 Then y1 = 0
If y1 > 590 Then y1 = 590
WriteInt(stream,x1)
WriteInt(stream,y1)
WriteLine(Stream,Name$)
If blink_ms <= MilliSecs() - 200 Then Blink = 1 - Blink:Blink_ms = MilliSecs()
g =GetKey()
Text 1,1,"IP : "+DottedIP(IP)
If Chat_a = 1
If g<>0 And g <> 8 And g<> 13 And g > 31 Then Chat$ = Chat$ + Chr(g)
If KeyDown(14) Then
If back_ms <= MilliSecs() -200 Then Chat$ = Mid(Chat$,1,Len(Chat$)-1):Back_ms = MilliSecs()
EndIf
If g=13 Then
WriteLine(Stream,Chat$)
T1$ = Chat$
SendUDPMsg(stream,IP,Port)
Chat$=""
EndIf
If Blink = 1 Then Rect StringWidth("SEND : "+Chat$)+3,560,1,13
EndIf
x2 = ReadInt(stream)
y2 = ReadInt(stream)
Name_$ = ReadLine(stream)
TT$  = ReadLine(stream)
If TT$ <> "" Then T2 = TT$
If Chat_a = 0
Chat$=Chat_an$
;If MAT(0,560,"SEND : "+Chat$) Chat_a=1:Chat$ = ""
EndIf
Color 255,255,255
;Plot MouseX(),MouseY()
;Oval MouseX()-10,MouseY()-10,20,20,0
Text 0,560,"SEND : "+Chat$:Rect 50,555,549,25,0
DrawImage s,x1,y1
DrawImage s,x2,y2
Text x1+5,y1+15,Name$,1,1
Text x2+5,y2+15,Name_$,1,1
If T1 <> "" Then
Color 128,128,128:Rect x1+5-StringWidth(T1)/2-10,y1-25,StringWidth(T1)+20,20,0
Color 200,200,200:Rect x1+5-StringWidth(T1)/2-10,y1-25,StringWidth(T1)+20,20,1
Color 0,0,255:Text x1+5,y1-15,T1,1,1:Color 255,255,255
EndIf 
If T2 <> "" Then
Color 128,128,128:Rect x2+5-StringWidth(T2)/2-10,y2-25,StringWidth(T2)+20,20,0
Color 200,200,200:Rect x2+5-StringWidth(T2)/2-10,y2-25,StringWidth(T2)+20,20,1
Color 0,0,255:Text x2+5,y2-15,T2,1,1:Color 255,255,255
EndIf 
SendUDPMsg(stream,IP,Port)
Delay 10
Flip
Cls
Until KeyHit(1)
End

Function Mat(x,y,Text$,xmid=0,ymid=0,modus=1)
Color 255,255,255
If xmid=0 And ymid = 0
  If MouseX() > x And MouseY() > y
    If MouseX() < x+StringWidth(Text$) And MouseY() < y + StringHeight(Text$) Then 
      Color 255,0,0
      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 
      Color 255,0,0
      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 
      Color 255,0,0
      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 
      Color 255,0,0
      If Modus = 1
        If MouseDown(1) Then Return 1
      Else
        Return 1
      EndIf
    EndIf
  EndIf
EndIf
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$,","))
b = Left ( t$, Len(t$))
Color r,g,b
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 INT_IP(IP$)
   A1 = Int(Left(IP$,Instr(IP$,".")-1)) : IP$ = Right(IP$,Len(IP$)-Instr(IP$,"."))
   A2 = Int(Left(IP$,Instr(IP$,".")-1)) : IP$ = Right(IP$,Len(IP$)-Instr(IP$,"."))
   A3 = Int(Left(IP$,Instr(IP$,".")-1)) : IP$ = Right(IP$,Len(IP$)-Instr(IP$,"."))
   A4 = Int(IP$)
   Return (A1 Shl 24) + (A2 Shl 16) + (A3 Shl 8 ) + A4
End Function



??


thx und mfg Crack93
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!

BladeRunner

Moderator

BeitragSa, Dez 08, 2007 23:03
Antworten mit Zitat
Benutzer-Profile anzeigen
Respekt, triplepost.
~GESCHLOSSEN~
Zu Diensten, Bürger.
Intel T2300, 2.5GB DDR 533, Mobility Radeon X1600 Win XP Home SP3
Intel T8400, 4GB DDR3, Nvidia GF9700M GTS Win 7/64
B3D BMax MaxGUI

Stolzer Gewinner des BAC#48, #52 & #92

Dieses Thema ist gesperrt, du kannst keine Beiträge editieren oder beantworten.


Übersicht BlitzBasic Beginners-Corner

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group