My Mud Project: As Is

Miscellaneous Forums/Blitz Showcase/My Mud Project: As Is

Nowhere near finished, and with the baby, the fiancee and the two step kids now i haven't had much time to work on it. but heres my latest code. I have a few functions to add in, but oh well. Theres a few semi-big changes i have to make, and its a little sloppy, what do you think so far??

Lots more work to do: Currently 1047 lines!

AppTitle "MDB MUD DEMO-1"
Graphics 400,300,16,3
Color 0,0,255
Global server
Global ckn
Global dir
Dim pl.player(1000);maxplayers from config.dat
Global ucount#
Ucount#=0
Global x
Const north=1
Const south=2
Const east=3
Const west=4
Const ne=5
Const mw=6
Const se=7
Const sw=8
Const up=9
Const down=10

Dim gColor$(19)
 gColor$ (0)="" ;set to default w/black background
 gColor$ (1)="" ;bright
 gColor$ (2)="" ;Underline
 gColor$(3)="" ;Blinkies
 gColor$ (4)=""   ;reverse
 gColor$ (5)="";	Dark Red
 gColor$ (6)="";	Default Green Necc??
 gColor$ (7)="";	Brown
 gColor$ (8)="";	Dark blue
 gColor$ (9)="";	Dark Purple
 gColor$ (10)="";	Dark Cyan(teal)
 gColor$ (11)="";	 light grey/light white
 gColor$(12)="" ;Grey
 gColor$(13)="";Bright Red
 gColor$(14)="";Bright green
 gColor$(15)="";Bright Yellow
 gcolor$(16)=""; Bright Blue
 gcolor$(17)=""; Bright Purple
 gcolor$(18)="";Bright cyan
 gcolor$(19)="";Bright White
Const Menu=1
Const NewChar1=2
Const NewChar2=3
Const Newchar3=4
Const Newchar4=5
Const PlayChar1=6
Const PlayChar2=7
Const Playing=8
Const Logoff=9
Const VwHelp=10
Const SelSex=11
Const SelRace=12
Const SelClass=13

Print "MDB-MUD Demo Version 1**************
Print "Programmed in Blitz Basic! ************"
Print "Written by Michael D. Boruta II*******"
Print "*******************************"

server=CreateTCPServer(4000)
If Not server Then
Print "Server Failed to start on port 4000!"
Print "terminating Program!...sorry!"
Delay 1000
End
Else
Print "Server started! Telnet to port 4000 to play!"
Print "*Now Listening for *Connections**"
Print "Hit the ESCAPE KEY to Shutdown MDB-MUD!"
EndIf

;eLoadAreas

a=0
areafile=OpenFile("c:\mdbmud\areas.dat")

If areafile Then
While Not Eof(areafile)
b$=ReadLine(areafile)
;Print b$+"file found"
a=a+1
Wend
CloseFile(areafile)
Else
Print "Areas.dat not found, terminating program"
Delay 5000
End
EndIf
Print a
Dim area.area(a)
If a=>1 Then
c=1

areafile=OpenFile("c:\mdbmud\areas.dat")
;get Each areas name

While Not Eof(areafile)
b$=ReadLine(areafile)
Print "File name found: "+b$
area(c)=New area
area(c)\areaname$=b$
area(c)\areanumber=c
c=c+1
Wend

CloseFile(areafile)
d=c-1
For x=1 To d Step 1 
Print x
c=1
afile$=area(x)\areaname$+".dat"
curr_file=OpenFile("c:\mdbmud"+afile$)
If curr_file Then
While Not Eof(curr_file)
b$=ReadLine(curr_file)
;Print x
area(x)\ro[c]=New room
area(x)\ro[c]\roomarea=x
area(x)\ro[c]\roomname$=b$
area(x)\ro[c]\roomnumber=c
area(x)\ro[c]\also$="Nobody";remove/replace when add in alsoheres!!!
b$=ReadLine(curr_file)
;Print "Rcolor="+b$
area(x)\ro[c]\rcolor=b$
For y=1 To 10
b$=ReadLine(curr_file)
;Print "Exit# "+y+" is "+b$
;if b$<>0 then
area(x)\ro[c]\roo[y]=New RExit
area(x)\ro[c]\roo[y]\ExitTo=b$
area(x)\ro[c]\roo[y]\ExitArea=1 ;change to allow for cross area exits
;EndIf
Next 
b$=ReadLine(curr_file)
;Print "exits$="+b$
area(x)\ro[c]\Exits$=b$
b$=ReadLine(curr_file)
c=c+1
Wend
EndIf
CloseFile(curr_file)
;Print "Loaded Area #"+x+" named: "+area(x)\areaname$
Next 
EndIf


Delay 200
;For ak.area=Each area
;Print ak\areaname$+"  -#"+ak\areanumber
;Next
;For rkx.room=Each room
;Print rkx\roomname$+"room number# "+rkx\roomnumber
;Next
;For rex.rexit=Each rexit
;Print rex\exitto +"<exitto - exitarea>"+rex\exitarea
;Next
;WaitKey()


;add loadrace
;add loadclass
;add loadmob
;add loadobjects

ckn=0
While Not KeyHit(1)
ckn=ckn+1
If ckn>200 Then
checknew
ckn=0
EndIf

readstream
;add tickcounter
;add regen/repop/hunger-thirst modifiier
;add weather
;Delay 100
Wend

Function checknew()
stream=AcceptTCPStream(server)
If stream Then
Print "*CONNECTION RECIEVED!*"
ucount#=ucount+1
x=ucount#
pl (x)=New Player
pl (x)\name$="Logon........................................................................................."
pl (x)\stream=stream
pl (x)\status=Menu
pl (x)\prace$="None"
pl (x)\pclass$="None"
pl(x)\sex$="None"
pl (x)\comm1$=""
pl (x)\comm2$=""
pl (x)\comm3$=""
pl (x)\comm4$=""
pl (x)\msg$=""
pl (x)\comm=1
pl (x)\PlayerId=x
For abc=0 To 19 Step 1
pl(x)\pc$[abc]=gcolor$(abc)
Next

;WriteLine pl (x)\stream, "X="+x+"Ucount="+ucount#+"name$="
;p.player=New Player
;p\name$="Logon........................................................................................."
;p\stream=stream
;p\status=Menu
;p\prace$="None"
;p\pclass$="None"
;p\comm1$=""
;p\comm2$=""
;p\comm3$=""
;p\comm4$=""
;p\msg$=""
;p\comm=1
WriteLine pl(x)\stream, Chr$(27)+"Welcome To MDB MUD!!!!"
WriteLine pl(x)\stream, "Initiating Color Test!"
For jk=0 To 18 Step 1
WriteLine pl(x)\stream, gColor$(jk)+"This is what color$("+jk+") does!"+""
Next

WriteLine pl(x)\stream, ""
DisplayMenu pl(x)
EndIf
End Function

Function readstream()
;Print "Case ReadStream  "+ucount#
For p.player=Each player
;Print p\name$+p\playerId
If Eof(p\stream) Then
p\status=Logoff
Else
If ReadAvail(p\stream) commandreader p
EndIf
If p\status=Logoff Logoff p
Next
End Function

Type player
Field pc$[20]
Field stream
Field PlayerId
Field status
Field level
Field name$
Field password$
Field curr_area
Field curr_room
Field recallArea
Field recallRoom
Field title$
Field pclass$
Field prace$
Field pracenumber ;?
Field pclassnumber;?
Field sex$
Field comm
Field comm1$
Field comm2$
Field comm3$
Field comm4$
Field msg$
Field experience#
Field baseexp#
Field exptnl#
End Type


Type area
Field areaname$
Field areanumber
Field ro.room[1000]
Field weather
End Type

Type room
Field roomname$
Field roomnumber
Field roomarea
Field Rcolor
Field roo.Rexit[11]
Field Exits$
Field Also$
Field ro2.alsohere[100]
Field ro3.lyinghere[100]
Field RoomLight
End Type

Type Rexit
Field Exitto
Field Exitarea
End Type

Type alsohere
Field Alsoname$
Field AlsoType
End Type

Type lyinghere
Field lyingname$
Field LyingType
End Type


Function commandreader(p.player)
x=p\comm
While ReadAvail(p\stream)
b=ReadByte(p\stream)
If b=32 Then 
If x=5 p\msg$=p\msg$+Chr$(32)
Select True
Case p\comm=1
	If p\comm1$<>"" Then
	p\comm=2 
	 x=x+1
	EndIf
Case p\comm=2
	If p\comm2$<>"" Then
	p\comm=3 
	 x=x+1
	EndIf
Case p\comm=3
	 If p\comm3$<>"" Then
	 p\comm=4 
	 x=x+1
	EndIf
Case p\comm=4
	If p\comm4$<>"" Then
	p\comm=5
	 x=x+1
	EndIf
End Select
EndIf

;if b=34  " And comm=2  And p\comm2$=""Then skip add quotes
;if chr$=" and comm=2 and p\comm2$<>"" then comm=3, next comm$
If x>5 x=5
If b>32 Then
If x=1 p\comm1$=p\comm1$+Chr$(b)
If x=2 p\comm2$=p\comm2$+Chr$(b)
If x=3 p\comm3$=p\comm3$+Chr$(b)
If x=4 p\comm4$=p\comm4$+Chr$(b)
If x=5 p\msg$=p\msg$+Chr$(b)
EndIf
If b=13 selectstatus p
Wend

End Function
Function Gossip(p.player)
	For a.player=Each player
	If a\name$=p\name$ Then
	WriteLine p\stream, "You gossip: "+p\comm2$+" "+p\comm3$+" "+p\comm4$+Chr$(32)+p\msg$
	Else
	WriteLine a\stream, p\name$+" gossips: "+p\comm2$+" "+p\comm3$+" "+p\comm4$+Chr$(32)+p\msg$
	EndIf
	Next
End Function

Function DisplayMenu(p.player)
 	WriteLine p\stream, ""
	WriteLine p\stream, ""
	WriteLine p\stream, ""
	WriteLine p\stream, "             Main Menu:"
	WriteLine p\stream, "             *********************"
	WriteLine p\stream, "             *                   *"
	WriteLine p\stream, "             * (P)lay Character  *"
	WriteLine p\stream, "             *                   *"
	WriteLine p\stream, "             * (N)ew Character   *"
	WriteLine p\stream, "             *                   *"
	WriteLine p\stream, "             * (W)hos Online     *"
	WriteLine p\stream, "             *                   *"
	WriteLine p\stream, "             * (V)iew Helpfiles  *"
	WriteLine p\stream, "             *                   *"
	WriteLine p\stream, "             *********************"
	WriteLine p\stream, "             *                   *"
	WriteLine p\stream, "             * Your Command:___  *"
	WriteLine p\stream, "             *                   *"
	WriteLine p\stream, "             *********************"
	WriteLine p\stream, "  "
	WriteLine p\stream, "Only New Char works right now...btw"
