Check player init
This commit is contained in:
@@ -128,6 +128,7 @@ 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(isClientInitialized(clients[i])) {
|
||||
if(getPlayerData(clients[i]) != false) {
|
||||
if(isPlayerLoggedIn(clients[i] && isPlayerSpawned(clients[i]))) {
|
||||
if(getPlayerData(clients[i]).rentingVehicle != false) {
|
||||
@@ -141,6 +142,7 @@ function vehicleRentCheck() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
for(let i in getServerData().vehicles) {
|
||||
@@ -168,6 +170,7 @@ function vehicleRentCheck() {
|
||||
function updatePings() {
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(isClientInitialized(clients[i])) {
|
||||
if(!clients[i].console) {
|
||||
updatePlayerPing(clients[i]);
|
||||
if(isPlayerSpawned(clients[i])) {
|
||||
@@ -175,6 +178,7 @@ function updatePings() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
@@ -205,6 +209,7 @@ function checkServerGameTime() {
|
||||
function checkPayDays() {
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(isClientInitialized(clients[i])) {
|
||||
if(isPlayerLoggedIn(clients[i]) && isPlayerSpawned(clients[i])) {
|
||||
getPlayerData(clients[i]).payDayStart = sdl.ticks;
|
||||
playerPayDay(clients[i]);
|
||||
@@ -215,6 +220,7 @@ function checkPayDays() {
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(let i in getServerData().businesses) {
|
||||
if(getBusinessData(i).ownerType != VRR_BIZOWNER_NONE && getBusinessData(i).ownerType != VRR_BIZOWNER_PUBLIC && getBusinessData(i).ownerType != VRR_BIZOWNER_FACTION) {
|
||||
@@ -230,12 +236,14 @@ function showRandomTipToAllPlayers() {
|
||||
|
||||
let clients = getClients();
|
||||
for(let i in clients) {
|
||||
if(isClientInitialized(clients[i])) {
|
||||
if(isPlayerLoggedIn(clients[i]) && isPlayerSpawned(clients[i])) {
|
||||
if(!doesPlayerHaveRandomTipsDisabled(clients[i])) {
|
||||
messagePlayerTimedRandomTip(null, randomTips[tipId]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
@@ -63,8 +63,10 @@ function getGameAreas(gameId) {
|
||||
*/
|
||||
function getPlayerData(client) {
|
||||
if(client != null) {
|
||||
if(isClientInitialized(client)) {
|
||||
return getServerData().clients[client.index];
|
||||
}
|
||||
}
|
||||
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