Ok, I just tried my own code, and it seems to have buggered up at someplace...
Gimme a bit to try and fix it...
Damn... that'll teach me not to do final tests...
[EDIT]
Fixed! Damn that was stupid, sorry people, i made a n00bish mistake, I used the parser function from another program, which used commas for delimination, but EZS uses the percentage sign "%" by default, so it was messing up, plus now you need to set the server settings a lil bit...
Listener port = 9999
Pings enabled = NO
Protocal Pass Through = YES
PPT Deliminator = "%"
Leave all the rest as blank
ANYWAY, its fixed now, and the code is below
Rem Project: EZ_Chat
Rem Created: 27/12/2004 19:58:05
`---------------------------------------------------
`| Written By John [Moggie100] Vidler for EZ_Serv |
`| 2005 |
`---------------------------------------------------
`!!!REQURES EXEATS WINSOCK DLL TO BE INSTALLED TO RUN!!!
set window on
set window title "EZ_Chat John (Moggie100) Vidler (Beta2)"
set text opaque
set display mode 640, 480, 32
disable escapekey
Global cTERM as string
cTERM = chr$(13) + chr$(10)
#CONSTANT MaxLength = 79
type msg
text$ as string
color as integer
endtype
global dim data$(28) as msg
global player_name$ as string
global message$ as string
global lock as boolean
global LongID$ as string
global ShortID as integer
input "IP: ",IP$
print ""
print "Names must be less than or equal to 15 characters."
repeat
repeat
input "Name: ",player_name$
until len(player_name$)<=15
until len(player_name$)>0
Print "Connecting..."
ws_connect IP$,9999
print "Connected!"
cls
sync on : sync rate 60
backdrop on : color backdrop 0
lock=1
message$=""
clear entry buffer
repeat
ink rgb(255,255,255),rgb(0,0,155)
text 0,0,"Running at: " + str$(screen fps()) + " - Server IP: " + IP$
display()
inputtext()
if returnkey()=0 then lock=0
if ws_MessageCount()>0
InBound(ws_Receive())
endif
if len(message$) > 79
Dmessage$ = right$(message$,79)
else
Dmessage$ = message$
endif
ink rgb(255,255,255),rgb(0,0,155)
if val(mid$(str$(timer()),6))>5
text 0,460,Dmessage$+"|"
else
text 0, 460,Dmessage$
endif
ink rgb(255,255,255),0
sync
until escapekey()=1
ws_send "SPEC%,1," + str$(ShortID) + ",,User '" + player_name$ +"' has left the room..." + cTERM
ws_close
end
function inputtext()
`Text input routine
`This takes the data the user inputs and processes it when
`they hit enter
if returnkey()=1 and lock=0
message$ = Remove$(message$)
if message$<>""
if asc(mid$(message$,1))=13 then message$ = right$(message$, len(message$)-1)
`If its a /me message
if lower$(left$(message$,3)) = "/me"
wText2("<<" + player_name$ + right$(message$, len(message$)-3) + ">>",0)
ws_send "CHAT%,1," + str$(ShortID) + ",,<<" + player_name$ + right$(message$, len(message$)-3) + ">>" + cTERM
else
`if its a /nick message to change their name (this is local, as names arnt stored on the server)
if lower$(left$(message$,5)) = "/nick"
name$ = right$(message$, len(message$)-6)
ws_send "CHAT%,1," + str$(ShortID) + ",,<" + player_name$ + " is now known as " + name$ + "> " + cTERM
update("<" + player_name$ + " is now known as " + name$ + ">", 0)
player_name$ = name$
else
`the /quit message, for when people want to leave
if lower$(left$(message$,5)) = "/quit"
ws_send "SPEC%,1," + str$(ShortID) + ",,User '" + player_name$ +"' has left the room..." + cTERM
ws_close
end
else
`otherwise just send the message as a chat message
wText2("<" + player_name$ + "> " + message$,0)
ws_send "CHAT%,1," + str$(ShortID) + ",,<" + player_name$ + "> " + message$ + cTERM
endif
endif
endif
clear entry buffer
message$=""
lock=1
endif
else
new$=entry$()
for n=1 to len(new$)
if asc(mid$(new$,n))=8
message$=left$(message$,len(message$)-1)
else
message$=message$+mid$(new$,n)
endif
next n
clear entry buffer
endif
endfunction
`Just a lil function to update the data array which holds the lines
`that people say, basicly, this scrolls the screen up :)
function update(txt$,plr)
for i=1 to 27
data$(i).text$=data$(i+1).text$
data$(i).color=data$(i+1).color
next i
data$(28).color=plr
data$(28).text$=txt$
endfunction
`This control the colours of the messages, and displays them on the screen.
function display()
for i=1 to 28
select data$(i).color
case 0
ink rgb(0,255,0),0
endcase
case 1
ink rgb(255,0,0),0
endcase
case 2
ink rgb(255,255,255),rgb(0,0,255)
endcase
endselect
text 0, 15+(i*15), data$(i).text$
ink rgb(255,255,255),0
next i
endfunction
`Inbound message processor
function InBound(temp$)
`Connection Info
if left$(temp$, 9) = "QS_CONNID"
wText2("Connection Accepted!",1)
LongID$ = Parse$(temp$,1)
ShortID = val(Parse$(temp$,2))
wText2("Long ID: " + LongID$,1)
wText2("Short ID: " + str$(ShortID),1)
ws_send "SPEC%,1," + str$(ShortID) + ",,User '" + player_name$ +"' has entered the room..." + cTERM
endif
`Ping Messages
if left$(temp$,7) = "QS_PING"
`eek! pinged, quick send a PONG message to let the server know we're still here!
ws_send "QS_PONG,3," + str$(ShortID) + ",," + cTERM
endif
`Server Disconnected Client
if left$(temp$,10) = "QS_DISCONN"
`Huh? we got disconnectd for some reason! Better let the user know!
wText2("Server Disconnected You!",2)
wText2("Closing Connection...",2)
ws_close
endif
`User Joins
if left$(temp$,4) = "SPEC"
`Oooh? new person?
wText2(Parse$(temp$,2),1)
endif
`Chat Messages
if left$(temp$,4) = "CHAT"
`People are saying things O_o
wText2(Parse$(temp$,2),0)
endif
endfunction
`String Parser, splits the incoming strings from the server into useful
`bits of data that we can use, based on a delimiting character
`in this case, the comma ","
`e.g. it converts:
` "CHAT%1%<Moggie100> Woo!!"
`into:
` "CHAT"
` "1"
` "<Moggie100> Woo!!"
`in an array
function Parse$(string$ as string, part as integer)
string$ = remove$(string$)
st=0 : index=0
dim StrIndex$(100)
for a=1 to len(string$)
if mid$(string$,a)="%"
StrIndex$(index)=right$(left$(string$,a-1),(a-st))
st=a+1
index=index+1
endif
next a
StrIndex$(index)=right$(left$(string$,a-1),(a-st))
out$ = StrIndex$(part)
undim StrIndex$()
endfunction out$
`This just removes the CR and LF symbols at the end of the lines
`incidentally, ANYTHING we send to the server must end in a CRLF
`I usually just add it as a global at the top, to make things easier
function Remove$(string$)
if right$(string$,1)=chr$(10)
string$=left$(string$,len(string$)-1)
endif
if right$(string$,1)=chr$(13)
string$=left$(string$,len(string$)-1)
endif
endfunction string$
`If messages are longer than the width of the screen, then let them spread over several lines
`I cant remember whether this part of the code actually works, i think i had a few probs with
`getting it to work properly...
function wText2(s$, pl)
wcount=0
while len(s$) > MaxLength
ptr=MaxLength
repeat
dec ptr
until lower$(mid$(s$, ptr))=" " or ptr<=0
if ptr=<0
wtextT$ = left$(s$, MaxLength)
s$ = right$(s$, len(s$) - MaxLength)
else
wtextT$ = left$(s$, ptr)
s$ = right$(s$, len(s$)-ptr)
endif
Update(wTextT$,pl)
wcount=wcount+1
endwhile
Update(s$,pl)
endfunction