Don't loop houses if there are none

This commit is contained in:
Vortrex
2022-05-30 07:40:48 -05:00
parent a097da7a63
commit c4916adc55

View File

@@ -659,6 +659,7 @@ function getClosestHouseExit(position, dimension) {
// =========================================================================== // ===========================================================================
function getPlayerHouse(client) { function getPlayerHouse(client) {
if(getServerData().houses.length > 0) {
if(getPlayerDimension(client) == getGameConfig().mainWorldDimension[getGame()]) { if(getPlayerDimension(client) == getGameConfig().mainWorldDimension[getGame()]) {
let closestEntrance = getClosestHouseEntrance(getPlayerPosition(client), getPlayerDimension(client)); let closestEntrance = getClosestHouseEntrance(getPlayerPosition(client), getPlayerDimension(client));
if(getDistance(getPlayerPosition(client), getHouseData(closestEntrance).entrancePosition) <= getGlobalConfig().enterPropertyDistance) { if(getDistance(getPlayerPosition(client), getHouseData(closestEntrance).entrancePosition) <= getGlobalConfig().enterPropertyDistance) {
@@ -676,6 +677,7 @@ function getPlayerHouse(client) {
} }
} }
} }
}
return -1; return -1;
} }