From 982fcf92789741b8c025aea59ef58ed06adc13ae Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Sun, 1 May 2022 15:05:19 -0500 Subject: [PATCH] Fixed move house exit and get plr house funcs --- scripts/server/house.js | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/scripts/server/house.js b/scripts/server/house.js index a1fe169e..bafd48dc 100644 --- a/scripts/server/house.js +++ b/scripts/server/house.js @@ -343,7 +343,7 @@ function setHouseInteriorTypeCommand(command, params, client) { return false; } - if(typeof getGameData().interiors[getGame()] == "undefined") { + if(typeof getGameConfig().interiors[getGame()] == "undefined") { messagePlayerError(client, `There are no interiors available for this game!`); return false; } @@ -455,7 +455,7 @@ function moveHouseEntranceCommand(command, params, client) { let houseId = getPlayerHouse(client); if(!getHouseData(houseId)) { - messagePlayer(client, getLocaleString(client, "InvalidHouse")); + messagePlayerError(client, getLocaleString(client, "InvalidHouse")); return false; } @@ -488,10 +488,10 @@ function moveHouseEntranceCommand(command, params, client) { * */ function moveHouseExitCommand(command, params, client) { - let houseId = getPlayerHouse(client); + let houseId = getClosestHouseEntrance(getPlayerPosition(client), getPlayerDimension(client)); if(!getHouseData(houseId)) { - messagePlayer(client, getLocaleString(client, "InvalidHouse")); + messagePlayerError(client, getLocaleString(client, "InvalidHouse")); return false; } @@ -661,14 +661,21 @@ function getClosestHouseExit(position, dimension) { // =========================================================================== function getPlayerHouse(client) { - let closestEntrance = getClosestHouseEntrance(getPlayerPosition(client), getPlayerDimension(client)); - if(getDistance(getPlayerPosition(client), getHouseData(closestEntrance).entrancePosition) <= getGlobalConfig().enterPropertyDistance) { - return getHouseData(closestEntrance).index - } + if(getPlayerDimension(client) == getGameConfig().mainWorldDimension[getGame()]) { + let closestEntrance = getClosestHouseEntrance(getPlayerPosition(client), getPlayerDimension(client)); + if(getDistance(getPlayerPosition(client), getHouseData(closestEntrance).entrancePosition) <= getGlobalConfig().enterPropertyDistance) { + return getHouseData(closestEntrance).index; + } + } else { + let closestEntrance = getClosestHouseEntrance(getPlayerPosition(client), getPlayerDimension(client)); + if(getDistance(getPlayerPosition(client), getHouseData(closestEntrance).entrancePosition) <= getGlobalConfig().enterPropertyDistance) { + return getHouseData(closestEntrance).index; + } - for(let i in getServerData().houses) { - if(getServerData().houses[i].exitDimension == getPlayerDimension(client)) { - return i; + for(let i in getServerData().houses) { + if(getServerData().houses[i].hasInterior && getServerData().houses[i].exitDimension == getPlayerDimension(client)) { + return i; + } } }