Optimizations, disable some timers when server empty
This commit is contained in:
@@ -90,12 +90,14 @@ function saveServerDataToDatabase() {
|
|||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function initTimers() {
|
function initTimers() {
|
||||||
//if(!isDevelopmentServer()) {
|
//if (isDevelopmentServer()) {
|
||||||
|
// return false;
|
||||||
|
//}
|
||||||
|
|
||||||
serverTimers.updatePingsTimer = setInterval(updatePings, 5000);
|
serverTimers.updatePingsTimer = setInterval(updatePings, 5000);
|
||||||
serverTimers.oneMinuteTimer = setInterval(oneMinuteTimerFunction, 60000);
|
serverTimers.oneMinuteTimer = setInterval(oneMinuteTimerFunction, 60000);
|
||||||
serverTimers.fifteenMinuteTimer = setInterval(tenMinuteTimerFunction, 600000);
|
serverTimers.tenMinuteTimer = setInterval(tenMinuteTimerFunction, 600000);
|
||||||
serverTimers.thirtyMinuteTimer = setInterval(thirtyMinuteTimerFunction, 1800000);
|
serverTimers.thirtyMinuteTimer = setInterval(thirtyMinuteTimerFunction, 1800000);
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
@@ -104,11 +106,13 @@ function oneMinuteTimerFunction() {
|
|||||||
logToConsole(LOG_DEBUG, `[VRR.Event] Checking server game time`);
|
logToConsole(LOG_DEBUG, `[VRR.Event] Checking server game time`);
|
||||||
checkServerGameTime();
|
checkServerGameTime();
|
||||||
|
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Event] Checking rentable vehicles`);
|
if (getClients().length > 0) {
|
||||||
checkVehicleRenting();
|
logToConsole(LOG_DEBUG, `[VRR.Event] Checking rentable vehicles`);
|
||||||
|
checkVehicleRenting();
|
||||||
|
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Event] Updating all player name tags`);
|
logToConsole(LOG_DEBUG, `[VRR.Event] Updating all player name tags`);
|
||||||
updateAllPlayerNameTags();
|
updateAllPlayerNameTags();
|
||||||
|
}
|
||||||
|
|
||||||
logToConsole(LOG_DEBUG, `[VRR.Event] Collecting all garbage`);
|
logToConsole(LOG_DEBUG, `[VRR.Event] Collecting all garbage`);
|
||||||
collectAllGarbage();
|
collectAllGarbage();
|
||||||
@@ -118,14 +122,18 @@ function oneMinuteTimerFunction() {
|
|||||||
|
|
||||||
function tenMinuteTimerFunction() {
|
function tenMinuteTimerFunction() {
|
||||||
//showRandomTipToAllPlayers();
|
//showRandomTipToAllPlayers();
|
||||||
saveServerDataToDatabase();
|
//saveServerDataToDatabase();
|
||||||
checkInactiveVehicleRespawns();
|
//checkInactiveVehicleRespawns();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function thirtyMinuteTimerFunction() {
|
function thirtyMinuteTimerFunction() {
|
||||||
checkPayDays();
|
if (getClients().length > 0) {
|
||||||
|
checkPayDays();
|
||||||
|
}
|
||||||
|
saveServerDataToDatabase();
|
||||||
|
checkInactiveVehicleRespawns();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
@@ -173,6 +181,10 @@ function checkVehicleRenting() {
|
|||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function updatePings() {
|
function updatePings() {
|
||||||
|
if (getClients().length == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
let clients = getClients();
|
let clients = getClients();
|
||||||
for (let i in clients) {
|
for (let i in clients) {
|
||||||
if (isClientInitialized(clients[i])) {
|
if (isClientInitialized(clients[i])) {
|
||||||
@@ -190,16 +202,16 @@ function updatePings() {
|
|||||||
|
|
||||||
function checkServerGameTime() {
|
function checkServerGameTime() {
|
||||||
//if(!getServerConfig().useRealTime) {
|
//if(!getServerConfig().useRealTime) {
|
||||||
if (getServerConfig().minute >= 59) {
|
//if (getServerConfig().minute >= 59) {
|
||||||
getServerConfig().minute = 0;
|
// getServerConfig().minute = 0;
|
||||||
if (getServerConfig().hour >= 23) {
|
// if (getServerConfig().hour >= 23) {
|
||||||
getServerConfig().hour = 0;
|
// getServerConfig().hour = 0;
|
||||||
} else {
|
// } else {
|
||||||
getServerConfig().hour = getServerConfig().hour + 1;
|
// getServerConfig().hour = getServerConfig().hour + 1;
|
||||||
}
|
// }
|
||||||
} else {
|
//} else {
|
||||||
getServerConfig().minute = getServerConfig().minute + 1;
|
// getServerConfig().minute = getServerConfig().minute + 1;
|
||||||
}
|
//}
|
||||||
//} else {
|
//} else {
|
||||||
// let dateTime = getCurrentTimeStampWithTimeZone(getServerConfig().realTimeZone);
|
// let dateTime = getCurrentTimeStampWithTimeZone(getServerConfig().realTimeZone);
|
||||||
// getServerConfig().hour = dateTime.getHours();
|
// getServerConfig().hour = dateTime.getHours();
|
||||||
@@ -212,6 +224,10 @@ function checkServerGameTime() {
|
|||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function checkPayDays() {
|
function checkPayDays() {
|
||||||
|
if (getClients().length == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
let clients = getClients();
|
let clients = getClients();
|
||||||
for (let i in clients) {
|
for (let i in clients) {
|
||||||
if (isClientInitialized(clients[i])) {
|
if (isClientInitialized(clients[i])) {
|
||||||
@@ -237,6 +253,10 @@ function checkPayDays() {
|
|||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function showRandomTipToAllPlayers() {
|
function showRandomTipToAllPlayers() {
|
||||||
|
if (getClients().length == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
let clients = getClients();
|
let clients = getClients();
|
||||||
for (let i in clients) {
|
for (let i in clients) {
|
||||||
if (isClientInitialized(clients[i])) {
|
if (isClientInitialized(clients[i])) {
|
||||||
|
|||||||
Reference in New Issue
Block a user