LAN Play
Blitz3D Forums/Blitz3D Programming/LAN Play
| ||
Hey Guys, Does anybody know how you would setup a multiplayer game ONLY on your local network?? |
| ||
It's the same as if it's on mutiple networks. Use UDP. Directplay is too slow. |
| ||
Can you give me an example of how to setup a LAN multiplayer game?? p.s Thanks for responding KillerX :) Oh, and the pulse rifle's bullets are comming along GREAT :D |
| ||
AppTitle "Fastalker" Graphics 800,600,0,2 FileOut = ReadFile("IP.txt") Global Name$ = ReadLine(FileOut) Global NumberOfPlayers = ReadLine(FileOut) Global Signin$ = ReadLine(FileOut) Global Signout$ = ReadLine(FileOut) ;Global Signature$ = ReadLine(FileOut) Global MessageSound% = ReadLine(FileOut) Dim IPAdress%(NumberofPlayers) For Loop = 1 To NumberofPlayers IPAdress(Loop) = ReadLine(FileOut) Next Global Sound = LoadSound("ReceivedMessage.wav") Global Stream% = CreateUDPStream(828) Global NewStream% = CreateUDPStream(79) Repeat IP = RecvUDPMsg(NewStream) For Loop = 1 To NumberofPlayers If IP = IPAdress(Loop) Message = 1 Next If Message = 1 Message = 0 If MessageSound = 1 PlaySound Sound String1$ = ReadString$(NewStream) Print String1 EndIf If KeyHit(28) FlushKeys Variable$ = Name + ": " + Input(Name + ": ") Broadcast(Variable,79,0) FlushKeys EndIf If KeyHit(2) And NumberOfPlayers >=1 FlushKeys Variable$ = Name + ": " + Input(Name + ": ") Broadcast(Variable,79,1) FlushKeys EndIf If KeyHit(3) And NumberOfPlayers >=2 FlushKeys Variable$ = Name + ": " + Input(Name + ": ") Broadcast(Variable,79,2) FlushKeys EndIf If KeyHit(4) And NumberOfPlayers >=3 FlushKeys Variable$ = Name + ": " + Input(Name + ": ") Broadcast(Variable,79,3) FlushKeys EndIf If KeyHit(5) And NumberOfPlayers >=4 FlushKeys Variable$ = Name + ": " + Input(Name + ": ") Broadcast(Variable,79,4) FlushKeys EndIf If KeyHit(6) And NumberOfPlayers >=5 FlushKeys Variable$ = Name + ": " + Input(Name + ": "); + Signature Broadcast(Variable,79,5) FlushKeys EndIf If KeyHit(7) And NumberOfPlayers >=6 FlushKeys Variable$ = Name + ": " + Input(Name + ": ") Broadcast(Variable,79,6) FlushKeys EndIf If KeyHit(8) And NumberOfPlayers >=7 FlushKeys Variable$ = Name + ": " + Input(Name + ": ") Broadcast(Variable,79,7) FlushKeys EndIf If KeyHit(9) And NumberOfPlayers >=8 FlushKeys Variable$ = Name + ": " + Input(Name + ": ") Broadcast(Variable,79,8) FlushKeys EndIf If KeyHit(10) And NumberOfPlayers >=9 FlushKeys Variable$ = Name + ": " + Input(Name + ": ") Broadcast(Variable,79,9) FlushKeys EndIf If KeyHit(11) And NumberOfPlayers >=10 FlushKeys Variable$ = Name + ": " + Input(Name + ": ") Broadcast(Variable,79,10) FlushKeys EndIf ;sign in and out If KeyHit(199) FlushKeys Variable$ = Name + ": " + Signin Print Name + ": " + Signin Broadcast(Variable,79,10) FlushKeys EndIf If KeyHit(207) FlushKeys Variable$ = Name + ": " + Signout Print Name + ": " + Signout Broadcast(Variable,79,10) FlushKeys EndIf Until KeyHit(1) WaitKey End Function Broadcast(Message$,Port,Recipient);Message is the stream that is being broadcasted. Port is the Destination Port. If Recipient = 0 For Loop = 1 To NumberofPlayers WriteString(Stream,Message) SendUDPMsg Stream,IPAdress(Loop),Port Next Else WriteString(Stream,Message) SendUDPMsg Stream,IPAdress(Recipient),Port EndIf End Function This is for a UDP Chat program that I wrote. |
| ||
Thanks KillerX :) But is it possible to use DirectPlay and ONLY connect for a LAN game? |
| ||
No. It's far too slow to use in realtime. You could possibly use it for a turn based game though. |
| ||
Could anybody show me a small example of just how to connect to the computers on a local network. For example: I have three computers and I want to setup sort of like a Chinees Checkers game. How would you connect them through Blitz3D. They are all connected on my local network though. [edit] Here is what I have so far: I run that when I'm hosting a game on my machine and when I fill everything out with the DirectPlay box, it works fine. But when I try to do that on another machine that is on my local network, it doesn't work. What port number does it have to be?? [/edit] |
| ||
Well, what I would do is set up a sort of server-client thing. Have one of the computers on your network work as a server:port=input("What port: ") tcp=CreateTCPServer(port) Then, I'm pretty sure that you can just do this for the clients: serverip$="192.168.1.1" port=8080 tcp=OpenTCPStream(serverip$,port) Just set port to whatever you set the server at, then change serverip$ to the local IP of the server comp. |
| ||
Thnx xtremegamr :) |
| ||
How can I put my server program ( in .EXE ) on the webpage I have created ? I want to try a multiplayer mode for my program Galaxang ( several "vaisseaux" in the cosmos ). |
| ||
I don't know the answer to your question, having myself avoided network stuff out of a combination of fear and thinking of it as a sort of optional last thing to include someday. However, you might get a better response if, rather than bumping a vaguely related thread from years ago, you created a brand new thread and put a link to this one in your question in that thread? Otherwise people feel like they have to read through the whole thread to get to your question, and many of them won't bother. |
| ||
Use Raknet :P |
| ||
Yes - I would never have even known that this was Prym's question - I just saw the stuff at the top and thought it was to do with something else...so I second what Axel Wheeler said...resurrecting old threads is not going to get the help you need! Can't you just upload with ftp the exe file to the website and then download it onto whichever machine you want to use as your server? Not sure I understand the question. |
| ||
I think he's asking how to do networking with Blitz. Specifically he's asking how to run his program as a network service, i.e. client-server rather than p2p. It also sounds like the server he is talking about may be a standard web hosting service. But I think he really just needs a good Blitz3D networking tutorial. Basically, he needs to know all about client server computing in Blitz. And probably P2P. It's one of the few areas of Blitz that I've managed to avoid, so I can't really help. But here's a couple of discussions on the topic I found through google: http://www.blitzbasic.com/Community/posts.php?topic=88872 http://www.blitzbasic.com/Community/posts.php?topic=63868 Good luck Prym! |