Модуль:ServerStatus: различия между версиями
Als (обсуждение | вклад) Новая страница: «local p = {} function p.getPlayerCount(frame) local http = require('http') -- предположим, что у вас есть доступ к этой библиотеке local json = require('json') -- предположим, что у вас есть доступ к этой библиотеке local url = "http://85.192.49.3:1212/status" local response, err = http.get(url) if not response then return "Ошибка при...» |
Als (обсуждение | вклад) Нет описания правки |
||
Строка 1: | Строка 1: | ||
fetch('http://85.192.49.3:1212/status') | |||
.then(response => { | |||
if (!response.ok) { | |||
throw new Error('Ошибка сети'); | |||
} | |||
return response.json(); | |||
}) | |||
.then(data => { | |||
const playerCount = data.players; | |||
if | console.log(`Количество игроков на сервере: ${playerCount}`); | ||
}) | |||
.catch(error => { | |||
console.error('Произошла ошибка:', error); | |||
}); | |||
Версия от 18:31, 3 августа 2025
fetch('http://85.192.49.3:1212/status')
.then(response => { if (!response.ok) { throw new Error('Ошибка сети'); } return response.json(); }) .then(data => { const playerCount = data.players; console.log(`Количество игроков на сервере: ${playerCount}`); }) .catch(error => { console.error('Произошла ошибка:', error); });