End Function

Function SelectStatus(p.player)
	Select True
	Case p\status=Playing
	playing p
	Case p\status=Menu 
	Menu p
	Case p\status=NewChar1
	 SelectName p
	Case p\status=NewChar2
	 SelectPassword p
	Case p\status=NewChar3 
	VerifyPassword p
	Case p\status=PlayChar1
	 ValidateName p
	Case p\status=Playchar2 
	Validatepassword p
	Case p\status=Selsex
	SelectSex p
	Case p\status=SelRace
	SelectRace p
	Case p\status=SelClass
	selectclass2 p
	End Select
	If p\stream Then
	p\msg$=""
	p\comm=1
	p\comm1$=""
	p\comm2$=""
	p\comm3$=""
	p\comm4$=""
	p\msg$=""
	EndIf
End Function

Function SelectSex(p.player)
;j=Len(p\comm1$)
;Print j+j+j
;If j>1 Then
;command$=Left$(p\comm1$,2)
;EndIf
comx$=p\comm1$
comx$=Lower(comx$)
j=Len(comx$)
If j>1 Then comx$=Left$(comx$,1)
;Print comx$
;Print comx$+":"+command$+"p\comm$="+p\comm1$
;WriteLine p\stream, "command:  "+comx$
If comx$="m" Then 
WriteLine p\stream, "Male Selected!"
p\sex$="Male"
p\status=SelRace
DisplayRace p
EndIf
If comx$="f" Then
WriteLine p\stream, "Female Selected"
p\sex$="Female"
p\status=SelRace
DisplayRace p
EndIf
If p\sex$="None" Then
WriteLine p\stream, "You can only be female, or male, please select again"
EndIf
End Function

Function Playing(p.player)
x=0
command$=p\comm1$
command$=Lower$(command$)

n#=Len(command$)

Select True

Case command$=""
;replace area annd ro and roo
	WriteLine p\stream, area(p\curr_area)\ro[p\curr_room]\roomname$
	WriteLine p\stream, area(p\curr_area)\ro[p\curr_room]\exits$
	;WriteLine p\stream, area(p\curr_area)\ro[p\curr_room]\Ralso$
	x=1
Case command$="save"
	saveplayer p
	x=1
