Cache house items

This commit is contained in:
Vortrex
2021-04-18 23:11:53 -05:00
parent 26cb01efa2
commit c527c6f839

View File

@@ -183,7 +183,7 @@ function setHouseInteriorTypeCommand(command, params, client) {
let houseId = getHouseFromParams(splitParams[1]) || (isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client));
if(!getHouseData(houseId)) {
messagePlayerError(client, "Business not found!");
messagePlayerError(client, "House not found!");
return false;
}
@@ -750,4 +750,22 @@ function setAllHouseIndexes() {
}
}
// ===========================================================================
function cacheAllHouseItems() {
for(let i in getServerData().houses) {
cacheHouseItems(i);
}
}
// ===========================================================================
function cacheHouseItems(houseId) {
for(let i in getServerData().items) {
if(getItemData(i).ownerType == AG_ITEM_OWNER_HOUSE && getItemData(i).ownerId == getHouseData(houseId).databaseId) {
getHouseData(houseId).itemCache.push(i);
}
}
}
// ===========================================================================