Use getPlayerHouse for checking if in one

This commit is contained in:
Vortrex
2022-05-11 04:00:46 -05:00
parent 2fbf15fcf7
commit b01f4190ff

View File

@@ -575,10 +575,8 @@ function deleteHouse(houseId, whoDeleted = 0) {
* @return {bool} Whether or not the player was successfully removed from the house
*
*/
function removePlayerFromHouses(client) {
if(isPlayerInAnyHouse(client)) {
exitHouse(client);
}
function removePlayerFromHouse(client) {
exitHouse(client);
}
// ===========================================================================
@@ -1082,7 +1080,7 @@ function setHouseBuyPriceCommand(command, params, client) {
getHouseData(houseId).buyPrice = amount;
getHouseData(houseId).needsSaved = true;
updateHousePickupLabelData(houseId);
messageAdmins(client, `{MAINCOLOUR}You set house {houseGreen}${getHouseData(houseId).description}'s {MAINCOLOUR}for-sale price to {ALTCOLOUR}$${makeLargeNumberReadable(amount)}`);
messagePlayerSuccess(client, `{MAINCOLOUR}You set house {houseGreen}${getHouseData(houseId).description}'s{MAINCOLOUR} for-sale price to {ALTCOLOUR}$${makeLargeNumberReadable(amount)}`);
}
// ===========================================================================
@@ -1120,7 +1118,7 @@ function setHouseRentPriceCommand(command, params, client) {
getHouseData(houseId).rentPrice = amount;
getHouseData(houseId).needsSaved = true;
updateHousePickupLabelData(houseId);
messagePlayerSuccess(client, `{MAINCOLOUR}You set house {houseGreen}${getHouseData(houseId).description}'s {MAINCOLOUR}rent price to {ALTCOLOUR}$${makeLargeNumberReadable(amount)}`);
messagePlayerSuccess(client, `{MAINCOLOUR}You set house {houseGreen}${getHouseData(houseId).description}'s{MAINCOLOUR} rent price to {ALTCOLOUR}$${makeLargeNumberReadable(amount)}`);
}
// ===========================================================================
@@ -1158,12 +1156,6 @@ function buyHouseCommand(command, params, client) {
// ===========================================================================
function isPlayerInAnyHouse(client) {
return doesEntityDataExist(client, "vrr.inHouse");
}
// ===========================================================================
/**
* @param {number} houseIndex - The data index of the house
* @return {HouseData} The house's data (class instance)
@@ -1250,8 +1242,8 @@ function deleteHouseExitBlip(houseId) {
function reloadAllHousesCommand(command, params, client) {
let clients = getClients();
for(let i in clients) {
if(isPlayerInAnyHouse(clients[i])) {
removePlayerFromHouses(clients[i]);
if(getPlayerHouse(clients[i]) != -1) {
removePlayerFromHouse(clients[i]);
}
}
@@ -1267,7 +1259,7 @@ function reloadAllHousesCommand(command, params, client) {
createAllHousePickups();
createAllHouseBlips();
announceAdminAction(`HousesReloaded`);
announceAdminAction(`AllHousesReloaded`);
}
// ===========================================================================
@@ -1279,7 +1271,6 @@ function exitHouse(client) {
setPlayerDimension(client, getServerData().house[houseId].entranceDimension);
setPlayerPosition(client, getServerData().house[houseId].entrancePosition);
}
removeEntityData(client, "vrr.inHouse");
}
// ===========================================================================