S
S
SAMACK2019-11-20 15:39:55
Game development
SAMACK, 2019-11-20 15:39:55

How to make a timer using a command on the game server so that it appears on the Site?

The bottom line is that there is a server in minecraft, and you need to make it so that using the / autostart set 30m command, a countdown of 30 minutes appears on the website and then after that the countdown is reset again. And so every time you want to add a rink, you just need to enter this command. Also, to cancel it (timer) / autostart cancel then the timer is simply reset. Here is a screenshot: https://pastenow.ru/7AHAS shows in red where the timer should be.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dollar, 2019-11-20
@dollar

The website in this case is also a server, and for understanding, we introduce the concepts:
Further, the task can be divided into two (three) stages:
You need your server to send start and end information to the web server. This is done over HTTP or HTTPS, something like java.net.HttpUrlConnection , but I don't know exactly which would suit you better for this purpose.
Accordingly, on the web server you must have your own script in any language, usually PHP. This script saves information to a database (usually MySQL).
To store a timer that changes all the time, you need to store its unchanged parts. Namely - the beginning and end, or the beginning and duration, or just the end time (timestamp) accurate to the second.
This is the communication between the web server and the browser (client). And here there are subtleties.
Firstly, immediately fork to the functionality - or you have a timer that appears by pressing F5 (refresh the page). That is, you refresh the page, the browser requests new data from the web server, and after that it shows a timer. Or you have a website page open, and a timer suddenly appears there in real time. Myself! This can be done in different ways, but the most banal way is for the web page (that is, the browser) to make a request every 10 seconds in the background (ajax), and if new data suddenly appears, then the page is transformed.
Secondly, if your server assumes players from different time zones, then the local time in each browser will be different. So you will have to confuse a little in order to correctly display the time on the site to the user, regardless of the time shift.
The rest is simple. Information from the database is stupidly sent to the client, that is, the end time, and then the script works locally on the client. It shows the countdown to the start of the game. Actually, writing this mini script in JavaScript can be considered the third stage.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question