I Don't Understand What The Mid Function Does, And How I Can Use It In A Multiplayer Game To Send Multiple Parameters In One String.
I'm Trying To Make A Chatroom That Allows Players To Set A Color For The Messages That They Send. I Plan To Add More.
Here Is The Code So Far:
sync on : sync rate 60 : sync :sync : sync
randomize timer()*3
playername$="ME"
sync
input "Your Name: ",playername$
sync
_newcolor:
playercolor=rgb(rnd(150)+105,rnd(150)+105,rnd(150)+105)
_custom:
ink playercolor,0
print "Testing Your Color..."
sync
print "Do You Like Your Color?"
input "Y For Yes, Anything Else For No, C For Custom, CC For ColorCode",yesno$
sync
if yesno$="cc" or yesno$="CC" then input "Color Code: ",playercolor : goto _custom
if yesno$="c" or yesno$="C"
sync
input "Red Level:",r
sync
input "Green Level:",g
sync
input "Blue Level:",b
sync
playercolor = rgb(r,g,b)
goto _custom
endif
if yesno$="y" or yesno$="Y" then else goto _newcolor
print "Your Colorcode: ";playercolor
print "Press Any Key To Continue"
sync
wait key
input "server(1) or client(0)?"; server
set net connection 3,"127.0.0.1"
if server = 1 then create net game "a game",playername$,2,1
if server = 0 then join net game 1,playerName$
do
if server = 0
rem search for new messages
keepgoing:
get net message
message$=net message string$()
message=net message integer()
rem ENTER WHATEVER YOU WANT TO DO WITH THE MESSAGE$ VARIABLE HERE
rem for this example, I'll just paste it to the screen
if message$>"" then gotmessage$=message$ : ink message,0
print gotmessage$
rem then check for any remaining messages
if net message exists()=1 then goto keepgoing
if spacekey()=1
input "Message:",mes$
send net message string 0,playername$+":"mes$: inc sent
endif
endif
if server = 1
rem search for new messages
keepgoing:
get net message
message$=net message string$()
message=net message integer()
rem ENTER WHATEVER YOU WANT TO DO WITH THE MESSAGE$ VARIABLE HERE
rem for this example, I'll just paste it to the screen
if message$>"" then gotmessage$=message$ : ink message,0
print gotmessage$
rem then check for any remaining messages
`if net message exists()=1 then goto keepgoing
if spacekey()=1
input "Message:",mes$
send net message string 0,playername$+":"+mes$: inc sent
endif
endif
sync
loop
There Is Another Problem : The Messages Are Printed May Times Instead Of Once. How Can I Solve These Problems.
Here Is What Help Said About The Mid Function:
MID$
This command will extract a character from the string provided. The return string will contain a single character extracted from the
string specified. The value provided should be an integer value.
SYNTAX
Return String=MID$(String,Value)
So What's Value?
Also, I'm New To Multiplayer In Darkbasic Pro, Not Darkbasic Pro, And I Used A Certain Code To Get Multiplayer To Work. The Author Should Be Able To Recognize It Because Of The Input Command Under The Wait Key.
-Ilya