Case command$=Left$("title",n#) And n#>2
	ntitle$=""
	If p\comm2$<>"" ntitle$=ntitle$+p\comm2$
	If p\comm3$<>"" ntitle$=ntitle$+" "+p\comm3$
	If p\comm4$<>"" ntitle$=ntitle$+" "+p\comm4$
	If p\msg$<>"" ntitle$=ntitle$+" "+p\msg$
	;ntitle$=p\comm2$+" "+p\comm3$+" "+p\comm4$+" "+p\msg$
	;Print "ntitle$: "+ntitle$
	n#=Len(ntitle$)
	If n#>36 Then 
	ntitle$=Left$(ntitle$,36)
	EndIf
	p\title$=ntitle$
	;Print "p\title$"+p\title$
	If p\title$<>"" Then
	WriteLine p\stream, "You will be known as "+p\name$+" "+p\title$
	Else
	p\title$=""
	WriteLine p\stream, "You will be known as "+p\name$+" the nameless one!"
	EndIf
	x=1
	Case command$="area"
		;WriteLine p\stream, "You are in: "+area(p\curr_area)\areaname$+"  Area#"+p\curr_area
		;WriteLine p\stream, "Room number "+p\curr_room+"  "+area(x)\ro[p\curr_room]\roomname$
		x=1

Case command$="quit"
	p\status=Logoff
	x=1
Case command$="who"
	wholist p
	x=1
Case command$=Left$("recall",n#)
	p\curr_room=1
	WriteLine p\stream, "You recall back to Town Sqaure"
	x=1
	;add default to home recall/town sqaure
Case command$=Left$("help",n#)
	WriteLine p\stream, "Sorry, no Helpfiles have been added yet *sniff*"
	x=1
Case command$=Left$("gossip",n#) 
	gossip p
	x=1
Case command$=Left$("look",n#) 
	Case command$=Left$("look",n#) 
	WriteLine p\stream, "You look around...."
	x=1
	WriteLine p\stream, area(p\curr_area)\ro[p\curr_room]\roomname$
	WriteLine p\stream, "Exits: "+area(p\curr_area)\ro[p\curr_room]\exits$
	;WriteLine p\stream, areas(p\curr_area)\ro[p\curr_room]\Ralso$
Case command$=Left$("whois", n#) And n#>3
	commx2$=Lower(p\comm2$)
	Print commx2$
	k#=Len(commx2$)
	Print k#
	If k#>2 Then
	WriteLine p\stream, "Players found:"
	abc=0
	For plk.player=Each player
	namex$=Left$(plk\name$,k#)
	namex$=Lower(namex$)
	If commx2$=namex$ Then
	WriteLine p\stream, plk\name$+" "+plk\prace$+" "+plk\pclass$
	abc=abc+1
	EndIf
	Next
	WriteLine p\stream, "Players Found= "+abc
	Else
	WriteLine p\stream, "You must enter the first three letters of their name!"
	EndIf
	x=1
Case command$=Left$("tell",n#) And n#>1
	If p\comm3$<>"" Then
	sentmsg$=p\comm3$+" "+p\comm4$+" "+p\msg$
	Print sentmsg$
	commx2$=Lower(p\comm2$)
	Print commx2$
	K#=Len(commx2$)
	Print K#
	ck=0
	If K#>2 Then
	For plk.player=Each player
	namex$=Left$(plk\name$,k#)
	namex$=Lower(namex$)
	If commx2$=namex$ Then
	ck=1
	WriteLine p\stream, "You tell "+plk\name$+" "+Chr$(34)+sentmsg$+Chr$(34)
	WriteLine plk\stream, p\name$+" telepaths you "+plk\pc[11]+Chr$(34)+sentmsg$+Chr$(34)+" "+p\pc$[0];+add color/reset color at end
	EndIf
	Next
	If ck=0 WriteLine p\stream, commx2$+" could not be reached!"
	Else
	WriteLine p\stream, "You must include 3 or more letters of their name!"
	EndIf
	Else
	WriteLine p\stream, "You can't send them a blank line!"
	EndIf
	x=1
;end all commands******************************************

Case command$=Left$("color",n#) And n#>1
	x=1
	If p\pc$[0]="" Then
	For gc=0 To 19 Step 1
	p\pc$[gc]=gcolor$(gc)
	Next
	WriteLine p\stream, "COLORS ACTIVATED"
	Else
	For gc=0 To 19 Step 1
	p\pc$[gc]=""
	Next
	WriteLine p\stream, "COLORS DISABLED"
	EndIf

Case command$=Left$("cast",n#)
	x=1
	a=0
	o=Len(p\comm2$) 
	If o=0 Then 
	o=1
	WriteLine p\stream, "Cast What? You need to speak words silly!"
	a=1:x=1
	EndIf
	If p\comm2$=Left$("fireball",o) Then
	WriteLine p\stream, "Your fireball "+gcolor$(13)+"***DEVESTATES***"+gcolor$(0)+" someone!!!"
	a=1:x=1
	EndIf
	If  p\comm2$=Left$("gate",o) Then 
	WriteLine p\stream, "You attempt to gate out but fail!"
	a=1:x=1
	EndIf
	If p\comm2$="" Then
	WriteLine p\stream, "Cast what silly? You must specify a spell...."
	EndIf
	If a=0 Then WriteLine p\stream, "You don't know the spell "+p\comm2$
	Case command$=Left$("north",n#)
	DIR=1
	moveplayer p
	Case command$=Left$("south",n#)
	DIR=2
	moveplayer p
	Case command$=Left$("west",n#)
	DIR=3
	moveplayer p
	Case command$=Left$("east",n#)
	DIR=4
	moveplayer p
	Case command$=Left$("northeast",n#) And n#>5
	DIR=5
	moveplayer p
	Case command$=Left$("northwest",n#) And n#>5
	DIR=6
	moveplayer p
	Case command$="ne"
	DIR=5
	moveplayer p
	Case command$="nw"
	DIR=6
	moveplayer p
	Case command$=Left$("southeast",n#) And n#>5
	DIR=7
	moveplayer p
	Case command$=Left$("southwest",n#) And n#>5
	DIR=8
	moveplayer p
	Case command$="se"
	DIR=7
	moveplayer p
	Case command$="sw"
	DIR=8
	moveplayer p
	Case command$=Left$("up",n#)
	DIR=9
	moveplayer p
	Case command$=Left$("down",n#)
	DIR=10
	moveplayer p
	
	End Select
	If x<>1 Then WriteLine p\stream, "Sorry, that command does not exist"	
End Function

Function Menu(p.player)
If p\comm1$<>"" Then
command$=Left(p\comm1$,1)
EndIf
If command$="n" Then
WriteLine p\stream, "Please choose your name:  "
p\status=NewChar1
EndIf
If command$="w" wholist p
If command$="v" Then
WriteLine p\stream,  "Sorry no helpfiles have been added yet!"
EndIf
If command$="p" Then
WriteLine p\stream,  "What is your characters name?  "
p\status=Playchar1
EndIf
End Function

Function SelectName(p.player)
x=1
name$=p\comm1$
name$=Lower(name$)
j#=Len(name$)
j#=j#-1
temp$=Right$(name$,j#)
ka$=Left$(name$,1)
ka$=Upper(ka$)
p\name$=ka$+temp$
n=Len(p\name$)
;RemCheck Pfile Already Exists
cfile$=p\name$+".dat"
curr_file=OpenFile("c:\mdbmud"+cfile$)
If curr_file
WriteLine p\stream, "Sorry That Name Is Already Taken...Try again"
x=0
Else
If n<3 Then
x=0
WriteLine p\stream, "Sorry, your name must be at least 3 characters long...please try again"
EndIf
If n>15 Then
x=0
WriteLine p\stream, "Sorry, your name must be 15 or less characters in length...please try again"
EndIf
If curr_file<>0  CloseFile(curr_file)
EndIf

If x=1 Then
WriteLine p\stream, "Welcome  to MDB MUD!!!"+p\name$
Print p\name$+" has logged on!!!"
WriteLine p\stream, "What password would you like?  "
p\status=NewChar2

EndIf
End Function

Function SelectPassword(p.player)
n=Len(p\comm1$)
If n<3 Then 
WriteLine p\stream, "sorry your password must have at least 3 letters, please reenter"
WriteLine p\stream, "Password?:  "
p\comm1$=""
EndIf
If n>15 Then
p\comm1$=""
WriteLine p\stream, "sorry, you4r password must be less then 15 characters, please reenter"
WriteLine p\stream, "Password?:  "
EndIf
If p\comm1$<>"" Then
p\password$=p\comm1$
WriteLine p\stream,  "Please Verifty that your password is:  "+p\password$+"!"
p\status=NewChar3
EndIf
End Function

Function VerifyPassword(p.player)
;add min 3 chars, max 12 characters and no spaces
If p\comm1$=p\password$ Then
WriteLine p\stream,"Password Verified...."
WriteLine p\stream, ""
WriteLine p\stream, "Are you male or female? "
p\status=SelSex
Else
WriteLine p\stream, "Sorry the passwords did not match, please try again!"
p\password$=""
p\status=NewChar2
WriteLine p\stream, "Please try another password:"
EndIf
End Function

Function Validatename(p.player)
k=1
xcomm1$=Lower(p\comm1$)
For pk.player=Each player
name$=Lower(pk\name$)
If name$=xcomm1$ Then
k=2
Exit
EndIf
Next
name$=xcomm1$

Print name$+"  k="+K
If k=2 Then
WriteLine p\stream, "Sorry, "+xcomm1$+" is already playing"
displaymenu p
p\status=MENU
Else 
cfile$=xcomm1$+".dat"
;cfile$=Lower(cfile$)
curr_file=OpenFile("c:\mdbmud"+cfile$)
If curr_file Then
d$=ReadLine(curr_file)
p\password$=d$
Print d$+"xx"
WriteLine p\stream, "Password? "
p\status=PLAYCHAR2
tname$=p\comm1$
j#=Len(tname$)
j#=j#-1
temp$=Right$(tname$,j#)
ka$=Left$(tname$,1)
ka$=Upper(ka$)
p\name$=ka$+temp$
Else
WriteLine p\stream, p\comm1$+" was not found as a player, please try again"
displayMenu p
p\status=MENU
EndIf
EndIf
If curr_file CloseFile(curr_file)
End Function

Function Validatepassword(p.player)
If p\comm1$=p\password$ Then
WriteLine p\stream, "Password Verified"
WriteLine p\stream, "Welcome Back "+p\name$
Print p\name$+" has Logged! on"
p\status=PLAYING
startup p
Else
WriteLine p\stream, "Password Incorrect, please try again!"
WriteLine p\stream, "    "
p\status=MENU
p\name$="LOGON...................................................."
p\password$=""
displaymenu p
EndIf
End Function

Function Startup(p.player)
	p\curr_room=1
	p\curr_area=1
	WriteLine p\stream, "This is a test server, Races,Classes, Areas, etc are not in yet"
	WriteLine p\stream, "The following commands are in:"
	WriteLine p\stream, "quit recall who gossip title look* help* cast* (fireball/gate try)" 
	WriteLine p\stream, "Look,Help, and cast are not complete either"
	WriteLine p\stream, "Please enjoy the game, hopefully will soon be completed"
	WriteLine p\stream, "New areas, etc etc will always be added...Thank you for playing!"
	;WriteLine p\stream, "You Are in: "+areas(p\curr_area)\areaname$
	;WriteLine p\stream, "You are standing in: "+areas(p\curr_area)\ar [p\curr_room]\roomname$
	;WriteLine p\stream, areas(p\curr_area)\ar [p\curr_room]\Rexits$
	;WriteLine p\stream, areas(p\curr_area)\ar [p\curr_room]\RAlso$
End Function

Function logoff(p.player)
	;If not Eof(p\stream)
	;Print p\name$+" has logged off!"
	;WriteLine p\stream, "GOODBYE!...come back soon!"
	;EndIf
	;CloseTCPStream(p\stream)
	;Delete p
	;rem end first start
	If Not Eof(p\stream)
	Print p\name$+" has logged off!"
	WriteLine p\stream, "GOODBYE!...come back soon!"
	CloseTCPStream(p\stream)
	EndIf
	jhk=p\playerID
	;Print "player id deleteing: "+jhk
	For x=1 To ucount# Step 1
	If pl(x)\playerid>jhk Then
	k=x-1
	stream=pl(x)\stream
	pl (k)\stream=stream
	;Print "player_id"+pl(x)\playerID+" larger Then A!="+a
	pl(k)\playerid=pl(x)\PlayerId-1
	pl(k)\status=pl(x)\status
	pl(k)\level=pl(x)\level
	pl(k)\name$=pl(x)\name$
	pl(k)\password$=pl(x)\password$
	pl(k)\password$=pl(x)\Curr_Area
	pl(k)\curr_room=pl(x)\curr_room
	pl(k)\title$=pl(x)\title$
	pl(k)\pclass$=pl(x)\pclass$
	pl(k)\prace$=pl(x)\prace$
	pl(k)\pracenumber=pl(x)\pracenumber ;?
	pl(k)\pclassnumber=pl(x)\pclassnumber;?
	pl(k)\sex$=pl(x)\sex$
	pl(k)\comm=pl(x)\comm
	pl(k)\experience#=pl(x)\experience#
	pl(k)\baseexp#=pl(x)\baseexp#
	pl(k)\exptnl#=pl(x)\exptnl#
	EndIf
	Next
	;Print "Deleting player# "+ucount#
	Delete pl(ucount#)
	ucount#=ucount#-1
	;Print "End Logoff"
End Function

Function Wholist(p.player)
	WriteLine p\stream, "Players found:"
	c#=0
	For a.player=Each player
	c#=c#+1
	WriteLine p\stream, "Level: "+p\level+"   "+a\name$+"   "+a\title$+"    "+a\playerID
	Next
	WriteLine p\stream, "Total players found:  "+c#
	WriteLine p\stream, "Total players online:  "+ucount#
End Function


Function SelectRace(p.player)
x=0
If p\comm1$="1" Then 
WriteLine p\stream, "You are now Human"
x=1
p\prace$="Human"
p\status=SelClass
EndIf
If p\comm1$="2" Then
 WriteLine p\stream, "You are now an Ogre"
x=1
p\status=SelClass
p\prace$="Ogre"
EndIf
If p\comm1$="3" Then 
WriteLine p\stream, "You are now an Elf"
x=1
p\status=Selclass
p\prace$="Elf"
EndIf
If p\comm1$="4" Then
WriteLine p\stream, "You are now a Halfling"
x=1
p\status=Selclass
p\prace$="Halfling"
EndIf
If p\comm1$="5" Then
WriteLine p\stream, "you are now a Minotaur"
x=1
p\status=SelClass
p\prace$="Minotaur"
EndIf
WriteLine p\stream, " "
If x<>1 Then
WriteLine p\stream, "That is not a valid race, please try again..."
Else
DisplayClass p
EndIf
;WriteLine p\stream, "You are now a "+p\prace$
End Function

Function DisplayRace(p.player)
	WriteLine p\stream, " "
	WriteLine p\stream, "        1. Human"
	WriteLine p\stream, "        2. Ogre"
	WriteLine p\stream, "        3. ELf"
	WriteLine p\stream, "        4. Halfling"
	WriteLine p\stream, "        5. Minotaur"
	WriteLine p\stream, " "
End Function

Function SelectClass2(p.player)
	command$=p\comm1$
	x=0
	If command$="1" Then
	p\pclass$="Druid"
	x=1
	EndIf
	If command$="2" Then
	p\pclass$="Mystic"
	x=1
	EndIf
	If command$="3" Then
	p\pclass$="Mage"
	x=1
	EndIf
	If command$="4" Then
	p\pclass$="Bard"
	x=1
	EndIf
	If command$="5" Then
	p\pclass$="Rogue"
	x=1
	EndIf
	If x<>1 Then 
	p\baseexp#=1000
	p\exptnl#=p\baseexp#
	p\level=0
	WriteLine p\stream, "Sorry that is not a valid class, please choose again...."
	Else
	WriteLine p\stream, ""
	WriteLine p\stream, "You are now a "+p\pclass$
	p\curr_room=1
	p\curr_area=1
	WriteLine p\stream, "You are now playing
	p\status=playing
	p\experience#=0
	p\RecallArea=1
	p\RecallRoom=0
	p\curr_area=1
	p\curr_room=1
	startup p
	EndIf
End Function

Function DisplayClass(p.player)
	WriteLine p\stream, "The Following Classes are Available..."
	WriteLine p\stream, " "
	WriteLine p\stream, "          1. Druid"
	WriteLine p\stream, "          2. Mystic"
	WriteLine p\stream, "          3. Mage"
	WriteLine p\stream, "          4. Bard"
	WriteLine p\stream, "          5. Rogue"
	WriteLine p\stream, " "
	p\status=SelClass
End Function

Function SavePlayer(p.player)
	file$=p\name$+".dat"
	curr_file=OpenFile("c:\mdbmud"+file$)
	If Not curr_file Then
	DeleteFile("c:\mdbmud"+file$)
	Else
	CloseFile(curr_file)
	EndIf
	curr_file=WriteFile("c:\mdbmud"+file$)
	WriteLine curr_file,p\password$
	WriteLine curr_file,p\prace$
	WriteLine curr_file,p\pclass$
	CloseFile(curr_file)
	WriteLine p\stream, "Your Character has been Saved!"
	Print p\name$+" pfile has been saved!"
End Function

Function MovePlayer(p.player)
	abc=1 ;check for if room/area exist
	old_area=p\curr_area
	old_room=p\curr_room
	new_area=old_area
	;new_area=area(p\curr_area)\ro[p\curr_room]\roo[dir]\ExitArea
	;Print area(p\curr_area)\ro[p\curr_room]\roo[dir]\Exitto

	;new_room=area(p\curr_area)\ro[p\curr_room]\roo[dir]\Exitto
	;If area(new_area)=Null Then abc=2
	;If area(p\curr_area)\ro[p\curr_room]=Null Then abc=2
	;If abc=1 Then
	
	;print "area: "+p\curr_area+" room: "+p\curr_room+" direction:  "+dir
	If area(p\curr_area)\ro[p\curr_room]\roo[dir]\ExitArea<>0 Then
	p\curr_area=area(p\curr_area)\ro[p\curr_room]\roo[dir]\ExitArea
	Else
	abc=2
	EndIf
	If area(p\curr_area)\ro[p\curr_room]\roo[dir]\Exitto<>0 Then
	p\curr_room=area(p\curr_area)\ro[p\curr_room]\roo[dir]\Exitto
	Else
	abc=2
	EndIf
	;Print abc
	
	;check stance
	;check if in combat
	;check if enough mvs
	;write to old room
	;delete old alsohere
	;write to new room
	;add new alsohere
	;check for aggy mobs
	If abc=1 Then
	WriteLine p\stream, "walking......"
	WriteLine p\stream, area(p\curr_area)\ro[p\curr_room]\roomname$
	
	;WriteLine all.alsohere
	WriteLine p\stream, area(p\curr_area)\ro[p\curr_room]\exits$
	;WriteLine p\prompt$?
	x=1
	Else
	WriteLine p\stream, "there is no exit in that direction!"
	WriteLine p\stream, area(p\curr_area)\ro[p\curr_room]\exits$
	abc=1
	x=1
	EndIf
End Function


;selskill
;selspell
;loadpfile
;savepfile


What is it? :D

MUD = Multi User Dungeon.

I would take a look myself but I have my own projects to look after, but good luck in getting further with it :)

For what type of mud is this server?

For what type of mud is this server?


The brown stuff.


Ok, so it's late and I'm tired.

Its a text based mud server, like rom, diku, or merc. Never heard of them?

I have heard of them. But these usually have .are files. Yours is trying to load a .dat file, and I can't find any example for these.

[codebox][/codebox]

hehe, i wrote some code to load .are files a long time ago in Blitz2D, it does a semi mud server as well :) .. 1600 lines or so :)

This is REALLY old tho.


Const STATUS_MENU = 1
Const GET_NICK = 2
Const GET_PASSWORD = 3
Const NEW_NICK = 4
Const NEW_PASSWORD = 5
Const VERIFY_PASSWORD = 6
Const PLAYING = 10

Type AREA
	Field AREA_ID
	Field levels$
	Field maker$
	Field name$
End Type

Type MOBILE
	Field vnum
	Field keyword$[25]
	Field num_keywords
	Field short_desc$
	Field long_desc$[25]
	Field num_long_desc_lines
	Field desc$[100]
	Field num_desc_lines
	Field act_flags[25]
	Field num_act_flags
	Field affected_flags[25]
	Field num_affected_flags
	Field alignment
	Field level
	Field gold
	Field sex
End Type

Type OBJECTS
	Field vnum
	Field keyword$[25]
	Field num_keywords
	Field short_desc$
	Field long_desc$
	Field item_type
	Field extra_flags[25]
	Field num_extra_flags
	Field wear_flags[25]
	Field num_wear_flags
	Field value_0
	Field value_1
	Field value_2
	Field value_3
	Field weight
	Field has_e
	Field num_e
	Field has_a
	Field num_a
End Type

Type OBJECT_E
	Field vnum
	Field keyword$[25]
	Field num_keywords
	Field desc$[100]
	Field num_desc_lines
End Type

Type OBJECT_A
	Field vnum
	Field apply_type
	Field apply_value
End Type

Type ROOM
	Field vnum
	Field name$
	Field desc$[100]
	Field num_desc_lines
	Field room_flags[25]
	Field num_room_flags
	Field sector_type
	Field has_d
	Field num_d
	Field has_e
	Field num_e
End Type

Type ROOM_D
	Field vnum
	Field door_number
	Field desc$[100]
	Field num_desc_lines
	Field keyword$[25]
	Field num_keywords
	Field lock
	Field key
	Field to_room
End Type

Type ROOM_E
	Field vnum
	Field keyword$[25]
	Field num_keywords
	Field desc$[100]
	Field num_desc_lines
End Type

Type RESET
	Field command$
	Field value_0
	Field value_1
	Field value_2
	Field value_3
End Type

Type SHOP
	Field keeper
	Field trade_0
	Field trade_1
	Field trade_2
	Field trade_3
	Field trade_4
	Field profit_buy
	Field profit_sell
	Field open_hour
	Field close_hour
End Type

Type SPECIAL
	Field mob_vnum
	Field spec_fun$
End Type

Type HELP
	Field level
	Field keyword$[25]
	Field num_keywords
	Field help_text[250]
	Field num_help_text_lines
End Type

Type PLAYER
	Field stream
	Field status
	Field nick$
	Field password$
	Field room
	Field level
	Field class
	
	Field temp$
	Field command$
	Field comms$[25]
	Field num_comms
	
	Field space_loc
	Field btemp
End Type

Dim area_temp$(100000)

Dim nick_list$(1000,3)

Dim area$(100)

Global area_counter = 1

Global mobiles
Global objects
Global rooms
Global resets
Global shops
Global specials

Global player_enter_game

read_area("areas\midgaard.are")
read_area("areas\school.are")

check_doors()

Print "Loaded zone header."
Print "Loaded " + mobiles + " Mobs."
Print "Loaded " + objects + " Objects."
Print "Loaded " + rooms + " Rooms."
Print "Loaded " + resets + " Resets."
Print "Loaded " + shops + " Shops."
Print "Loaded " + specials + " Specials."

Global MUD = CreateTCPServer(4000)

If MUD = 0
	Print "SERVER NOT STARTED!"
	WaitKey
	End
Else
	Print "SERVER STARTED"
EndIf

;Global stream
Global the_nick$

While Not KeyDown(1)
	look_for_new_players
	
	update_players()
Wend

Function look_for_new_players()
	; Look for connections
	stream = AcceptTCPStream(MUD)
	If stream
		Print "CONNECTION RECEIVED FROM " + DottedIP(TCPStreamIP(stream)) + " ON " + CurrentDate$() + " AT " + CurrentTime$()
		p.PLAYER = New PLAYER
		p\stream = stream
		p\status = STATUS_MENU
	EndIf
End Function

Function game(p.PLAYER)
	If ReadAvail(p\stream)
		p\command$ = ReadLine(p\stream)
		
		parse_commands(p)
	EndIf
End Function

Function parse_commands(p.PLAYER)
	p\command$ = Lower(p\command$)
	p\space_loc = Instr(p\command$," ")

	If p\space_loc > 0
		; Get command, and split the rest
		p\comms$[1] = Left$(p\command$,p\space_loc - 1)
			
		p\command$ = Right$(p\command$,Len(p\command$) - p\space_loc)
			
		p\num_comms = p\num_comms + 1
				
		p\comms$[2] = p\command$
							
		Select p\comms$[1]
			Case "c","chat","gossip"
				For pp.PLAYER = Each player
					If pp\stream <> p\stream
						writetxt pp\stream,Chr$(10) + Chr$(13)
						WriteLine pp\stream,p\nick$ + " chats '" + p\comms$[2] + "'."
					Else
						WriteLine pp\stream,"You chat '" + p\comms$[2] + "'."
					EndIf
					
					writetxt pp\stream,"> "
				Next

			Default
				WriteLine p\stream,"What?"
				writetxt p\stream,"> "
		End Select
	Else
		p\num_comms = 0
		Select p\command$
			Case "n","north"
				For rd.room_d = Each room_d
					If rd\vnum = p\room
						If rd\door_number = 0
							p\room = rd\to_room
							Exit
						EndIf
					EndIf
				Next
				
				p\command$ = "look"
				parse_commands(p)
			Case "e","east"
				For rd.room_d = Each room_d
					If rd\vnum = p\room
						If rd\door_number = 1
							p\room = rd\to_room
							Exit
						EndIf
					EndIf
				Next
				
				p\command$ = "look"
				parse_commands(p)
			Case "s","south"
				For rd.room_d = Each room_d
					If rd\vnum = p\room
						If rd\door_number = 2
							p\room = rd\to_room
							Exit
						EndIf
					EndIf
				Next
				
				p\command$ = "look"
				parse_commands(p)
			Case "w","west"
				For rd.room_d = Each room_d
					If rd\vnum = p\room
						If rd\door_number = 3
							p\room = rd\to_room
							Exit
						EndIf
					EndIf
				Next

				p\command$ = "look"
				parse_commands(p)
			Case "u","up"
				For rd.room_d = Each room_d
					If rd\vnum = p\room
						If rd\door_number = 4
							p\room = rd\to_room
							Exit
						EndIf
					EndIf
				Next

				p\command$ = "look"
				parse_commands(p)
			Case "d","down"
				For rd.room_d = Each room_d
					If rd\vnum = p\room
						If rd\door_number = 5
							p\room = rd\to_room
						EndIf
					EndIf
				Next

				p\command$ = "look"
				parse_commands(p)
				
				
			Case "look"
				For r.room = Each room
					If r\vnum = p\room
						WriteLine p\stream,""
						WriteLine p\stream,r\name$
						For t = 1 To r\num_desc_lines
							WriteLine p\stream,r\desc$[t]
						Next
						WriteLine p\stream,""
						
						room_vnum = r\vnum
					EndIf
				Next
				
				p\temp$ = ""
				For rd.room_d = Each room_d
					If rd\vnum = room_vnum
						Select rd\door_number
							Case 0
								p\temp$ = p\temp$ + " north,"
							Case 1
								p\temp$ = p\temp$ + " east,"
							Case 2
								p\temp$ = p\temp$ + " south,"
							Case 3
								p\temp$ = p\temp$ + " west,"
							Case 4
								p\temp$ = p\temp$ + " up,"
							Case 5
								p\temp$ = p\temp$ + " down,"
						End Select
					EndIf
				Next
				
				p\temp$ = Left$(p\temp$,Len(p\temp$) - 1)
				p\temp$ = p\temp$ + "."
				p\temp$ = Trim(p\temp$)
				
				WriteLine p\stream,"Exits: " + p\temp$

				WriteLine p\stream,""
				
				writetxt p\stream,"> "

			Case "exits", "exit","doors"
				p\temp$ = ""
				For rd.room_d = Each room_d
					If rd\vnum = p\room
						Select rd\door_number
							Case 0
								p\temp$ = p\temp$ + " north,"
							Case 1
								p\temp$ = p\temp$ + " east,"
							Case 2
								p\temp$ = p\temp$ + " south,"
							Case 3
								p\temp$ = p\temp$ + " west,"
							Case 4
								p\temp$ = p\temp$ + " up,"
							Case 5
								p\temp$ = p\temp$ + " down,"
						End Select
					EndIf
				Next
				
				p\temp$ = Left$(p\temp$,Len(p\temp$) - 1)
				p\temp$ = p\temp$ + "."
				p\temp$ = Trim(p\temp$)
				
				WriteLine p\stream,"Exits: " + p\temp$

				WriteLine p\stream,""
				
				writetxt p\stream,"> "

			Case "wh,","who"
				nick_cnt = 1
				For pp.player = Each player
					nick_list$(nick_cnt,1) = pp\nick$
					nick_list$(nick_cnt,2) = "Unknown"
					nick_list$(nick_cnt,3) = pp\level

					nick_list$(nick_cnt,1) = LSet$(nick_list$(nick_cnt,1),16)
					nick_list$(nick_cnt,2) = LSet$(nick_list$(nick_cnt,2),10)
					nick_list$(nick_cnt,3) = RSet$(nick_list$(nick_cnt,3),3)
					
					nick_cnt = nick_cnt + 1
				Next
				nick_cnt = nick_cnt - 1

				WriteLine p\stream,"+------------------+"
				WriteLine p\stream,"| Who are online   |"
				WriteLine p\stream,"+------------------+------------+-------+"
				WriteLine p\stream,"| Name             | Class      | Level |"
				WriteLine p\stream,"+------------------+------------+-------+"
				
				For t = 1 To nick_cnt
					WriteLine p\stream,"| " + nick_list$(t,1) + " | " + nick_list$(t,2) + " |  " + nick_list$(t,3) + "  |"
				Next

				WriteLine p\stream,"+------------------+------------+-------+"
				WriteLine p\stream,""

				For t = 1 To nick_cnt
					nick_list$(t,1) = ""
					nick_list$(t,2) = ""
					nick_list$(t,3) = ""
				Next
				
				writetxt p\stream,"> "

			Case "areas"
				For t = 1 To area_counter
					WriteLine p\stream,area$(t)
				Next

				WriteLine p\stream,""

				writetxt p\stream,"> "


	
	
			Default
				WriteLine p\stream,"What?"
				writetxt p\stream,"> "
		End Select
	EndIf
End Function

Function writetxt(stream,txt$)
	For t = 1 To Len(txt$)
		ch$ = Mid$(txt$,t,1)
		WriteByte stream,Asc(ch$)
	Next
End Function

Function update_players()
	For p.PLAYER = Each PLAYER
		Select p\status
			Case STATUS_MENU
				                   ;12345678901234567890123456789012345678901234567890123456789012345678901234567890
				WriteLine p\stream,"                                                                                "
				WriteLine p\stream,"********   *******  ********  **     **                                         "
				WriteLine p\stream,"********* ********* ********* **    **                                          "
				WriteLine p\stream,"**     ** **     ** **     ** **   **                                           "
				WriteLine p\stream,"**     ** **     ** **     ** **  **                                            "
				WriteLine p\stream,"**     ** ********* ********  *****                                             "
				WriteLine p\stream,"**     ** ********* ********  *****                                             "
				WriteLine p\stream,"**     ** **     ** **     ** **  **                                            "
				WriteLine p\stream,"**     ** **     ** **     ** **   **                                           "
				WriteLine p\stream,"********* **     ** **     ** **    **                                          "
				WriteLine p\stream,"********  **     ** **     ** **     **                                         "
				WriteLine p\stream,"                                                                                "
				WriteLine p\stream," ******** **     **  *******   **    **  ********  ********* ********   ********"
				WriteLine p\stream,"********* **     ** ********* ****  **** ********* ********* ********* *********"
				WriteLine p\stream,"**        **     ** **     ** ** **** ** **     ** **        **     ** **       "
				WriteLine p\stream,"**        **     ** **     ** **  **  ** **     ** **        **     ** **       "
				WriteLine p\stream,"**        ********* ********* **  **  ** ********  *****     ********  ******** "
				WriteLine p\stream,"**        ********* ********* **  **  ** ********  *****     ********   ********"
				WriteLine p\stream,"**        **     ** **     ** **  **  ** **     ** **        **     **        **"
				WriteLine p\stream,"**        **     ** **     ** **      ** **     ** **        **     **        **"
				WriteLine p\stream,"********* **     ** **     ** **      ** ********* ********* **     ** *********"
				WriteLine p\stream," ******** **     ** **     ** **      ** ********  ********* **     ** ******** "
				WriteLine p\stream,"                                                                                "
				writetxt p\stream,"Player Name (NEW for new player) > "
	
				p\status = GET_NICK
			Case GET_NICK
				If ReadAvail(p\stream)
					the_nick$ = Lower(ReadLine(p\stream))
					
					Select the_nick$
						Case "NEW","new","New"
							p\status = NEW_NICK
						Default
							p\status = GET_PASSWORD

							For pp.PLAYER = Each PLAYER
								If Lower(pp\nick$) = Lower(the_nick$)
									WriteLine p\stream,"This player is already in the game!"
									p\status = STATUS_MENU
									p\btemp = False
								EndIf
							Next
					End Select
				EndIf
			Case NEW_NICK
				If p\btemp = False
					writetxt p\stream,"Enter a name > "
					p\btemp = True
				EndIf
				
				taken = False
				If ReadAvail(p\stream)
					name$ = Lower(ReadLine(p\stream))

					player_dir = ReadDir("players/")
					Repeat
						file$ = NextFile(player_dir)
							
						If file$ = name$
							WriteLine p\stream,"This name has already been taken, please select another."
							p\status = NEW_NICK
							p\btemp = False
							name$ = ""
							taken = True
							Exit
						EndIf
														
						If file$ = ""
							Exit
						EndIf
					Forever
						
					If taken = False
						p\nick$ = name$
		
						If Len(p\nick$) < 3
							WriteLine p\stream,"Name is too short, must be between 3 and 16 letters."
							p\status = NEW_NICK
							p\btemp = False
							Exit
						ElseIf Len(p\nick$) > 16
							WriteLine p\stream,"Name is too long, must be between 3 and 16 letters."
							p\status = NEW_NICK
							p\btemp = False
							Exit
						Else
							p\status = NEW_PASSWORD
							p\btemp = False
							Exit
						EndIf
					EndIf
				EndIf
			Case NEW_PASSWORD
				If p\btemp = False
					writetxt p\stream,"Enter a password > "
					p\btemp = True
				EndIf
							
				If ReadAvail(p\stream)
					pass$ = ReadLine(p\stream)
						
					If Len(pass$) < 5
						WriteLine p\stream,"Password is too short, must be 5 or more letters/numbers."
						p\status = NEW_PASSWORD
						p\btemp = False
						Exit
					Else
						p\password$ = pass$
						p\status = VERIFY_PASSWORD
						p\btemp = False
						Exit
					EndIf
				EndIf
			Case VERIFY_PASSWORD
				If p\btemp = False
					writetxt p\stream,"Enter the password again > "
					p\btemp = True
				EndIf
							
				If ReadAvail(p\stream)
					pass$ = ReadLine(p\stream)
						
					If p\password$ <> pass$
						WriteLine p\stream,"Passwords didn't match!"
							
						p\password$ = ""
						p\status = NEW_PASSWORD
						p\btemp = False
						Exit
					Else
						p\level = 1
						save_player(p)
						load_player(p)
						p\status = PLAYING
							
						For pp.PLAYER = Each PLAYER
							If pp\stream <> p\stream
								writetxt pp\stream,Chr$(10) + Chr$(13)
								WriteLine pp\stream,"Please welcome our new player " + p\nick$ + " to Dark Chambers!"
								WriteLine pp\stream,""
								writetxt pp\stream,"> "
							Else
								WriteLine pp\stream,"Welcome to Dark Chambers " + pp\nick$ + "!"
								WriteLine pp\stream,"We hope you have a good time here and, please, if you can't"
								WriteLine pp\stream,"figure something out, feel free to ask anyone!"
								WriteLine pp\stream,""
							EndIf
						Next

						; Force player to look
						p\command$ = "look"
						parse_commands(p)
						p\btemp = False													
						Exit
					EndIf
				EndIf
			Case GET_PASSWORD
				If p\btemp = False
					writetxt p\stream,"Enter your password > "
					p\btemp = True
				EndIf
							
				found = False
				If ReadAvail(p\stream)
					pass$ = ReadLine(p\stream)
						
					player_dir = ReadDir("players")
					Repeat
						file$ = NextFile(player_dir)

						If file$ = the_nick$
							pnick$ = file$
								
							f = OpenFile("players" + file$)
							ppass$ = ReadLine(f)
							CloseFile f
								
							found = True
							Exit
						EndIf
							
						If file$ = ""
							Exit
						EndIf
					Forever
					If found = False
						WriteLine p\stream,"Player not found!"
							
						p\status = STATUS_MENU
						p\btemp = False
						Exit
					Else
						If ppass$ = pass$
							p\nick$ = the_nick$
							load_player(p)
							p\status = PLAYING

							For pp.PLAYER = Each PLAYER
								If pp\stream <> p\stream
									writetxt pp\stream,Chr$(10) + Chr$(13)
									WriteLine pp\stream,p\nick$ + " has entered the realm!"
									WriteLine pp\stream,""
									writetxt pp\stream,"> "
								Else
									WriteLine pp\stream,"Welcome back to Dark Chambers, " + p\nick$ + "!"
									WriteLine pp\stream,""
								EndIf
							Next

							; Force player to look
							p\command$ = "look"
							parse_commands(p)
							p\btemp = False								
							Exit
						Else
							WriteLine p\stream,"Password is incorrect!"
							p\status = GET_PASSWORD
							p\btemp = False
							Exit
						EndIf
					EndIf
				EndIf
			Case PLAYING
				game(p)
		End Select
			
		; If player disconnects
		If Eof(p\stream)
			Print "DISCONNECTION FROM " + DottedIP(TCPStreamIP(p\stream)) + " ON " + CurrentDate$() + " AT " + CurrentTime$()
			CloseTCPStream(p\stream)
			Delete p
		EndIf
	Next
End Function

Function save_player(p.PLAYER)
	dir$ = "players"
	file = WriteFile(dir$ + Lower(p\nick$))
	WriteLine file,p\password$
	WriteLine file,p\level
	WriteLine file,"3001"
	WriteLine file,CurrentDate$()
	WriteLine file,CurrentTime$()
	WriteLine file,CurrentDate$()
	WriteLine file,CurrentTime$()
	CloseFile file
End Function

Function load_player(p.PLAYER)
	file = OpenFile("players" + Lower(p\nick$))
	dummy$ = ReadLine(file)
	p\level = ReadLine(file)
	p\room = ReadLine(file)
	CloseFile file
	
	temp$ = Upper(Left$(p\nick$,1))
	p\nick$ = Right$(p\nick$,Len(p\nick$) - 1)
	p\nick$ = temp$ + p\nick$
End Function

Function check_doors()
	For rd.ROOM_D = Each ROOM_D
		found = False
		For r.ROOM = Each ROOM
			If rd\to_room = r\vnum
				rn$ = r\name$
				rv$ = r\vnum
				found = True
				Exit
			EndIf
		Next

		If found = False
			Print "Vnum " + rd\to_room + " doesn't exist, door removed! (" + rv$ + "/" + rn$ + ")"
			Delete rd
		EndIf
	Next
End Function

Function read_area(file$)
	area_file = ReadFile(file$)
	are_cnt = 1
	While Not Eof(area_file)
		area_temp$(are_cnt) = ReadLine(area_file)
		are_cnt = are_cnt + 1
	Wend
	CloseFile area_file
	are_total_cnt = are_cnt - 1
	
	; AREA HEADER
	area_header$ = area_temp$(1)

	If Left$(area_header$,5) = "#AREA"
		area_header$ = Right$(area_header$,Len(area_header$) - 6)

		a.AREA = New AREA
		a\AREA_ID = area_counter
		a\levels$ = Left$(area_header$,7)
		area_header$ =	Right$(area_header$,Len(area_header$) - 8)
		a\maker$ = Left$(area_header$,7)
		area_header$ =	Right$(area_header$,Len(area_header$) - 8)
		a\name$ = Left$(area_header$,Len(area_header$) - 1)
		
		sl_loc = Instr(file$,"")
		larea$ = Right$(file$,Len(file$) - sl_loc)
		sl_loc = Instr(larea$,".")
		larea$ = Left$(larea$,sl_loc - 1)
		
		larea$ = Upper(Mid$(larea$,1,1)) + Right$(larea$,Len(larea$) - 1)
		
		area$(area_counter) = larea$
		
		area_counter = area_counter + 1
	Else
		Print "ERROR #1 - AREA HEADER NOT FOUND ON FIRST LINE OF AREA FILE!"
		Return False
	EndIf


	; AREA MOBILES
	mobiles_found = False
	For are_line_cnt = 1 To are_total_cnt
		If Left$(area_temp$(are_line_cnt),8) = "#MOBILES"
			mobiles_found = True
			mobiles_location = are_line_cnt + 1
			Exit
		EndIf
	Next
	If mobiles_found = True
		While Left$(area_temp$(mobiles_location),2) <> "#0"
			If Left$(area_temp$(mobiles_location),1) = "#"
				If Len(area_temp$(mobiles_location)) > 2
					m.MOBILE = New MOBILE
					; Read virtual number
					m\vnum = Right$(area_temp$(mobiles_location),Len(area_temp$(mobiles_location)) - 1)
					
					mobiles_location = mobiles_location + 1
					
					; Read keywords
					keyword = 1
					go = False
					While go = False
						space_loc = Instr(area_temp$(mobiles_location)," ")
						If space_loc = 0
							m\keyword$[keyword] = Left$(area_temp$(mobiles_location),Len(area_temp$(mobiles_location)) - 1)
							m\num_keywords = keyword
							
							go = True
						Else
							m\keyword$[keyword] = Left$(area_temp$(mobiles_location),space_loc - 1)
							area_temp$(mobiles_location) = Right$(area_temp$(mobiles_location),Len(area_temp$(mobiles_location)) - space_loc)
							
							keyword = keyword + 1
						EndIf
					Wend

					mobiles_location = mobiles_location + 1
					
					; Read short description
					m\short_desc$ = Left$(area_temp$(mobiles_location),Len(area_temp$(mobiles_location)) - 1)
					
					mobiles_location = mobiles_location + 1

					; Read long description
					ldesc = 1
					While Left$(area_temp$(mobiles_location),1) <> "~"
						m\long_desc$[ldesc] = area_temp$(mobiles_location)
						
						ldesc = ldesc + 1
						mobiles_location = mobiles_location + 1
					Wend
					m\num_long_desc_lines = ldesc - 1
					
					mobiles_location = mobiles_location + 1

					; Read Description
					desc = 1
					While Left$(area_temp$(mobiles_location),1) <> "~"
						m\desc$[desc] = area_temp$(mobiles_location)
						
						desc = desc + 1
						mobiles_location = mobiles_location + 1
					Wend
					m\num_desc_lines = desc - 1

					mobiles_location = mobiles_location + 1

					; Read act-flags, affected-flags and alignment
					num_act = 1
					num_affected = 1
					space_loc = Instr(area_temp$(mobiles_location)," ")
					; act-flags
					flags$ = Left$(area_temp$(mobiles_location),space_loc - 1)
					
					leave = False
					While leave = False
						If Instr(flags$,"|") > 0
							m\act_flags[num_act] = Left$(flags$,Instr(flags$,"|") - 1)
							
							flags$ = Right$(flags$,Len(flags$) - Instr(flags$,"|"))

							num_act = num_act + 1
						Else
							m\act_flags[num_act] = flags$
							m\num_act_flags = num_act
							leave = True
						EndIf
					Wend
											
					area_temp$(mobiles_location) = Right$(area_temp$(mobiles_location),Len(area_temp$(mobiles_location)) - space_loc)

					space_loc = Instr(area_temp$(mobiles_location)," ")
					; affected-flags
					flags$ = Left$(area_temp$(mobiles_location),space_loc - 1)

					leave = False
					While leave = False
						If Instr(flags$,"|") > 0
							m\affected_flags[num_affected] = Left$(flags$,Instr(flags$,"|") - 1)
							
							flags$ = Right$(flags$,Len(flags$) - Instr(flags$,"|"))

							num_affected = num_affected + 1
						Else
							m\affected_flags[num_affected] = flags$
							m\num_affected_flags = num_affected
							leave = True
						EndIf
					Wend

					area_temp$(mobiles_location) = Right$(area_temp$(mobiles_location),Len(area_temp$(mobiles_location)) - space_loc)
					
					space_loc = Instr(area_temp$(mobiles_location)," ")
					; alignment
					m\alignment = Left$(area_temp$(mobiles_location),space_loc - 1)
					
					area_temp$(mobiles_location) = Right$(area_temp$(mobiles_location),Len(area_temp$(mobiles_location)) - space_loc)

					mobiles_location = mobiles_location + 1

					; Read Level - Ignore the rest
					space_loc = Instr(area_temp$(mobiles_location)," ")
					m\level = Left$(area_temp$(mobiles_location),space_loc - 1)
					
					mobiles_location = mobiles_location + 1

					; Read gold - Ignore the rest
					space_loc = Instr(area_temp$(mobiles_location)," ")
					m\gold = Left$(area_temp$(mobiles_location),space_loc - 1)
					
					mobiles_location = mobiles_location + 1

					; Read sex - Ignore the rest
					m\sex = Right$(area_temp$(mobiles_location),1)

					mobiles = mobiles + 1
				EndIf
			EndIf
			
			mobiles_location = mobiles_location + 1
		Wend
	EndIf



	; AREA OBJECTS
	objects_found = False
	For are_line_cnt = 1 To are_total_cnt
		If Left$(area_temp$(are_line_cnt),8) = "#OBJECTS"
			objects_found = True
			objects_location = are_line_cnt + 1
			Exit
		EndIf
	Next
	If objects_found = True
		While Left$(area_temp$(objects_location),2) <> "#0"
			If Left$(area_temp$(objects_location),1) = "#"
				If Len(area_temp$(objects_location)) > 2
					o.OBJECTS = New OBJECTS
					; Read virtual number
					o\vnum = Right$(area_temp$(objects_location),Len(area_temp$(objects_location)) - 1)
					
					objects_location = objects_location + 1
					
					; Read keywords
					keyword = 1
					go = False
					While go = False
						space_loc = Instr(area_temp$(objects_location)," ")
						If space_loc = 0
							o\keyword$[keyword] = Left$(area_temp$(objects_location),Len(area_temp$(objects_location)) - 1)
							o\num_keywords = keyword
							
							go = True
						Else
							o\keyword$[keyword] = Left$(area_temp$(objects_location),space_loc - 1)
							area_temp$(objects_location) = Right$(area_temp$(objects_location),Len(area_temp$(objects_location)) - space_loc)
							
							keyword = keyword + 1
						EndIf
					Wend

					objects_location = objects_location + 1
					
					; Read short description

					o\short_desc$ = Left$(area_temp$(objects_location),Len(area_temp$(objects_location)) - 1)
					
					objects_location = objects_location + 1

					; Read Long Description and skip next
					o\long_desc$ = Left$(area_temp$(objects_location),Len(area_temp$(objects_location)) - 1)
					
					objects_location = objects_location + 1
					
					; Skip action desc, ignored
					While Left$(area_temp$(objects_location),1) <> "~"
						objects_location = objects_location + 1
					Wend
					
					objects_location = objects_location + 1
					
					; Read item type, extra flags and wear flags
					space_loc = Instr(area_temp$(objects_location)," ")
					; Item Type
					o\item_type = Left$(area_temp$(objects_location),space_loc - 1)

					area_temp$(objects_location) = Right$(area_temp$(objects_location),Len(area_temp$(objects_location)) - space_loc)

					num_extra = 1
					num_wear = 1
					
					; Extra Flags
					space_loc = Instr(area_temp$(objects_location)," ")

					flags$ = Left$(area_temp$(objects_location),space_loc - 1)
					
					leave = False
					While leave = False
						If Instr(flags$,"|") > 0
							o\extra_flags[num_extra] = Left$(flags$,Instr(flags$,"|") - 1)
							
							flags$ = Right$(flags$,Len(flags$) - Instr(flags$,"|"))

							num_extra = num_extra + 1
						Else
							o\extra_flags[num_extra] = flags$
							o\num_extra_flags = num_extra
							leave = True
						EndIf
					Wend
											
					area_temp$(objects_location) = Right$(area_temp$(objects_location),Len(area_temp$(objects_location)) - space_loc)
					
					flags$ = area_temp$(objects_location)

					leave = False
					While leave = False
						If Instr(flags$,"|") > 0
							o\wear_flags[num_wear] = Left$(flags$,Instr(flags$,"|") - 1)
							
							flags$ = Right$(flags$,Len(flags$) - Instr(flags$,"|"))

							num_wear = num_wear + 1
						Else
							o\wear_flags[num_wear] = flags$
							o\num_wear_flags = num_wear
							leave = True
						EndIf
					Wend

					objects_location = objects_location + 1

					; Read values
					space_loc = Instr(area_temp$(objects_location)," ")

					o\value_0 = Left$(area_temp$(objects_location),space_loc - 1)
					
					area_temp$(objects_location) = Right$(area_temp$(objects_location),Len(area_temp$(objects_location)) - space_loc)

					space_loc = Instr(area_temp$(objects_location)," ")

					o\value_1 = Left$(area_temp$(objects_location),space_loc - 1)
					
					area_temp$(objects_location) = Right$(area_temp$(objects_location),Len(area_temp$(objects_location)) - space_loc)

					space_loc = Instr(area_temp$(objects_location)," ")

					o\value_2 = Left$(area_temp$(objects_location),space_loc - 1)
					
					area_temp$(objects_location) = Right$(area_temp$(objects_location),Len(area_temp$(objects_location)) - space_loc)

					o\value_3 = area_temp$(objects_location)


					objects_location = objects_location + 1

					; Read weight					
					space_loc = Instr(area_temp$(objects_location)," ")

					o\weight = Left$(area_temp$(objects_location),space_loc - 1)
					
					objects_location = objects_location + 1

					die = False
					e_cnt = 0
					a_cnt = 0
					While die = False
						If Left$(area_temp$(objects_location),1) = "E"
							objects_location = objects_location + 1
							
							e_cnt = e_cnt + 1
							
							oe.OBJECT_E = New OBJECT_E
							; Link to object vnum
							oe\vnum = o\vnum
							
							; Read keywords
							keyword = 1
							go = False
							While go = False
								space_loc = Instr(area_temp$(objects_location)," ")
								If space_loc = 0
									oe\keyword$[keyword] = Left$(area_temp$(objects_location),Len(area_temp$(objects_location)) - 1)
									oe\num_keywords = keyword
									
									go = True
								Else
									oe\keyword$[keyword] = Left$(area_temp$(objects_location),space_loc - 1)
									area_temp$(objects_location) = Right$(area_temp$(objects_location),Len(area_temp$(objects_location)) - space_loc)
									
									keyword = keyword + 1
								EndIf
							Wend
		
							objects_location = objects_location + 1
							
							; Read Description
							desc = 1
							While Left$(area_temp$(objects_location),1) <> "~"
								oe\desc$[desc] = area_temp$(objects_location)
								
								desc = desc + 1
								objects_location = objects_location + 1
							Wend
							oe\num_desc_lines = desc - 1
						EndIf

						If Left$(area_temp$(objects_location),1) = "A"
							objects_location = objects_location + 1
							
							a_cnt = a_cnt + 1
							
							oa.OBJECT_A = New OBJECT_A
							; Link to object vnum
							oa\vnum = o\vnum
							
							space_loc = Instr(area_temp$(objects_location)," ")

							; Read apply type
							oa\apply_type = Left$(area_temp$(objects_location),space_loc - 1)
					
							area_temp$(objects_location) = Right$(area_temp$(objects_location),Len(area_temp$(objects_location)) - space_loc)

							oa\apply_value = area_temp$(objects_location)
						EndIf
						
						If Left$(area_temp$(objects_location),1) = "#"
							If e_cnt = 0
								o\has_e = False
								o\num_e = 0
							Else
								o\has_e = True
								o\num_e = e_cnt
							EndIf

							If a_cnt = 0
								o\has_a = False
								o\num_a = 0
							Else
								o\has_a = True
								o\num_a = a_cnt
							EndIf
							
							die = True
		
						EndIf

						objects_location = objects_location + 1
					Wend
					objects_location = objects_location - 2
													
					objects = objects + 1
				EndIf
			EndIf
			
			objects_location = objects_location + 1
		Wend
	EndIf

	; AREA ROOMS
	rooms_found = False
	For are_line_cnt = 1 To are_total_cnt
		If Left$(area_temp$(are_line_cnt),6) = "#ROOMS"
			rooms_found = True
			rooms_location = are_line_cnt + 1
			Exit
		EndIf
	Next
	If rooms_found = False
		Print "ERROR #4 - ROOMS NOT FOUND IN AREA FILE!"
		Return False
	Else
		While Left$(area_temp$(rooms_location),2) <> "#0"
			If Left$(area_temp$(rooms_location),1) = "#"
				If Len(area_temp$(rooms_location)) > 2
					r.ROOM = New ROOM
					
					; Read vnum
					r\vnum = Right$(area_temp$(rooms_location),Len(area_temp$(rooms_location)) - 1)
					
					rooms_location = rooms_location + 1

					; Read room name
					r\name$ = Left$(area_temp$(rooms_location),Len(area_temp$(rooms_location)) - 1)

					rooms_location = rooms_location + 1

					; Read description
					ldesc = 1
					While Left$(area_temp$(rooms_location),1) <> "~"
						r\desc$[ldesc] = area_temp$(rooms_location)
						
						ldesc = ldesc + 1
						rooms_location = rooms_location + 1
					Wend
					r\num_desc_lines = ldesc - 1
					
					rooms_location = rooms_location + 1

					; Read area number (ignored), room flags, sector_type
					
					space_loc = Instr(area_temp$(rooms_location)," ")

					; strip ignored area number
					area_temp$(rooms_location) = Right$(area_temp$(rooms_location),Len(area_temp$(rooms_location)) - space_loc)

					num_flags = 1
					space_loc = Instr(area_temp$(rooms_location)," ")
					; room_flags
					flags$ = Left$(area_temp$(rooms_location),space_loc - 1)
					
					leave = False
					While leave = False
						If Instr(flags$,"|") > 0
							r\room_flags[num_flags] = Left$(flags$,Instr(flags$,"|") - 1)
							
							flags$ = Right$(flags$,Len(flags$) - Instr(flags$,"|"))

							num_flags = num_flags + 1
						Else
							r\room_flags[num_flags] = flags$
							r\num_room_flags = num_flags
							leave = True
						EndIf
					Wend
					
					area_temp$(rooms_location) = Right$(area_temp$(rooms_location),Len(area_temp$(rooms_location)) - space_loc)

					; Sector Type
					r\sector_type = area_temp$(rooms_location)

					rooms_location = rooms_location + 1

					; Read D and E
					die = False
					d_cnt = 0
					e_cnt = 0
					While die = False
						If Left$(area_temp$(rooms_location),1) = "E"
							rooms_location = rooms_location + 1
							
							e_cnt = e_cnt + 1
							
							re.ROOM_E = New ROOM_E
							; Link to room vnum
							re\vnum = r\vnum
							
							; Read keywords
							keyword = 1
							go = False
							While go = False
								space_loc = Instr(area_temp$(rooms_location)," ")
								If space_loc = 0
									re\keyword$[keyword] = Left$(area_temp$(rooms_location),Len(area_temp$(rooms_location)) - 1)
									re\num_keywords = keyword
									
									go = True
								Else
									re\keyword$[keyword] = Left$(area_temp$(rooms_location),space_loc - 1)
									area_temp$(rooms_location) = Right$(area_temp$(rooms_location),Len(area_temp$(rooms_location)) - space_loc)
									
									keyword = keyword + 1
								EndIf
							Wend
		
							rooms_location = rooms_location + 1
							
							; Read Description
							desc = 1
							While Left$(area_temp$(rooms_location),1) <> "~"
								re\desc$[desc] = area_temp$(rooms_location)

								desc = desc + 1
								rooms_location = rooms_location + 1
							Wend
							re\num_desc_lines = desc - 1
						EndIf

						If Left$(area_temp$(rooms_location),1) = "D"
							d_cnt = d_cnt + 1
							
							rd.ROOM_D = New ROOM_D
							
							; link to room vnum
							rd\vnum = r\vnum
							; Get door number
							rd\door_number = Right$(area_temp$(rooms_location),1)
							
							rooms_location = rooms_location + 1
							
							; Read Description
							desc = 1
							While Left$(area_temp$(rooms_location),1) <> "~"
								rd\desc$[desc] = area_temp$(rooms_location)

								desc = desc + 1
								rooms_location = rooms_location + 1
							Wend
							rd\num_desc_lines = desc - 1

							rooms_location = rooms_location + 1

							; Read keywords
							keyword = 1
							go = False
							While go = False
								space_loc = Instr(area_temp$(rooms_location)," ")
								If space_loc = 0
									rd\keyword$[keyword] = Left$(area_temp$(rooms_location),Len(area_temp$(rooms_location)) - 1)
									rd\num_keywords = keyword
									
									go = True
								Else
									rd\keyword$[keyword] = Left$(area_temp$(rooms_location),space_loc - 1)
									area_temp$(rooms_location) = Right$(area_temp$(rooms_location),Len(area_temp$(rooms_location)) - space_loc)
									
									keyword = keyword + 1
								EndIf
							Wend							
							
							rooms_location = rooms_location + 1
							
							; Read lock, key, to_room
							space_loc = Instr(area_temp$(rooms_location)," ")

							rd\lock = Left$(area_temp$(rooms_location),space_loc - 1)
					
							area_temp$(rooms_location) = Right$(area_temp$(rooms_location),Len(area_temp$(rooms_location)) - space_loc)

							space_loc = Instr(area_temp$(rooms_location)," ")

							rd\key = Left$(area_temp$(rooms_location),space_loc - 1)

							area_temp$(rooms_location) = Right$(area_temp$(rooms_location),Len(area_temp$(rooms_location)) - space_loc)
							
							rd\to_room = area_temp$(rooms_location)
						EndIf
						
						If Left$(area_temp$(rooms_location),1) = "S"
							If e_cnt = 0
								r\has_e = False
								r\num_e = 0
							Else
								r\has_e = True
								r\num_e = e_cnt
							EndIf

							If d_cnt = 0
								r\has_d = False
								r\num_d = 0
							Else
								r\has_d = True
								r\num_d = a_cnt
							EndIf
							
							die = True
						EndIf

						rooms_location = rooms_location + 1
					Wend
					rooms_location = rooms_location - 2

					rooms = rooms + 1
				EndIf
			EndIf
			
			rooms_location = rooms_location + 1
		Wend
	EndIf

	; AREA RESETS
	resets_found = False
	For are_line_cnt = 1 To are_total_cnt
		If Left$(area_temp$(are_line_cnt),7) = "#RESETS"
			resets_found = True
			resets_location = are_line_cnt + 1
			Exit
		EndIf
	Next
	If resets_found = True
		While Left$(area_temp$(resets_location),1) <> "S"
			If Left$(area_temp$(resets_location),1) <> "*"
				If Left$(area_temp$(resets_location),1) <> "G" And Left$(area_temp$(resets_location),1) <> "R"
					rs.RESET = New RESET
					
					; Read command
					rs\command$ = Left$(area_temp$(resets_location),1)

					space_loc = Instr(area_temp$(resets_location)," ")					
					area_temp$(resets_location) = Right$(area_temp$(resets_location),Len(area_temp$(resets_location)) - space_loc)

					space_loc = Instr(area_temp$(resets_location)," ")					
					; Read first value
					rs\value_0 = Left$(area_temp$(resets_location),space_loc - 1)

					area_temp$(resets_location) = Right$(area_temp$(resets_location),Len(area_temp$(resets_location)) - space_loc)

					space_loc = Instr(area_temp$(resets_location)," ")					
					; Read second value
					rs\value_1 = Left$(area_temp$(resets_location),space_loc - 1)

					area_temp$(resets_location) = Right$(area_temp$(resets_location),Len(area_temp$(resets_location)) - space_loc)

					space_loc = Instr(area_temp$(resets_location)," ")		
					; Read third value
					rs\value_2 = Left$(area_temp$(resets_location),space_loc - 1)

					area_temp$(resets_location) = Right$(area_temp$(resets_location),Len(area_temp$(resets_location)) - space_loc)

					tab_loc = Instr(area_temp$(resets_location),Chr$(9))
					
					If tab_loc = 0
						space_loc = Instr(area_temp$(resets_location)," ")		
						If space_loc = 0
							; Read fourth value (if no comment)
							rs\value_3 = area_temp$(resets_location)
						Else
							; Read fourth value (if comment with spaces)
							rs\value_3 = Left$(area_temp$(resets_location),space_loc - 1)
						EndIf
					Else
						; Read fourth value (if comment with tabs)
						rs\value_3 = Left$(area_temp$(resets_location),tab_loc - 1)
					EndIf
				Else
					rs.RESET = New RESET

					; Read command
					rs\command$ = Left$(area_temp$(resets_location),1)

					space_loc = Instr(area_temp$(resets_location)," ")					
					area_temp$(resets_location) = Right$(area_temp$(resets_location),Len(area_temp$(resets_location)) - space_loc)

					space_loc = Instr(area_temp$(resets_location)," ")					
					; Read first value
					rs\value_0 = Left$(area_temp$(resets_location),space_loc - 1)

					area_temp$(resets_location) = Right$(area_temp$(resets_location),Len(area_temp$(resets_location)) - space_loc)

					space_loc = Instr(area_temp$(resets_location)," ")		
					; Read second value
					rs\value_1 = Left$(area_temp$(resets_location),space_loc - 1)

					area_temp$(resets_location) = Right$(area_temp$(resets_location),Len(area_temp$(resets_location)) - space_loc)

					tab_loc = Instr(area_temp$(resets_location),Chr$(9))
					
					If tab_loc = 0
						space_loc = Instr(area_temp$(resets_location)," ")		
						If space_loc = 0
							; Read third value (if no comment)
							rs\value_2 = area_temp$(resets_location)
						Else
							; Read third value (if comment with spaces)
							rs\value_2 = Left$(area_temp$(resets_location),space_loc - 1)
						EndIf
					Else
						; Read third value (if comment with tabs)
						rs\value_2 = Left$(area_temp$(resets_location),tab_loc - 1)
					EndIf

					resets = resets + 1
				EndIf
			EndIf
			
			resets_location = resets_location + 1
		Wend
	EndIf
	

	; AREA SHOPS
	shops_found = False
	For are_line_cnt = 1 To are_total_cnt
		If Left$(area_temp$(are_line_cnt),6) = "#SHOPS"
			shops_found = True
			shops_location = are_line_cnt + 1
			Exit
		EndIf
	Next
	If shops_found = True
		While Left$(area_temp$(shops_location),1) <> "0"
			; remove any tabs out of the text
			area_temp$(shops_location) = Replace$(area_temp$(shops_location),Chr$(9)," ")
			; Strip spaces from front and back
			area_temp$(shops_location) = Trim$(area_temp$(shops_location))


			If area_temp$(shops_location) <> ""
				sh.SHOP = New SHOP

				space_loc = Instr(area_temp$(shops_location)," ")
				; Read keeper
				sh\keeper = Left$(area_temp$(shops_location),space_loc - 1)
				
				area_temp$(shops_location) = Right$(area_temp$(shops_location),Len(area_temp$(shops_location)) - space_loc)
				area_temp$(shops_location) = Trim$(area_temp$(shops_location))
				
				space_loc = Instr(area_temp$(shops_location)," ")
				; Read trade 0
				sh\trade_0 = Left$(area_temp$(shops_location),space_loc - 1)
				
				area_temp$(shops_location) = Right$(area_temp$(shops_location),Len(area_temp$(shops_location)) - space_loc)
				area_temp$(shops_location) = Trim$(area_temp$(shops_location))

				space_loc = Instr(area_temp$(shops_location)," ")
				; Read trade 1
				sh\trade_1 = Left$(area_temp$(shops_location),space_loc - 1)
				
				area_temp$(shops_location) = Right$(area_temp$(shops_location),Len(area_temp$(shops_location)) - space_loc)
				area_temp$(shops_location) = Trim$(area_temp$(shops_location))

				space_loc = Instr(area_temp$(shops_location)," ")
				; Read trade 2
				sh\trade_2 = Left$(area_temp$(shops_location),space_loc - 1)
				
				area_temp$(shops_location) = Right$(area_temp$(shops_location),Len(area_temp$(shops_location)) - space_loc)
				area_temp$(shops_location) = Trim$(area_temp$(shops_location))

				space_loc = Instr(area_temp$(shops_location)," ")
				; Read trade 3
				sh\trade_3 = Left$(area_temp$(shops_location),space_loc - 1)
				
				area_temp$(shops_location) = Right$(area_temp$(shops_location),Len(area_temp$(shops_location)) - space_loc)
				area_temp$(shops_location) = Trim$(area_temp$(shops_location))

				space_loc = Instr(area_temp$(shops_location)," ")
				; Read trade 4
				sh\trade_4 = Left$(area_temp$(shops_location),space_loc - 1)
				
				area_temp$(shops_location) = Right$(area_temp$(shops_location),Len(area_temp$(shops_location)) - space_loc)
				area_temp$(shops_location) = Trim$(area_temp$(shops_location))

				space_loc = Instr(area_temp$(shops_location)," ")
				; Read profit_buy
				sh\profit_buy = Left$(area_temp$(shops_location),space_loc - 1)
				
				area_temp$(shops_location) = Right$(area_temp$(shops_location),Len(area_temp$(shops_location)) - space_loc)
				area_temp$(shops_location) = Trim$(area_temp$(shops_location))

				space_loc = Instr(area_temp$(shops_location)," ")
				; Read profit_sell
				sh\profit_sell = Left$(area_temp$(shops_location),space_loc - 1)
				
				area_temp$(shops_location) = Right$(area_temp$(shops_location),Len(area_temp$(shops_location)) - space_loc)
				area_temp$(shops_location) = Trim$(area_temp$(shops_location))

				space_loc = Instr(area_temp$(shops_location)," ")
				; Read open_hour
				sh\open_hour = Left$(area_temp$(shops_location),space_loc - 1)
				
				area_temp$(shops_location) = Right$(area_temp$(shops_location),Len(area_temp$(shops_location)) - space_loc)
				area_temp$(shops_location) = Trim$(area_temp$(shops_location))

				space_loc = Instr(area_temp$(shops_location)," ")
				; Read close_hour
				sh\close_hour = Left$(area_temp$(shops_location),space_loc - 1)
				
				area_temp$(shops_location) = Right$(area_temp$(shops_location),Len(area_temp$(shops_location)) - space_loc)
				area_temp$(shops_location) = Trim$(area_temp$(shops_location))

				shops = shops + 1
			EndIf

			shops_location = shops_location + 1
		Wend
	EndIf


	; AREA SPECIALS
	specials_found = False
	For are_line_cnt = 1 To are_total_cnt
		If Left$(area_temp$(are_line_cnt),9) = "#SPECIALS"
			specials_found = True
			specials_location = are_line_cnt + 1
			Exit
		EndIf
	Next
	If specials_found = True
		While Left$(area_temp$(specials_location),1) <> "S"
			If Left$(area_temp$(specials_location),1) <> "*"
				sp.SPECIAL = New SPECIAL
				
				; Trim "M" from text
				space_loc = Instr(area_temp$(specials_location)," ")
				area_temp$(specials_location) = Right$(area_temp$(specials_location),Len(area_temp$(specials_location)) - space_loc)
				area_temp$(specials_location) = Trim$(area_temp$(specials_location))
				
				; Read mob_vnum
				space_loc = Instr(area_temp$(specials_location)," ")
				sp\mob_vnum = Left$(area_temp$(specials_location),space_loc - 1)

				; Read spec_fun
				space_loc = Instr(area_temp$(specials_location)," ")
				area_temp$(specials_location) = Right$(area_temp$(specials_location),Len(area_temp$(specials_location)) - space_loc)
				
				space_loc = Instr(area_temp$(specials_location)," ")
				If space_loc = 0
					sp\spec_fun$ = area_temp$(specials_location)
				Else
					sp\spec_fun$ = Left$(area_temp$(specials_location),space_loc - 1)
				EndIf				

				specials = specials + 1
			EndIf

			specials_location = specials_location + 1
		Wend
	EndIf


	; AREA HELPS
	helps_found = False
	For are_line_cnt = 1 To are_total_cnt
		If Left$(area_temp$(are_line_cnt),6) = "#HELPS"
			helps_found = True
			helps_location = are_line_cnt + 1
			Exit
		EndIf
	Next
	If helps_found = True
		While Left$(area_temp$(helps_location),4) <> "0 $~"
			If area_temp$(helps_location) <> ""
			EndIf
			
			helps_location = helps_location + 1
		Wend
	EndIf

	; CLEAR TEMP ARRAY
	For are_line_cnt = 1 To are_total_cnt + 1
		area_temp$(are_line_cnt) = ""
	Next
End Function


I have no idea how far this works.. i think you can walk through the areas after you connect to the MUD.

I haven't ran this in years, so i have no idea how complete anything is.. it does load ARE files and check all the exits on the rooms. Oh, i think the ARE files needed are the original MERC mud ones.

[EDIT]
I ran it quick, yeah, it allows you to run around the loaded area files.

Tracer

My apologies...i didn't know about the codebox thing, thanks.

Tracer, I got an error with every .are file i tried, but it looks nice, do you have an .are file it works with? i think theres a few different formats.

Heres a few small .dat files that will get my code to work, well as much as it does:

make areas.dat with 1 line of text, blank lines btw
newhaven

then make newhaven.dat with the following text:
Town Sqaure
1
2
3
0
0
0
0
0
0
0
0
North,South

North Market
5
0
1
0
0
0
0
0
0
0
0
South

South Market
3
1
0
0
0
0
0
0
0
0
0
North

*again no blank, lines, etc

areas.dat needs to only include the area name, the default loadares is this:

roomname$
roomcolor
exitnorth
exitsouth
exiteast
exitwest
exitne
exitnw
exitse
exitsw
exitup
exitdown
exits$

with a blank line between them,o means no exit, a numbe will refer to the room# the exits to. I need alot of work on this.

loadraces and loadclasses isn't really supported yet. But those files should get the program to work. saving is disabled and doesn't save everything. so thats it for now, am still working on it though. Already added alsohere so you can see the people in the room, and when they leave and exit. And a few other things.

Sure, here's two areas, i think they are the standard Merc files.

Midgaard and School area files

Copy them into a directory called "Areas" by the MUD thing source, also create a "Players" directory by the source, as that's where new players are stored.

Tracer