TGC Codebase Backup



Chat Room Simple by tfm1

9th Jun 2006 15:08
Summary

Chat room simple. I need help here, this is the source code I wrote mixing all the different chat room codes together. Could some one see if you can get it to work correctly. I'm n



Description

Please do tell me if you get it to work.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    ` Notes
print " "
print "Welcome to Chat Room! Chat Room created by Mustafa Rashad."
print " "
print "One day this chat room will be so powerful you will be able to share files and"
print "if God wills, may be even video conferencing."
print " "
print "Instructions: * This is a beta version."

print " "
` ---------------------------------------------------------------------------------------------------

`CONNECT TO TCP/IP CONNECTION.
print "Searching for connections..."
perform checklist for net connections
for i=1 to checklist quantity()
   if checklist string$(i)="Internet TCP/IP Connection For DirectPlay" then netsel=i
next i
print "   connection found"
print ""
input "Please enter ip address of server: ",ip$
print ""
print "Connecting..."
set net connection netsel,ip$
print "   connected"
print ""
print "Searching for server..."

`CHECK IF ANY SERVERS EXIST DISPLAY THEM AND ASK USER TO JOIN OR CREATE A NET GAME.
perform checklist for net sessions
print "   server found" : cls
print "[ ",checklist quantity()," ] SERVERS FOUND"
for i=1 to checklist quantity()
   print i,". ",checklist string$(i)
next i
print "" : input "(1)JOIN / (2)CREATE: ",netsel

`IF JOINING A CURRENT GAME.
if netsel=1
   host=0 : flag=1
   input "Join which server?: ",s
   input "Nick name: ",name$
   join net game s,name$
   print "Joining..."
endif

`IF STARTING A NET GAME.
if netsel=2
   host=1
   input "Server name: ",s$
   input "Nick name: ",name$
   input "Max # of chatters: ",num
endif
print
joined$ = name$ +" has joined."
send net message string 0,joined$
print joined$
print
` Start loop
do

   gosub _recieve
   gosub _write

loop

` Recieve and Print Text
_recieve:

if net message exists()=1
   get net message
   if net message type()=3
      incoming$ = net message string$()
      print incoming$
   endif
endif

return
` End of recieve

` Write message
_write:

input name$ +" says: ", say$
send$ = name$ +" says: "+ say$
send net message string 0, send$

return
` End of Writing

` End program
end