Add error checking to get client current char util

This commit is contained in:
Vortrex
2020-12-28 01:25:27 -06:00
parent e778720ea6
commit 64c297d32b

View File

@@ -1160,7 +1160,15 @@ function getPlayerData(client) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function getClientCurrentSubAccount(client) { function getClientCurrentSubAccount(client) {
if(!getPlayerData(client)) {
return false;
}
let subAccountId = getPlayerData(client).currentSubAccount; let subAccountId = getPlayerData(client).currentSubAccount;
if(subAccountId == -1) {
return false;
}
return getPlayerData(client).subAccounts[subAccountId]; return getPlayerData(client).subAccounts[subAccountId];
} }
@@ -1820,15 +1828,23 @@ async function waitUntil(condition) {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
function resetClientStuff(client) { function resetClientStuff(client) {
if(isClientOnJobRoute(client)) { if(isPlayerOnJobRoute(client)) {
stopJobRoute(client); stopJobRoute(client);
} }
if(getClientData(client).rentingVehicle) { if(getPlayerData(client).rentingVehicle) {
stopRentingVehicle(client); stopRentingVehicle(client);
} }
getClientData(client).lastVehicle = null; getPlayerData(client).lastVehicle = null;
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
function sendAllLabelsToPlayer(client) {
sendAllBusinessLabelsToPlayer(client);
sendAllHouseLabelsToPlayer(client);
sendAllJobLabelsToPlayer(client);
}
// ----------------------------------------------------------------------------