diff --git a/scripts/server/business.js b/scripts/server/business.js index cd12571a..3bdfbcd4 100644 --- a/scripts/server/business.js +++ b/scripts/server/business.js @@ -59,6 +59,7 @@ class BusinessData { this.needsSaved = false; this.interiorLights = true; this.type = AGRP_BIZ_TYPE_NONE; + this.propertyType = AGRP_PROPERTY_TYPE_BUSINESS; this.floorItemCache = []; this.storageItemCache = []; @@ -186,8 +187,8 @@ class BusinessGameScriptData { // =========================================================================== function initBusinessScript() { - logToConsole(LOG_INFO, "[VRR.Business]: Initializing business script ..."); - logToConsole(LOG_INFO, "[VRR.Business]: Business script initialized successfully!"); + logToConsole(LOG_INFO, "[AGRP.Business]: Initializing business script ..."); + logToConsole(LOG_INFO, "[AGRP.Business]: Business script initialized successfully!"); return true; } @@ -212,7 +213,7 @@ function loadBusinessFromId(businessId) { // =========================================================================== function loadBusinessesFromDatabase() { - logToConsole(LOG_INFO, "[VRR.Business]: Loading businesses from database ..."); + logToConsole(LOG_INFO, "[AGRP.Business]: Loading businesses from database ..."); let tempBusinesses = []; let dbConnection = connectToDatabase(); @@ -228,7 +229,7 @@ function loadBusinessesFromDatabase() { tempBusinessData.locations = loadBusinessLocationsFromDatabase(tempBusinessData.databaseId); //tempBusinessData.gameScripts = loadBusinessGameScriptsFromDatabase(tempBusinessData.databaseId); tempBusinesses.push(tempBusinessData); - logToConsole(LOG_VERBOSE, `[VRR.Business]: Business '${tempBusinessData.name}' (ID ${tempBusinessData.databaseId}) loaded from database successfully!`); + logToConsole(LOG_VERBOSE, `[AGRP.Business]: Business '${tempBusinessData.name}' (ID ${tempBusinessData.databaseId}) loaded from database successfully!`); } } freeDatabaseQuery(dbQuery); @@ -236,14 +237,14 @@ function loadBusinessesFromDatabase() { disconnectFromDatabase(dbConnection); } - logToConsole(LOG_INFO, `[VRR.Business]: ${tempBusinesses.length} businesses loaded from database successfully!`); + logToConsole(LOG_INFO, `[AGRP.Business]: ${tempBusinesses.length} businesses loaded from database successfully!`); return tempBusinesses; } // =========================================================================== function loadBusinessLocationsFromDatabase(businessId) { - logToConsole(LOG_VERBOSE, `[VRR.Business]: Loading business locations for business ${businessId} from database ...`); + logToConsole(LOG_VERBOSE, `[AGRP.Business]: Loading business locations for business ${businessId} from database ...`); let tempBusinessLocations = []; let dbConnection = connectToDatabase(); @@ -259,7 +260,7 @@ function loadBusinessLocationsFromDatabase(businessId) { while (dbAssoc = fetchQueryAssoc(dbQuery)) { let tempBusinessLocationData = new BusinessLocationData(dbAssoc); tempBusinessLocations.push(tempBusinessLocationData); - logToConsole(LOG_VERBOSE, `[VRR.Business]: Location '${tempBusinessLocationData.name}' loaded from database successfully!`); + logToConsole(LOG_VERBOSE, `[AGRP.Business]: Location '${tempBusinessLocationData.name}' loaded from database successfully!`); } } freeDatabaseQuery(dbQuery); @@ -267,7 +268,7 @@ function loadBusinessLocationsFromDatabase(businessId) { disconnectFromDatabase(dbConnection); } - logToConsole(LOG_VERBOSE, `[VRR.Business]: ${tempBusinessLocations.length} location for business ${businessId} loaded from database successfully!`); + logToConsole(LOG_VERBOSE, `[AGRP.Business]: ${tempBusinessLocations.length} location for business ${businessId} loaded from database successfully!`); return tempBusinessLocations; } @@ -275,7 +276,7 @@ function loadBusinessLocationsFromDatabase(businessId) { /* function loadBusinessGameScriptsFromDatabase(businessId) { - logToConsole(LOG_VERBOSE, `[VRR.Business]: Loading business game scripts for business ${businessId} from database ...`); + logToConsole(LOG_VERBOSE, `[AGRP.Business]: Loading business game scripts for business ${businessId} from database ...`); let tempBusinessGameScripts = []; let dbConnection = connectToDatabase(); @@ -291,7 +292,7 @@ function loadBusinessGameScriptsFromDatabase(businessId) { while(dbAssoc = fetchQueryAssoc(dbQuery)) { let tempBusinessGameScriptData = new BusinessGameScriptData(dbAssoc); tempBusinessGameScripts.push(tempBusinessGameScriptData); - logToConsole(LOG_VERBOSE, `[VRR.Business]: Game script '${tempBusinessGameScriptData.name}' loaded from database successfully!`); + logToConsole(LOG_VERBOSE, `[AGRP.Business]: Game script '${tempBusinessGameScriptData.name}' loaded from database successfully!`); } } freeDatabaseQuery(dbQuery); @@ -299,7 +300,7 @@ function loadBusinessGameScriptsFromDatabase(businessId) { disconnectFromDatabase(dbConnection); } - logToConsole(LOG_VERBOSE, `[VRR.Business]: ${tempBusinessGameScripts.length} game scripts for business ${businessId} loaded from database successfully!`); + logToConsole(LOG_VERBOSE, `[AGRP.Business]: ${tempBusinessGameScripts.length} game scripts for business ${businessId} loaded from database successfully!`); return tempBusinessGameScripts; } */ @@ -1559,7 +1560,7 @@ function orderItemForBusinessCommand(command, params, client) { let value = toInteger(splitParams.slice(-1)) || getItemTypeData(itemType).capacity; let businessId = getPlayerBusiness(client); - logToConsole(LOG_DEBUG, `[VRR.Business] ${getPlayerDisplayForConsole(client)} is ordering ${amount} ${splitParams.slice(0, -2).join(" ")} (${value})`); + logToConsole(LOG_DEBUG, `[AGRP.Business] ${getPlayerDisplayForConsole(client)} is ordering ${amount} ${splitParams.slice(0, -2).join(" ")} (${value})`); if (!getBusinessData(businessId)) { messagePlayerError(client, getLocaleString(client, "InvalidBusiness")); @@ -1899,7 +1900,7 @@ function saveBusinessToDatabase(businessId) { return false; } - logToConsole(LOG_DEBUG, `[VRR.Business]: Saving business '${tempBusinessData.name}' to database ...`); + logToConsole(LOG_DEBUG, `[AGRP.Business]: Saving business '${tempBusinessData.name}' to database ...`); let dbConnection = connectToDatabase(); if (dbConnection) { let safeBusinessName = escapeDatabaseString(dbConnection, tempBusinessData.name); @@ -1955,7 +1956,7 @@ function saveBusinessToDatabase(businessId) { disconnectFromDatabase(dbConnection); return true; } - logToConsole(LOG_DEBUG, `[VRR.Business]: Saved business '${tempBusinessData.name}' to database!`); + logToConsole(LOG_DEBUG, `[AGRP.Business]: Saved business '${tempBusinessData.name}' to database!`); return false; } @@ -2033,9 +2034,9 @@ function createBusinessEntrancePickup(businessId) { return false; } - logToConsole(LOG_VERBOSE, `[VRR.Job]: Creating entrance pickup for business ${businessData.name}`); + logToConsole(LOG_VERBOSE, `[AGRP.Job]: Creating entrance pickup for business ${businessData.name}`); - if (areServerElementsSupported()) { + if (areServerElementsSupported() && getGame() != AGRP_GAME_MAFIA_ONE) { let entrancePickup = null; if (isGameFeatureSupported("pickup")) { let pickupModelId = getGameConfig().pickupModels[getGame()].Business; @@ -2073,7 +2074,7 @@ function createBusinessEntrancePickup(businessId) { if (businessData.entrancePickupModel != 0) { pickupModelId = businessData.entrancePickupModel; } - sendBusinessToPlayer(null, businessId, businessData.name, businessData.entrancePosition, blipModelId, pickupModelId, businessData.hasInterior, doesBusinessHaveAnyItemsToBuy(businessId)); + sendBusinessToPlayer(null, businessId, businessData.name, businessData.entrancePosition, blipModelId, pickupModelId, businessData.hasInterior, businessData.buyPrice, businessData.rentPrice, doesBusinessHaveAnyItemsToBuy(businessId)); } return false; @@ -2117,7 +2118,7 @@ function createBusinessEntranceBlip(businessId) { blipModelId = businessData.entranceBlipModel; } - logToConsole(LOG_VERBOSE, `[VRR.Job]: Creating entrance blip for business ${businessData.name} (model ${blipModelId})`); + logToConsole(LOG_VERBOSE, `[AGRP.Job]: Creating entrance blip for business ${businessData.name} (model ${blipModelId})`); if (areServerElementsSupported()) { let entranceBlip = createGameBlip(businessData.entrancePosition, blipModelId, 1, getColourByType("businessBlue")); @@ -2169,7 +2170,7 @@ function createBusinessExitPickup(businessId) { return false; } - logToConsole(LOG_VERBOSE, `[VRR.Job]: Creating exit pickup for business ${businessData.name}`); + logToConsole(LOG_VERBOSE, `[AGRP.Job]: Creating exit pickup for business ${businessData.name}`); let exitPickup = null; if (isGameFeatureSupported("pickup")) { @@ -2243,7 +2244,7 @@ function createBusinessExitBlip(businessId) { blipModelId = businessData.exitBlipModel; } - logToConsole(LOG_VERBOSE, `[VRR.Job]: Creating exit blip for business ${businessData.name} (model ${blipModelId})`); + logToConsole(LOG_VERBOSE, `[AGRP.Job]: Creating exit blip for business ${businessData.name} (model ${blipModelId})`); let exitBlip = createGameBlip(businessData.exitPosition, blipModelId, 1, getColourByName("businessBlue")); if (exitBlip != null) { @@ -2849,11 +2850,11 @@ function getBusinessFloorFirstFreeItemSlot(businessId) { // Caches all items for all businesses function cacheAllBusinessItems() { - logToConsole(LOG_DEBUG, "[VRR.Business] Caching all business items ..."); + logToConsole(LOG_DEBUG, "[AGRP.Business] Caching all business items ..."); for (let i in getServerData().businesses) { cacheBusinessItems(i); } - logToConsole(LOG_DEBUG, "[VRR.Business] Cached all business items successfully!"); + logToConsole(LOG_DEBUG, "[AGRP.Business] Cached all business items successfully!"); } // =========================================================================== @@ -2864,11 +2865,11 @@ function cacheBusinessItems(businessId) { clearArray(getBusinessData(businessId).storageItemCache); //let businessData = getBusinessData(businessId); - //logToConsole(LOG_VERBOSE, `[VRR.Business] Caching business items for business ${businessId} (${businessData.name}) ...`); + //logToConsole(LOG_VERBOSE, `[AGRP.Business] Caching business items for business ${businessId} (${businessData.name}) ...`); //getBusinessData(businessId).floorItemCache = getServerData().items.filter(item => item.ownerType == AGRP_ITEM_OWNER_BIZFLOOR && item.ownerId == businessData.databaseId).map(i => i.index); //getBusinessData(businessId).storageItemCache = getServerData().items.filter(item => item.ownerType == AGRP_ITEM_OWNER_BIZSTORAGE && item.ownerId == businessData.databaseId); - logToConsole(LOG_VERBOSE, `[VRR.Business] Caching business items for business ${businessId} (${getBusinessData(businessId).name}) ...`); + logToConsole(LOG_VERBOSE, `[AGRP.Business] Caching business items for business ${businessId} (${getBusinessData(businessId).name}) ...`); for (let i in getServerData().items) { if (getItemData(i).ownerType == AGRP_ITEM_OWNER_BIZFLOOR && getItemData(i).ownerId == getBusinessData(businessId).databaseId) { getBusinessData(businessId).floorItemCache.push(i); @@ -2877,7 +2878,7 @@ function cacheBusinessItems(businessId) { } } - logToConsole(LOG_VERBOSE, `[VRR.Business] Successfully cached ${getBusinessData(businessId).floorItemCache.length} floor items and ${getBusinessData(businessId).storageItemCache} storage items for business ${businessId} (${getBusinessData(businessId).name})!`); + logToConsole(LOG_VERBOSE, `[AGRP.Business] Successfully cached ${getBusinessData(businessId).floorItemCache.length} floor items and ${getBusinessData(businessId).storageItemCache} storage items for business ${businessId} (${getBusinessData(businessId).name})!`); } // =========================================================================== diff --git a/scripts/server/house.js b/scripts/server/house.js index 4c3a2fd7..7686eed3 100644 --- a/scripts/server/house.js +++ b/scripts/server/house.js @@ -42,6 +42,7 @@ class HouseData { this.index = -1; this.needsSaved = false; this.interiorLights = true; + this.propertyType = AGRP_PROPERTY_TYPE_HOUSE; this.itemCache = []; this.locations = []; @@ -167,15 +168,15 @@ class HouseGameScriptData { // =========================================================================== function initHouseScript() { - logToConsole(LOG_INFO, "[VRR.House]: Initializing house script ..."); - logToConsole(LOG_INFO, "[VRR.House]: House script initialized successfully!"); + logToConsole(LOG_INFO, "[AGRP.House]: Initializing house script ..."); + logToConsole(LOG_INFO, "[AGRP.House]: House script initialized successfully!"); return true; } // =========================================================================== function loadHousesFromDatabase() { - logToConsole(LOG_INFO, "[VRR.House]: Loading houses from database ..."); + logToConsole(LOG_INFO, "[AGRP.House]: Loading houses from database ..."); let tempHouses = []; let dbConnection = connectToDatabase(); let dbAssoc; @@ -187,14 +188,14 @@ function loadHousesFromDatabase() { while (dbAssoc = fetchQueryAssoc(dbQuery)) { let tempHouseData = new HouseData(dbAssoc); tempHouses.push(tempHouseData); - logToConsole(LOG_VERBOSE, `[VRR.House]: House '${tempHouseData.description}' (ID ${tempHouseData.databaseId}) loaded!`); + logToConsole(LOG_VERBOSE, `[AGRP.House]: House '${tempHouseData.description}' (ID ${tempHouseData.databaseId}) loaded!`); } } freeDatabaseQuery(dbQuery); } disconnectFromDatabase(dbConnection); } - logToConsole(LOG_INFO, `[VRR.House]: ${tempHouses.length} houses loaded from database successfully!`); + logToConsole(LOG_INFO, `[AGRP.House]: ${tempHouses.length} houses loaded from database successfully!`); return tempHouses; } @@ -878,9 +879,9 @@ function getPlayerHouse(client) { // =========================================================================== function saveAllHousesToDatabase() { - logToConsole(LOG_DEBUG, `[VRR.House]: Saving all server houses to database ...`); + logToConsole(LOG_DEBUG, `[AGRP.House]: Saving all server houses to database ...`); if (getServerConfig().devServer) { - logToConsole(LOG_DEBUG | LOG_WARN, `[VRR.House]: Aborting save all houses to database, dev server is enabled.`); + logToConsole(LOG_DEBUG | LOG_WARN, `[AGRP.House]: Aborting save all houses to database, dev server is enabled.`); return false; } @@ -889,7 +890,7 @@ function saveAllHousesToDatabase() { saveHouseToDatabase(i); } } - logToConsole(LOG_INFO, `[VRR.House]: Saved all server houses to database`); + logToConsole(LOG_INFO, `[AGRP.House]: Saved all server houses to database`); } // =========================================================================== @@ -901,7 +902,7 @@ function saveHouseToDatabase(houseId) { return false; } - logToConsole(LOG_VERBOSE, `[VRR.House]: Saving house '${tempHouseData.description}' to database ...`); + logToConsole(LOG_VERBOSE, `[AGRP.House]: Saving house '${tempHouseData.description}' to database ...`); let dbConnection = connectToDatabase(); if (dbConnection) { let safeHouseDescription = escapeDatabaseString(dbConnection, tempHouseData.description); @@ -955,7 +956,7 @@ function saveHouseToDatabase(houseId) { disconnectFromDatabase(dbConnection); return true; } - logToConsole(LOG_VERBOSE, `[VRR.House]: Saved house '${tempHouseData.description}' to database!`); + logToConsole(LOG_VERBOSE, `[AGRP.House]: Saved house '${tempHouseData.description}' to database!`); return false; } @@ -969,7 +970,7 @@ function saveHouseLocationToDatabase(houseId, locationId) { return false; } - logToConsole(LOG_VERBOSE, `[VRR.House]: Saving house location ${locationId} for house ${houseId} to database ...`); + logToConsole(LOG_VERBOSE, `[AGRP.House]: Saving house location ${locationId} for house ${houseId} to database ...`); let dbConnection = connectToDatabase(); if (dbConnection) { let data = [ @@ -1010,7 +1011,7 @@ function saveHouseLocationToDatabase(houseId, locationId) { disconnectFromDatabase(dbConnection); return true; } - logToConsole(LOG_VERBOSE, `[VRR.House]: Saved location ${locationId} for house ${houseId} to database`); + logToConsole(LOG_VERBOSE, `[AGRP.House]: Saved location ${locationId} for house ${houseId} to database`); return false; } @@ -1054,7 +1055,7 @@ function createHouseEntrancePickup(houseId) { return false; } - if (areServerElementsSupported()) { + if (areServerElementsSupported() && getGame() != AGRP_GAME_MAFIA_ONE) { let entrancePickup = null; if (isGameFeatureSupported("pickup")) { let pickupModelId = getGameConfig().pickupModels[getGame()].House; @@ -1084,7 +1085,7 @@ function createHouseEntrancePickup(houseId) { if (houseData.entrancePickupModel != 0) { pickupModelId = houseData.entrancePickupModel; } - sendHouseToPlayer(null, houseId, houseId.description, houseId.entrancePosition, blipModelId, pickupModelId, houseId.hasInterior); + sendHouseToPlayer(null, houseId, houseId.description, houseId.entrancePosition, blipModelId, pickupModelId, houseData.buyPrice, houseData.rentPrice, houseId.hasInterior); } }