rem zootans 20 line challenge Chat room 7billion.5
set window on;set display mode 640,480,32;sync on : sync rate 60;PlayerNumber=default net game("gamename","playername",2,1)
if net game exists()=1
if PlayerNumber=1 then set window title "HOST Player "+str$(PlayerNumber);if PlayerNumber=2 then set window title "CLIENT Player "+str$(PlayerNumber)
dim TXT_DATA$(2) as string
do
get net message
if net message type()=3 then TXT_DATA$(2) = net message string$();get net message;cls 0
text 10,40,"[player2]: " + (TXT_DATA$(2))
text 10,20,"[player1]: " + (TXT_DATA$(1))
if returnkey() > 0 then inc tog,1; wait 200
if tog > 2 then tog = 0
if tog = 1 then text 20,0,"you say > ";input " "; TXT_DATA$(1): cls 0
if tog = 2then send net message string 0,(TXT_DATA$(1));inc tog,1
sync : if escapekey()=1 then exit
loop
free net game
else
do : cls 0 : center text 160,113,"COULD NOT CREATED NET GAME" : sync : loop
endif
i just finnished this for a simple chat interface for my online 2 player game , i scrunched it to 19 lines , for DBpro!
to test it run it 2 times and talk to yourself! Return key to start message, return key to send message.