r/pythonhelp • u/ViridianGuy • Jan 07 '22
Why Is This Not Working
I'm trying to make a script that pings a Minecraft Server (using inputs) every little bit, so the server always stays online. But there are a few errors and I don't know why. I've only been using Python for a few Months.
import timefrom mcstatus import MinecraftServerprint("Minecraft Server Pinger")print("By: ViridianTelamon.")print("The Server Will Be Pinged Every 5 Minutes Until You Close This Script.")Server = input("Enter Your Minecraft Java Server IP (Example: Server.aternos.me): ")Port = input("Enter Your Minecraft Java Port Or Host (Example: 12345678910): ")Seconds = int(input("Enter The Amount Of Seconds For Intervals Between Server Pings: "))while True:
time.sleep(280)
server = MinecraftServer.lookup(Server,":",Port)
latency = server.ping()
print(f"The server replied in {latency} ms")
1
u/Vicente_Cunha Jan 07 '22
put the time.sleep below the print statement, because your script now waits 5 minutes and only then displays the data