Server Disconect (how to)

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
10 posts Page 1 of 1
Contributors
User avatar
muttley1968
Hardcore Programmer
Hardcore Programmer
Posts: 622
Joined: Thu Jun 17, 2010 11:54 pm

Server Disconect (how to)
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
User avatar
visualtech
VIP - Donator
VIP - Donator
Posts: 265
Joined: Sat Nov 19, 2011 2:19 pm

Re: Server Disconect (how to)
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")
Image
User avatar
muttley1968
Hardcore Programmer
Hardcore Programmer
Posts: 622
Joined: Thu Jun 17, 2010 11:54 pm

Re: Server Disconect (how to)
muttley1968
and how would i go about finiding out these command lines
User avatar
visualtech
VIP - Donator
VIP - Donator
Posts: 265
Joined: Sat Nov 19, 2011 2:19 pm

Re: Server Disconect (how to)
visualtech
they might be in the server documentation
Image
User avatar
muttley1968
Hardcore Programmer
Hardcore Programmer
Posts: 622
Joined: Thu Jun 17, 2010 11:54 pm

Re: Server Disconect (how to)
muttley1968
nope it aint were would it be inside the main jar file its for minecraft so
User avatar
visualtech
VIP - Donator
VIP - Donator
Posts: 265
Joined: Sat Nov 19, 2011 2:19 pm

Re: Server Disconect (how to)
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()
Image
User avatar
visualtech
VIP - Donator
VIP - Donator
Posts: 265
Joined: Sat Nov 19, 2011 2:19 pm

Re: Server Disconect (how to)
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()
Image
User avatar
visualtech
VIP - Donator
VIP - Donator
Posts: 265
Joined: Sat Nov 19, 2011 2:19 pm

Re: Server Disconect (how to)
visualtech
For reconnecting

kill the process with server.Kill() and then re-execute the connection bit i.e. server = Process.Start()
Image
User avatar
muttley1968
Hardcore Programmer
Hardcore Programmer
Posts: 622
Joined: Thu Jun 17, 2010 11:54 pm

Re: Server Disconect (how to)
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
User avatar
visualtech
VIP - Donator
VIP - Donator
Posts: 265
Joined: Sat Nov 19, 2011 2:19 pm

Re: Server Disconect (how to)
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.
Image
10 posts Page 1 of 1
Return to “Coding Help & Support”