Commit 1da5b518 authored by Neoony's avatar Neoony
Browse files

Added fallback in case lobbies are down

parent c48f8de9
......@@ -99,8 +99,9 @@ function KillSQL()
function RefreshSQL()
{
var LobbyUp = 0;
messagex = "";
messageServerOn = "```No full data yet. Try again in < 10 seconds``````diff\n-Connection to the database/lobby is down!```";
messageServerOn = "```No full data yet. Try again in < 10 seconds``````diff\n-Connection to the database/lobby is down!``````diff\n-Fast refreshing might be down, info might be OUTDATED```";
connection.query("SELECT COUNT(*) as cnt FROM `LobbyDB`.`servers` WHERE password=0 AND isenabled=1 AND addr!='80.112.155.100:27017' ORDER BY players DESC LIMIT 10;", function (error, results, fields)
{
if (error)
......@@ -189,6 +190,7 @@ function RefreshSQL()
//});
if (namex[i] == 'Empires Lobby' && addrx[i] == '185.165.242.40:27015' || namex[i] == 'Empires Backup Lobby' && addrx[i] == '80.112.155.100:27015')
{
LobbyUp = 1;
messageQuickPlay = "***`" + "Quick play ---> `*** **steam://connect/" + addrx[i] + "**";
playersinlobby = playersx[i];
......@@ -244,14 +246,14 @@ function RefreshSQL()
}
}
if (playersinlobby > 1 && playersoutoflobby < 8)
if (playersinlobby > 1 && playersoutoflobby < 8 && LobbyUp == 1)
{
client.user.setStatus('available');
//client.user.setActivity(numberofallplayers + ' players');
client.user.setPresence({ game: { name: "with " + playersinlobby + " players @Lobby", type: "Playing", url: "https://empiresmod.com"}});
}
if (playersinlobby == 1 && playersoutoflobby < 8)
if (playersinlobby == 1 && playersoutoflobby < 8 && LobbyUp == 1)
{
client.user.setStatus('available');
//client.user.setActivity(numberofallplayers + ' players');
......@@ -259,13 +261,13 @@ function RefreshSQL()
client.user.setPresence({ game: { name: "with " + playersinlobby + " player @Lobby", type: "Playing", url: "https://empiresmod.com"}});
}
if (playersinlobby == 0 && playersoutoflobby < 8)
if (playersinlobby == 0 && playersoutoflobby < 8 && LobbyUp == 1)
{
client.user.setPresence({ game: { name: "Waiting for players", type: "Playing", url: "https://empiresmod.com"}});
client.user.setStatus('idle');
}
if (HighestCurPopulation >= 8)
if (HighestCurPopulation >= 8 && LobbyUp == 1)
{
client.user.setStatus('available');
//client.user.setActivity(numberofallplayers + ' players');
......@@ -275,13 +277,43 @@ function RefreshSQL()
messageServerOn += "```CSS\n" + "Total number of players: " + numberofallplayers + "\nServers: " + numberofservers + "\n" + "```";
if (numberofallplayers == 0)
if (numberofallplayers == 0 && LobbyUp == 1)
{
//client.user.setActivity('Waiting for players');
client.user.setPresence({ game: { name: "Waiting for players", type: "Playing", url: "https://empiresmod.com"}});
client.user.setStatus('idle');
}
if (LobbyUp == 0)
{
if (HighestCurPopulation == 0)
{
client.user.setPresence({ game: { name: "Waiting for players", type: "Playing", url: "https://empiresmod.com"}});
client.user.setStatus('idle');
}
if (HighestCurPopulation == 1)
{
client.user.setStatus('available');
//client.user.setActivity(numberofallplayers + ' players');
client.user.setPresence({ game: { name: "with player" + " @" + namex[HighestPopServer], type: "Playing", url: "https://empiresmod.com"}});
}
if (HighestCurPopulation > 1 && HighestCurPopulation < 8)
{
client.user.setStatus('available');
//client.user.setActivity(numberofallplayers + ' players');
client.user.setPresence({ game: { name: "with players" + " @" + namex[HighestPopServer], type: "Playing", url: "https://empiresmod.com"}});
}
if (HighestCurPopulation >= 8)
{
client.user.setStatus('available');
//client.user.setActivity(numberofallplayers + ' players');
client.user.setPresence({ game: { name: "Game On!" + " @" + namex[HighestPopServer], type: "Playing", url: "https://empiresmod.com"}});
}
}
//messageServerOn += namex[i] + " (" + playersx[i] + "/" + maxplayersx[i] + ")" + "\n" + addrx[i] + "\n";
//console.log('Returned value on message: ', messageServerOn);
//client.user.setStatus('available')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment