Fix biz withdraw/deposit

This commit is contained in:
Vortrex
2021-01-21 04:37:22 -06:00
parent 9562a7cca1
commit 460b48fcf1

View File

@@ -504,17 +504,15 @@ function withdrawFromBusinessCommand(command, params, client) {
return false; return false;
} }
let tempBusinessData = getServerData().businesses.filter(b => b.databaseId == businessId)[0]; if(getBusinessData(businessId).till < amount) {
if(getServerData().businesses[businessId].till < amount) {
messagePlayerError(client, `Business '${tempBusinessData.name}' doesn't have that much money! Use /bizbalance.`); messagePlayerError(client, `Business '${tempBusinessData.name}' doesn't have that much money! Use /bizbalance.`);
return false; return false;
} }
getServerData().businesses[businessId].till -= amount; getBusinessData(businessId).till -= amount;
getPlayerCurrentSubAccount(client).cash += amount; getPlayerCurrentSubAccount(client).cash += amount;
updatePlayerCash(client); updatePlayerCash(client);
messagePlayerSuccess(client, `You withdrew $${amount} from business [#0099FF]${tempBusinessData.name} till'`); messagePlayerSuccess(client, `You withdrew $${amount} from business [#0099FF]${getBusinessData(businessId).name} till'`);
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -540,10 +538,10 @@ function depositIntoBusinessCommand(command, params, client) {
return false; return false;
} }
getServerData().businesses[businessId].till += amount; getBusinessData(businessId).till += amount;
getPlayerCurrentSubAccount(client).cash -= amount; getPlayerCurrentSubAccount(client).cash -= amount;
updatePlayerCash(client); updatePlayerCash(client);
messagePlayerSuccess(client, `You deposited $${amount} into business [#0099FF]${tempBusinessData.name} [#FFFFFF]till'`); messagePlayerSuccess(client, `You deposited $${amount} into business [#0099FF]${getBusinessData(businessId).name} [#FFFFFF]till'`);
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -611,7 +609,7 @@ function viewBusinessTillAmountCommand(command, params, client) {
return false; return false;
} }
messagePlayerSuccess(client, `Business '${getServerData().businesses[businessId].name}' till has $'${getServerData().businesses[businessId].till}'!`); messagePlayerSuccess(client, `Business [#0099FF]${getBusinessData(businessId).name} [#FFFFFF]till has [#AAAAAA]$'${getBusinessData(businessId).till}'`);
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------