Check player init
This commit is contained in:
@@ -128,14 +128,16 @@ function vehicleRentCheck() {
|
|||||||
// Loop through players, not vehicles. Much more efficient (and doesn't consume resources when no players are connected)
|
// Loop through players, not vehicles. Much more efficient (and doesn't consume resources when no players are connected)
|
||||||
let clients = getClients();
|
let clients = getClients();
|
||||||
for(let i in clients) {
|
for(let i in clients) {
|
||||||
if(getPlayerData(clients[i]) != false) {
|
if(isClientInitialized(clients[i])) {
|
||||||
if(isPlayerLoggedIn(clients[i] && isPlayerSpawned(clients[i]))) {
|
if(getPlayerData(clients[i]) != false) {
|
||||||
if(getPlayerData(clients[i]).rentingVehicle != false) {
|
if(isPlayerLoggedIn(clients[i] && isPlayerSpawned(clients[i]))) {
|
||||||
if(getPlayerCurrentSubAccount(clients[i]).cash < getServerData().vehicles[getPlayerData(clients[i]).rentingVehicle].rentPrice) {
|
if(getPlayerData(clients[i]).rentingVehicle != false) {
|
||||||
messagePlayerAlert(clients[i], `You do not have enough money to continue renting this vehicle!`);
|
if(getPlayerCurrentSubAccount(clients[i]).cash < getServerData().vehicles[getPlayerData(clients[i]).rentingVehicle].rentPrice) {
|
||||||
stopRentingVehicle(clients[i]);
|
messagePlayerAlert(clients[i], `You do not have enough money to continue renting this vehicle!`);
|
||||||
} else {
|
stopRentingVehicle(clients[i]);
|
||||||
takePlayerCash(clients[i], getServerData().vehicles[getPlayerData(clients[i]).rentingVehicle].rentPrice);
|
} else {
|
||||||
|
takePlayerCash(clients[i], getServerData().vehicles[getPlayerData(clients[i]).rentingVehicle].rentPrice);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -168,10 +170,12 @@ function vehicleRentCheck() {
|
|||||||
function updatePings() {
|
function updatePings() {
|
||||||
let clients = getClients();
|
let clients = getClients();
|
||||||
for(let i in clients) {
|
for(let i in clients) {
|
||||||
if(!clients[i].console) {
|
if(isClientInitialized(clients[i])) {
|
||||||
updatePlayerPing(clients[i]);
|
if(!clients[i].console) {
|
||||||
if(isPlayerSpawned(clients[i])) {
|
updatePlayerPing(clients[i]);
|
||||||
updatePlayerCash(clients[i]);
|
if(isPlayerSpawned(clients[i])) {
|
||||||
|
updatePlayerCash(clients[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -205,14 +209,16 @@ function checkServerGameTime() {
|
|||||||
function checkPayDays() {
|
function checkPayDays() {
|
||||||
let clients = getClients();
|
let clients = getClients();
|
||||||
for(let i in clients) {
|
for(let i in clients) {
|
||||||
if(isPlayerLoggedIn(clients[i]) && isPlayerSpawned(clients[i])) {
|
if(isClientInitialized(clients[i])) {
|
||||||
getPlayerData(clients[i]).payDayStart = sdl.ticks;
|
if(isPlayerLoggedIn(clients[i]) && isPlayerSpawned(clients[i])) {
|
||||||
playerPayDay(clients[i]);
|
getPlayerData(clients[i]).payDayStart = sdl.ticks;
|
||||||
|
playerPayDay(clients[i]);
|
||||||
|
|
||||||
//if(sdl.ticks-getPlayerData(clients[i]).payDayTickStart >= getGlobalConfig().payDayTickCount) {
|
//if(sdl.ticks-getPlayerData(clients[i]).payDayTickStart >= getGlobalConfig().payDayTickCount) {
|
||||||
// getPlayerData(clients[i]).payDayStart = sdl.ticks;
|
// getPlayerData(clients[i]).payDayStart = sdl.ticks;
|
||||||
// playerPayDay(clients[i]);
|
// playerPayDay(clients[i]);
|
||||||
//}
|
//}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,9 +236,11 @@ function showRandomTipToAllPlayers() {
|
|||||||
|
|
||||||
let clients = getClients();
|
let clients = getClients();
|
||||||
for(let i in clients) {
|
for(let i in clients) {
|
||||||
if(isPlayerLoggedIn(clients[i]) && isPlayerSpawned(clients[i])) {
|
if(isClientInitialized(clients[i])) {
|
||||||
if(!doesPlayerHaveRandomTipsDisabled(clients[i])) {
|
if(isPlayerLoggedIn(clients[i]) && isPlayerSpawned(clients[i])) {
|
||||||
messagePlayerTimedRandomTip(null, randomTips[tipId]);
|
if(!doesPlayerHaveRandomTipsDisabled(clients[i])) {
|
||||||
|
messagePlayerTimedRandomTip(null, randomTips[tipId]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,9 @@ function getGameAreas(gameId) {
|
|||||||
*/
|
*/
|
||||||
function getPlayerData(client) {
|
function getPlayerData(client) {
|
||||||
if(client != null) {
|
if(client != null) {
|
||||||
return getServerData().clients[client.index];
|
if(isClientInitialized(client)) {
|
||||||
|
return getServerData().clients[client.index];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -456,3 +458,9 @@ function updateTimeRule() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
|
function isClientInitialized(client) {
|
||||||
|
return (typeof getServerData().clients[client.index] != "undefined");
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
Reference in New Issue
Block a user