From 2fbf15fcf7e1e3062824ad69ac93b057769e2087 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Wed, 11 May 2022 04:00:38 -0500 Subject: [PATCH] Use getPlayerBusiness for checking if in one --- scripts/server/business.js | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/scripts/server/business.js b/scripts/server/business.js index c49eb913..e6a4d20f 100644 --- a/scripts/server/business.js +++ b/scripts/server/business.js @@ -163,7 +163,7 @@ function createBusinessLocationCommand(command, params, client) { } let locationType = toString(getParam(params, " ", 1)); - let businessId = (isPlayerInAnyBusiness(getParam(params, " ", 2))) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client)); + let businessId = getPlayerBusiness(client); if(!areParamsEmpty(params)) { businessId = getBusinessFromParams(params); @@ -1892,10 +1892,8 @@ function deleteBusiness(businessId, deletedBy = 0) { function removePlayersFromBusiness(businessId) { getClients().forEach(function(client) { if(doesBusinessHaveInterior(businessId)) { - if(isPlayerInAnyBusiness(client)) { - if(getPlayerBusiness(client) == businessId) { - exitBusiness(client); - } + if(getPlayerBusiness(client) == businessId) { + exitBusiness(client); } } }); @@ -1912,12 +1910,8 @@ function removePlayersFromBusiness(businessId) { * @return {Boolean} Whether or not the player was forced to exit * */ -function removePlayerFromBusinesses(client) { - if(isPlayerInAnyBusiness(client)) { - exitBusiness(client); - return true; - } - +function removePlayerFromBusiness(client) { + exitBusiness(client); return false; } @@ -2094,9 +2088,7 @@ function deleteBusinessExitBlip(businessId) { function reloadAllBusinessesCommand(command, params, client) { let clients = getClients(); for(let i in clients) { - if(isPlayerInAnyBusiness(clients[i])) { - removePlayerFromBusinesses(clients[i]); - } + removePlayerFromBusiness(clients[i]); } for(let i in getServerData().businesses) {