Optimize vehicle rent check timer
This commit is contained in:
@@ -112,6 +112,24 @@ function thirtyMinuteTimerFunction() {
|
||||
// ===========================================================================
|
||||
|
||||
function vehicleRentCheck() {
|
||||
// Loop through players, not vehicles. Much more efficient (and doesn't consume resources when no players are connected)
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(getPlayerData(clients[i]) != false) {
|
||||
if(isPlayerLoggedIn(clients[i] && isPlayerSpawned(clients[i]))) {
|
||||
if(getPlayerData(clients[i]).rentingVehicle != false) {
|
||||
if(getPlayerCurrentSubAccount(clients[i]).cash < getServerData().vehicles[getPlayerData(clients[i]).rentingVehicle].rentPrice) {
|
||||
messagePlayerAlert(clients[i], `You do not have enough money to continue renting this vehicle!`);
|
||||
stopRentingVehicle(clients[i]);
|
||||
} else {
|
||||
takePlayerCash(clients[i], getServerData().vehicles[getPlayerData(clients[i]).rentingVehicle].rentPrice);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
for(let i in getServerData().vehicles) {
|
||||
if(getServerData().vehicles[i] != null) {
|
||||
if(getServerData().vehicles[i].rentPrice > 0) {
|
||||
@@ -129,6 +147,7 @@ function vehicleRentCheck() {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -174,9 +193,12 @@ function checkPayDays() {
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(isPlayerLoggedIn(clients[i]) && isPlayerSpawned(clients[i])) {
|
||||
getPlayerData(clients[i]).payDayStart = sdl.ticks;
|
||||
playerPayDay(clients[i]);
|
||||
|
||||
//if(sdl.ticks-getPlayerData(clients[i]).payDayTickStart >= getGlobalConfig().payDayTickCount) {
|
||||
getPlayerData(clients[i]).payDayStart = sdl.ticks;
|
||||
playerPayDay(clients[i]);
|
||||
// getPlayerData(clients[i]).payDayStart = sdl.ticks;
|
||||
// playerPayDay(clients[i]);
|
||||
//}
|
||||
}
|
||||
}
|
||||
@@ -190,7 +212,7 @@ function showRandomTipToAllPlayers() {
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(isPlayerLoggedIn(clients[i]) && isPlayerSpawned(clients[i])) {
|
||||
messagePlayerTimedRandomTip(clients[i], randomTips[tipId]);
|
||||
messagePlayerTimedRandomTip(null, randomTips[tipId]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user