Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / multiplayer code anyone

Author
Message
Neil19533
20
Years of Service
User Offline
Joined: 30th Aug 2003
Location: England
Posted: 24th Mar 2004 05:37
I have just made some simple code for a tcp/ip connection.
This may be helpfull for someone.

there are 2 programs the server and the client

server:
Quote: "rem this command connects you to your own computer with a tcp/ip connection
rem "127.0.0.1" is the address to connect to your self
rem the number 3 is a tcp/ip connection
set net connection 3,"127.0.0.1"

rem this create's a network game and you are the host computer
rem "game1"=name of game
rem "host"=Name of player
rem 2 means a client host game that means it sends information to a server which
rem which then sends it to all the clients
create net game "game1","host",2

rem for fun this prints connected when you connect.
print "connected"

rem start a simple loop
do

rem this is an input command so you can send information over the net
input "type: ",txt$

rem this command sends a some text information across the net connection
send net message string 0,txt$

rem this command is collecting any information that may have been sent to the computer
get net message

rem this command makes text$ have the same value as the string sent over the net
text$=net message string$()

rem this command reads the text$ to make sure it has some text in
if text$>""

rem this command prints the text$'s text.
print text$

rem this ends the if command
endif

rem this ends the loop
loop"

Client:
Quote: "rem ---------------------------
rem This makes a net connection.
rem number 3 means tcp/ip connection.
rem the "127.0.0.1" is an ip address which connects you to your own computer
set net connection 3,"127.0.0.1"

rem the next command allows you to join the game one the net connection
join net game 1,"client"

rem for fun this will tell you that you are connected after it has connected
print "connected"

rem a simple loop
do

rem this is an input command so you can send information over the net
input "type: ",txt$

rem this command sends a some text information across the net connection
send net message string 0,txt$

rem this command is collecting any information that may have been sent to the computer
get net message

rem this command makes text$ have the same value as the string sent over the net
text$=net message string$()

rem this command reads the text$ to make sure it has some text in
if text$>""

rem this command prints the text$'s text.
print text$

rem this ends the if command
endif

rem this ends the loop
loop"


I wonder where that fish did go, a fish, a fish, a fish, O
Neil19533
20
Years of Service
User Offline
Joined: 30th Aug 2003
Location: England
Posted: 24th Mar 2004 05:43
there is a problem with it
if information is sent more than once threw one they break they must be done in order with client server client server ect...

I wonder where that fish did go, a fish, a fish, a fish, O
Neil19533
20
Years of Service
User Offline
Joined: 30th Aug 2003
Location: England
Posted: 24th Mar 2004 07:04 Edited at: 24th Mar 2004 07:04
I have also discovered that this also has trouble when there is more than just the client and the host.

But it can still be used as a guide or learning resorce into the multiplayer commands.

I wonder where that fish did go, a fish, a fish, a fish, O

Login to post a reply

Server time is: 2024-05-13 19:30:39
Your offset time is: 2024-05-13 19:30:39