In the two code segments above, add the bit you corrected, make sure that MN Client Joined is in the main loop somewhere, I have tried bo9th in the for loop and main 'do' loop. Either report the server being connected to by a client once and then report no connection from the client... but the client side stays connected. I need to report a constant connection from the server by a client (IE see all current connections server side)
Code:
set window on
Set window size Desktop Width()/2, Desktop Height()/2
Set Window Position Desktop Width()/4, Desktop Height()/4
Startblue "", ""
Result = mn Start(1, 0)
mn Disable Message Boxes
mn Disable Debug
` Setup instance 0 - Game
mn Set Buffer Sizes instGame, 4096, 4096, 2
Recv = mn Create Packet()
mn set memory size Recv, 4096
Send = mn Create Packet()
mn set memory size Send, 4096
Server$ = "000.000.000.000"
Result = mn Connect(instGame, Server$, 1824, Server$, 1925, 15, 1)
sync on : Sync Rate 60
do
Con=mn Client Connected (InstGame,0)
sync
If Result = -2
Text 10,10, "Server Is Full"
endif
If result = 0
DS=1
Text 10,10, "Connection timed out. Please try again later."
endif
If result = 1
Text 10,10, "Connection Successful..."
endif
If CON=1
sync
Text 10,25,"Connected to Server @ "+ Server$
else
sync
text 10,25,""
endif
If Con=0 and DS=0
cls
Repeat
sync
Text 10,10, "Connection Terminated by Server"
until Con=1
endif
sync
loop
Set display mode Desktop Width()/2, Desktop Height()/2, 32, 1
set text font "Impact"
set text size 18
Startblue "", ""
Set window on
set window size desktop width()/2, Desktop Height()/2
set window position Desktop Width()/4, Desktop Height()/4
Sync on : Sync Rate 60
PB$=CHR$(10)+CHR$(13)
Main=createMenu(0)
addMenuItem Main, "File",100
addMenuItem Main, "Connect",200
addMenuItem Main, "Options",300
`file menu
Save=createSubMenu(Main,100)
addMenuItem Save, "Save Log...", 0
addMenuItem Save, "Save Log as...", 1
addMenuItem Save, "Save Connections at timestamp", 2
addMenuItem Save, "Save Connections at timestamp as...", 3
addMenuSplitter Save
addMenuItem Save, "Open Log...", 4
addMenuSplitter Save
addMenuItem Save, "Quit and Exit", 5
`connect menu
Connect=createSubMenu(Main,200)
addMenuItem connect, "Connect Server...", 6
SetSer=createSubMenu(connect,6)
addMenuItem setser, "Automatic Local IP Detection", 7
addMenuItem setser, "Check Current Connection(s)", 9
addMenuSplitter connect
addMenuItem connect, "Find Connected Users...", 10
Find=createSubMenu(connect,10)
addMenuItem Find, "Find User's IP Address...", 11
addMenuItem Find, "Find User by Name...", 12
addMenuSplitter connect
addMenuItem connect, "Disconnect...", 14
DisSer=createSubMenu(connect,14)
addMenuItem DisSer, "Disconnect All Users and Stop Server", 15
addMenuSplitter connect
addMenuItem connect, "Admin Message All Users", 17
MessUsers=createSubMenu(connect,17)
addMenuItem MessUsers, "On Selected Server", 18
addMenuItem MessUsers, "On All Servers", 19
addMenuItem connect, "Admin Manage Repeating Messages", 20
RepMess=createSubMenu(Connect,20)
addMenuItem RepMess, "Set Weekly Message(s)", 21
addMenuItem RepMess, "Set Login Message(s)", 22
`file menu
Op=createSubMenu(Main,300)
addMenuItem Op, "G.Env. Server", 23
addMenuItem Op, "User Setup", 24
addMenuItem Op, "Connection Setup", 25
addMenuSplitter op
addMenuItem op, "Help...", 26
addMenuSplitter op
addMenuItem op, "About...", 27
` Setup instance 0 - Game
instGame = 0
Started=0
CClients = 0
Clients=createTreeView(Screen Width()-200, 0, 200, Screen Height(), 0)
Bringtofront Clients
Panel=CreatePanel (10,10, Screen Width()-200, Screen Height(),0)
Setgadgetcolor Clients, RGB(60,75,90),RGB(255,255,255)
Setgadgetcolor Panel, RGB(120,122,125),RGB(255,255,255)
CLS RGB(120,122,125)
Euro=CreateFont("Eurostile", 12,0,0,0)
Applyfont Clients,Euro
Applyfont Panel,Euro
do
Sync
Resetmainwindow
getevent
if eventType()=MENU_CLICK
select eventData()
case 0: : endcase
case 1: : endcase
case 2: : endcase
case 3: : endcase
case 4: : endcase
case 5: end : endcase
case 7 :
Result = mn Start (1, 0)
Started=1
AutoIP$=MN Get Local IP(0)
mn Set Local instGame, AutoIP$, 1824, AutoIP$, 1925
Recv = mn Create Packet()
mn set memory size Recv, 4096
Send = mn Create Packet()
mn Set Buffer Sizes instGame, 4096, 4096, 1
mn set memory size Send, 4096
MN start Server InstGame,50,1,4
endcase
case 9:
if Started=1
TotalNumIPs=mn Get Local IP Amount()-1
For MessageIPS = 0 to TotalNumIps
Messaging$=Messaging$+Str$(MessageIPS+1)+".) "+MN Get Local Ip(MessageIPS)
next MessageIPS
message "Server configured and running on:" +PB$+ Messaging$
Messaging$=CHR$(0)
endif
if Started=0
Started=1
mn Start 1, 0
AutoIP$=MN Get Local IP(0)
mn Set Local instGame, AutoIP$, 1824, AutoIP$, 1925
TotalNumIPs=mn Get Local IP Amount()-1
For MessageIPS = 0 to TotalNumIps
Messaging$=Messaging$+Str$(MessageIPS+1)+".) "+MN Get Local Ip(MessageIPS)
next MessageIPS
MN Finish -1
message "Current addresses you are able to configure:" +PB$+ Messaging$
Messaging$=CHR$(0)
Started=0
endif
endcase
case 10:: endcase
case 11:: endcase
case 12:: endcase
case 13:: endcase
case 14:: endcase
case 15:
If Started=1
Started=0
MN Finish -1
endif
endcase
case 17:: endcase
case 18:: endcase
case 19:: endcase
case 20:: endcase
case 21:: endcase
case 22:: endcase
case 23:: endcase
case 24:: endcase
case 25:: endcase
case 26:: endcase
case 27:: endcase
endselect
endif
Screen = GET DBPRO WINDOW ( )
Height = GET WINDOW CLIENT HEIGHT( Screen )
Width = GET WINDOW CLIENT Width( Screen )
Setgadget Clients, Width-200, 0,200, Height
Setgadget Panel, 10, 10,Width-200, Height
If Started = 1
NotJoined=-1
Joined = MN Client Joined (InstGame)
setMenuItemEnabled Setser, 7, 0
setMenuItemEnabled DisSer, 15, 1
For ClientCall= 1 to mn Get Max Clients(0)
If mn Client Connected(0, ClientCall)=1
CClient= CClient+1
endif
next ClientCall
Mess$="Connected to user ID #"
Setgadgettext Panel, Mess$+STR$(CClient+1)+PB$+STR$(CClient+1)+" Users Connected"+PB$
Resetmainwindow
If Result < 0
Mess$="Unable To Establish Server"
else
Mess$="Connected"
If Joined > 0
SetGadgetText Panel, Mess$+STR$(CClient+1)+PB$+STR$(CClient+1)+" Users Connected"+PB$+"New User Joined"
endif
endif
endif
If Started = 0
NotJoined=1
setMenuItemEnabled Setser, 7, 1
setMenuItemEnabled DisSer, 15, 0
resetmainwindow
endif
If Result < 0
Mess$="Unable To Establish Server"
endif
If Result = 0 and NotJoined =1
Mess$="Select a Connection"
endif
Setgadgettext Panel, Mess$
Sync
loop
First is client, second is then server
Take a look. You need BlueGUI and Matrix1 Utility Plugin (IanM) for it to work, otherwise I will have to rewrite it all for you, which may not cause the same errors.
Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.