Commit fba42a52 authored by Neoony's avatar Neoony
Browse files

Small fixes

parent 8e650f5a
......@@ -31,6 +31,8 @@ var xpx = ["", "", "", "", "", "", "", "", "", ""];
var xpmessage = ["", "", "", "", "", "", "", "", "", ""];
var numberofservers;
var HandleDisconnectOn = 0;
//var messagex;
var messageServerOn = "```No data yet. Try again in < 10 seconds```";
var messageQuickPlay = "```No data yet. Try again in < 10 seconds```";
......@@ -86,6 +88,15 @@ client.on('message', message => {
}
});
function KillSQL()
{
connection.end(function(err)
{
return;
// The connection is terminated now
});
}
function RefreshSQL()
{
messagex = "";
......@@ -96,12 +107,18 @@ function RefreshSQL()
{
console.log('Query 1 error');
messageServerOn = "```No data yet. Try again in < 10 seconds``````diff\n-Connection to the database is down!```";
client.user.setStatus('dnd');
if (HandleDisconnectOn == 0)
{
handleDisconnect();
}
return;
}
//{
// console.error('error query1: ' + error.stack);
// return;
//}
HandleDisconnectOn = 0;
console.log('Number of servers: ', results[0].cnt);
numberofservers = results[0].cnt;
});
......@@ -112,6 +129,11 @@ function RefreshSQL()
{
console.log('Query 2 error');
messageServerOn = "```No data yet. Try again in < 10 seconds``````diff\n-Connection to the database is down!```";
client.user.setStatus('dnd');
if (HandleDisconnectOn == 0)
{
handleDisconnect();
}
return;
}
//{
......@@ -119,6 +141,7 @@ function RefreshSQL()
// return;
//}
HandleDisconnectOn = 0;
var i;
//var xpmessage;
......@@ -210,14 +233,14 @@ function RefreshSQL()
}
}
if (playersinlobby > 1)
if (playersinlobby > 1 && playersoutoflobby < 8)
{
client.user.setStatus('available');
//client.user.setActivity(numberofallplayers + ' players');
client.user.setPresence({ game: { name: "with " + playersinlobby + " players", type: "Playing", url: "https://empiresmod.com"}});
}
if (playersinlobby == 1)
if (playersinlobby == 1 && playersoutoflobby < 8)
{
client.user.setStatus('available');
//client.user.setActivity(numberofallplayers + ' players');
......@@ -225,7 +248,7 @@ function RefreshSQL()
client.user.setPresence({ game: { name: "with " + playersinlobby + " player", type: "Playing", url: "https://empiresmod.com"}});
}
if (playersinlobby == 0 && numberofallplayers != 0)
if (playersinlobby == 0 && playersoutoflobby < 8)
{
client.user.setPresence({ game: { name: "Waiting for players", type: "Playing", url: "https://empiresmod.com"}});
client.user.setStatus('idle');
......@@ -258,16 +281,8 @@ function RefreshSQL()
});
};
function KillSQL()
{
connection.end(function(err)
{
return;
// The connection is terminated now
});
}
function handleDisconnect() {
HandleDisconnectOn = 1;
connection = mysql.createConnection(db_config); // Recreate the connection, since
// the old one cannot be reused.
......
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