TGC Codebase Backup



Chat Room by BMacZero

3rd May 2006 20:44
Summary

Very simple chat program



Description

Easy to understand, easy to use. Includes a password and an (unused) subroutine to check to see how many players there are. Send strings to any other player who is logged in.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    `disable escapekey
set window title "Chat!"
trya:
print "Chat"
print " "
Input "  Name: ",name$
Input "  Password: ",pass$
if pass$="42"
   gosub start
   else gosub wrong
endif

wrong:
cls
print "Chat"
print " "
print "Wrong password!"
print " "
gosub trya

start:
cls
IF NET GAME EXISTS()=1
   JOIN NET GAME 1,name$
   else CREATE NET GAME "chat",name$,200,2
endif
joined$ = name$ +" has joined."
send net message string 0,joined$
print joined$
gosub main

main:
gosub checkppl
print "Press spacebar to send a message"
do
if NET MESSAGE EXISTS()=1
   GET NET MESSAGE
   if net message type()=3
      incoming$ = net message string$()
   endif
endif
if spacekey()=1 then gosub write
loop


checkppl:
open to write 1,"Checklist.txt"
perform checklist for net players
for t=1 to checklist quantity()
write string 1,checklist string$(t)
next t
return

write:
print " "
Print "Sorry, the backspace key does not work yet."
input "Type Message: ",sendout$
send net message string 0,sendout$
return