Check if player is actually in house before forcing out
This commit is contained in:
@@ -692,8 +692,13 @@ function deleteHouseCommand(command, params, client) {
|
|||||||
* @return {bool} Whether or not the house was successfully deleted
|
* @return {bool} Whether or not the house was successfully deleted
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function deleteHouse(houseId, whoDeleted = 0) {
|
function deleteHouse(houseIndex, whoDeleted = 0) {
|
||||||
let tempHouseData = getServerData().houses[houseId];
|
if (!getHouseData(houseIndex)) {
|
||||||
|
messagePlayerError(client, getLocaleString(client, "InvalidHouse"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
let tempHouseData = getServerData().houses[houseIndex];
|
||||||
|
|
||||||
let dbConnection = connectToDatabase();
|
let dbConnection = connectToDatabase();
|
||||||
let dbQuery = null;
|
let dbQuery = null;
|
||||||
@@ -706,15 +711,15 @@ function deleteHouse(houseId, whoDeleted = 0) {
|
|||||||
disconnectFromDatabase(dbConnection);
|
disconnectFromDatabase(dbConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteHouseEntrancePickup(houseId);
|
deleteHouseEntrancePickup(houseIndex);
|
||||||
deleteHouseExitPickup(houseId);
|
deleteHouseExitPickup(houseIndex);
|
||||||
|
|
||||||
deleteHouseEntranceBlip(houseId);
|
deleteHouseEntranceBlip(houseIndex);
|
||||||
deleteHouseExitBlip(houseId);
|
deleteHouseExitBlip(houseIndex);
|
||||||
|
|
||||||
removePlayersFromHouse(houseId);
|
removePlayersFromHouse(houseIndex);
|
||||||
|
|
||||||
getServerData().houses.splice(houseId, 1);
|
getServerData().houses.splice(houseIndex, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
@@ -739,13 +744,15 @@ function removePlayerFromHouse(client) {
|
|||||||
* @return {Boolean} Whether or not the players were forced to exit
|
* @return {Boolean} Whether or not the players were forced to exit
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function removePlayersFromHouse(houseId) {
|
function removePlayersFromHouse(houseIndex) {
|
||||||
getClients().forEach(function (client) {
|
getClients().forEach(function (client) {
|
||||||
if (doesHouseHaveInterior(houseId)) {
|
if (doesHouseHaveInterior(houseIndex)) {
|
||||||
if (getPlayerHouse(client) == houseId) {
|
if (getPlayerHouse(client) == houseIndex) {
|
||||||
|
if (getPlayerInterior(client) == getHouseData(houseIndex).exitInterior && getPlayerDimension(client) == getHouseData(houseIndex).exitDimension) {
|
||||||
exitHouse(client);
|
exitHouse(client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user