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)
|
// 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(isClientInitialized(clients[i])) {
|
||||||
if(getPlayerData(clients[i]) != false) {
|
if(getPlayerData(clients[i]) != false) {
|
||||||
if(isPlayerLoggedIn(clients[i] && isPlayerSpawned(clients[i]))) {
|
if(isPlayerLoggedIn(clients[i] && isPlayerSpawned(clients[i]))) {
|
||||||
if(getPlayerData(clients[i]).rentingVehicle != false) {
|
if(getPlayerData(clients[i]).rentingVehicle != false) {
|
||||||
@@ -141,6 +142,7 @@ function vehicleRentCheck() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
for(let i in getServerData().vehicles) {
|
for(let i in getServerData().vehicles) {
|
||||||
@@ -168,6 +170,7 @@ function vehicleRentCheck() {
|
|||||||
function updatePings() {
|
function updatePings() {
|
||||||
let clients = getClients();
|
let clients = getClients();
|
||||||
for(let i in clients) {
|
for(let i in clients) {
|
||||||
|
if(isClientInitialized(clients[i])) {
|
||||||
if(!clients[i].console) {
|
if(!clients[i].console) {
|
||||||
updatePlayerPing(clients[i]);
|
updatePlayerPing(clients[i]);
|
||||||
if(isPlayerSpawned(clients[i])) {
|
if(isPlayerSpawned(clients[i])) {
|
||||||
@@ -175,6 +178,7 @@ function updatePings() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
@@ -205,6 +209,7 @@ function checkServerGameTime() {
|
|||||||
function checkPayDays() {
|
function checkPayDays() {
|
||||||
let clients = getClients();
|
let clients = getClients();
|
||||||
for(let i in clients) {
|
for(let i in clients) {
|
||||||
|
if(isClientInitialized(clients[i])) {
|
||||||
if(isPlayerLoggedIn(clients[i]) && isPlayerSpawned(clients[i])) {
|
if(isPlayerLoggedIn(clients[i]) && isPlayerSpawned(clients[i])) {
|
||||||
getPlayerData(clients[i]).payDayStart = sdl.ticks;
|
getPlayerData(clients[i]).payDayStart = sdl.ticks;
|
||||||
playerPayDay(clients[i]);
|
playerPayDay(clients[i]);
|
||||||
@@ -215,6 +220,7 @@ function checkPayDays() {
|
|||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for(let i in getServerData().businesses) {
|
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) {
|
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();
|
let clients = getClients();
|
||||||
for(let i in clients) {
|
for(let i in clients) {
|
||||||
|
if(isClientInitialized(clients[i])) {
|
||||||
if(isPlayerLoggedIn(clients[i]) && isPlayerSpawned(clients[i])) {
|
if(isPlayerLoggedIn(clients[i]) && isPlayerSpawned(clients[i])) {
|
||||||
if(!doesPlayerHaveRandomTipsDisabled(clients[i])) {
|
if(!doesPlayerHaveRandomTipsDisabled(clients[i])) {
|
||||||
messagePlayerTimedRandomTip(null, randomTips[tipId]);
|
messagePlayerTimedRandomTip(null, randomTips[tipId]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|||||||
@@ -63,8 +63,10 @@ function getGameAreas(gameId) {
|
|||||||
*/
|
*/
|
||||||
function getPlayerData(client) {
|
function getPlayerData(client) {
|
||||||
if(client != null) {
|
if(client != null) {
|
||||||
|
if(isClientInitialized(client)) {
|
||||||
return getServerData().clients[client.index];
|
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