Page 1 of 1

Server Disconect (how to)

Posted: Mon Dec 10, 2012 7:19 pm
by muttley1968
hello i have this code for launching minecraft to a server straight away
Code: Select all
       Process.Start(My.Settings.Minecraft_loc, String.Format("{0} {1} {2}", Label4.Text, "12345", My.Settings.server_ip))
but what i now want to know is, is their a way to make it so if a player disconects from that server to attempt single player is their a way to kill the game or just reconect to server and display a message box saying sorry you can not do that

Re: Server Disconect (how to)

Posted: Mon Dec 10, 2012 9:43 pm
by visualtech
you need to know the command line argument for that,

suppose the argument is -d for disconnect, the the code will be

Process.Start(My.Settings.Minecraft_loc, "-c")

Re: Server Disconect (how to)

Posted: Mon Dec 10, 2012 10:12 pm
by muttley1968
and how would i go about finiding out these command lines

Re: Server Disconect (how to)

Posted: Tue Dec 11, 2012 8:30 pm
by visualtech
they might be in the server documentation

Re: Server Disconect (how to)

Posted: Tue Dec 11, 2012 8:40 pm
by muttley1968
nope it aint were would it be inside the main jar file its for minecraft so

Re: Server Disconect (how to)

Posted: Thu Dec 13, 2012 8:28 am
by visualtech
what do you mean, there is no documentation?

well, then you have to quit the process:

you can do this:

Dim server As New Process

server = Process.Start("MINECRAFT_SERVER.jar", "-connect")

server.Kill()

Re: Server Disconect (how to)

Posted: Thu Dec 13, 2012 8:30 am
by visualtech
sorry modify the code like this

Dim server as Process
server = Process.Start(My.Settings.Minecraft_loc, String.Format("{0} {1} {2}", Label4.Text, "12345", My.Settings.server_ip) 'The code for connecting

'For Disconnecting:

server.Kill()

Re: Server Disconect (how to)

Posted: Thu Dec 13, 2012 8:34 am
by visualtech
For reconnecting

kill the process with server.Kill() and then re-execute the connection bit i.e. server = Process.Start()

Re: Server Disconect (how to)

Posted: Thu Dec 13, 2012 8:38 am
by muttley1968
i will try taht but allow me to explain my self better what i want to do is make a mincraft launcher that will launch staight to my server and then make it so if a user pressed the esc button and click the disconect button on that menu the program runing in the background will see this and restart the game back to the server and show a message box saying you cant do this

Re: Server Disconect (how to)

Posted: Thu Dec 13, 2012 9:55 am
by visualtech
then you have to find each thread on which the JAR relies, then scan them for activity, if there is a disconnection activity then restart the server. that can get a little complicated if you are a amateur programmer.