diff --git a/scripts/server/business.js b/scripts/server/business.js index 7349e657..e821ff5a 100644 --- a/scripts/server/business.js +++ b/scripts/server/business.js @@ -73,6 +73,7 @@ class BusinessData { this.entranceBlipModel = -1; this.entrancePickup = null; this.entranceBlip = null; + this.entranceScene = ""; this.exitPosition = false; this.exitRotation = 0.0; @@ -82,6 +83,7 @@ class BusinessData { this.exitBlipModel = -1; this.exitPickup = null; this.exitBlip = null; + this.exitScene = ""; this.entranceFee = 0; this.till = 0; @@ -108,6 +110,7 @@ class BusinessData { this.entranceDimension = toInteger(dbAssoc["biz_entrance_vw"]); this.entrancePickupModel = toInteger(dbAssoc["biz_entrance_pickup"]); this.entranceBlipModel = toInteger(dbAssoc["biz_entrance_blip"]); + this.entranceScene = toString(dbAssoc["biz_entrance_scene"]); this.exitPosition = toVector3(dbAssoc["biz_exit_pos_x"], dbAssoc["biz_exit_pos_y"], dbAssoc["biz_exit_pos_z"]); this.exitRotation = toInteger(dbAssoc["biz_exit_rot_z"]); @@ -115,6 +118,7 @@ class BusinessData { this.exitDimension = toInteger(dbAssoc["biz_exit_vw"]); this.exitPickupModel = toInteger(dbAssoc["biz_exit_pickup"]); this.exitBlipModel = toInteger(dbAssoc["biz_exit_blip"]); + this.exitScene = toString(dbAssoc["biz_exit_scene"]); this.entranceFee = toInteger(dbAssoc["biz_entrance_fee"]); this.till = toInteger(dbAssoc["biz_till"]); @@ -320,7 +324,7 @@ function createBusinessCommand(command, params, client) { -1, getPlayerInterior(client), getPlayerDimension(client), - getPlayerData(client).interiorCutscene); + getPlayerData(client).interiorScene); messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} created business: {businessBlue}${params}`); } @@ -362,7 +366,7 @@ function createBusinessLocationCommand(command, params, client) { // =========================================================================== -function createBusiness(name, entrancePosition, exitPosition, entrancePickupModel = -1, entranceBlipModel = -1, entranceInterior = 0, entranceDimension = 0, entranceCutscene = -1) { +function createBusiness(name, entrancePosition, exitPosition, entrancePickupModel = -1, entranceBlipModel = -1, entranceInterior = 0, entranceDimension = 0, entranceScene = -1) { let tempBusinessData = new BusinessData(false); tempBusinessData.name = name; @@ -372,7 +376,7 @@ function createBusiness(name, entrancePosition, exitPosition, entrancePickupMode tempBusinessData.entranceBlipModel = entranceBlipModel; tempBusinessData.entranceInterior = entranceInterior; tempBusinessData.entranceDimension = entranceDimension; - tempBusinessData.entranceCutscene = entranceCutscene; + tempBusinessData.entranceScene = entranceScene; tempBusinessData.exitPosition = exitPosition; tempBusinessData.exitRotation = 0.0; @@ -380,7 +384,7 @@ function createBusiness(name, entrancePosition, exitPosition, entrancePickupMode tempBusinessData.exitBlipModel = -1; tempBusinessData.exitInterior = 0; tempBusinessData.exitDimension = 0; - tempBusinessData.exitCutscene = -1; + tempBusinessData.exitScene = -1; tempBusinessData.needsSaved = true; let businessId = getServerData().businesses.push(tempBusinessData); @@ -1099,7 +1103,8 @@ function setBusinessInteriorTypeCommand(command, params, client) { getBusinessData(businessId).exitDimension = 0; getBusinessData(businessId).exitInterior = -1; getBusinessData(businessId).hasInterior = false; - getBusinessData(businessId).interiorCutscene = ""; + getBusinessData(businessId).entranceScene = ""; + getBusinessData(businessId).exitScene = ""; getBusinessData(businessId).exitPickupModel = -1; getBusinessData(businessId).customInterior = false; messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} removed business {businessBlue}${getBusinessData(businessId).name}{MAINCOLOUR} interior`); @@ -1124,7 +1129,14 @@ function setBusinessInteriorTypeCommand(command, params, client) { getBusinessData(businessId).exitPickupModel = getGameConfig().pickupModels[getGame()].Exit; getBusinessData(businessId).hasInterior = true; getBusinessData(businessId).customInterior = getGameConfig().interiors[getGame()][typeParam][2]; - getBusinessData(businessId).interiorCutscene = getGameConfig().interiors[getGame()][typeParam][3]; + + if (isGameFeatureSupported("interiorScene")) { + if (isMainWorldScene(getPlayerData(client).scene)) { + getBusinessData(businessId).exitScene = getGameConfig().mainWorldScene[getGame()]; + } else { + getBusinessData(businessId).exitScene = getGameConfig().interiors[getGame()][typeParam][3]; + } + } } //deleteBusinessExitPickup(businessId); @@ -1183,7 +1195,7 @@ function addBusinessPropertyTemplateEntities(command, params, client) { getBusinessData(businessId).exitPickupModel = getGameConfig().pickupModels[getGame()].Exit; getBusinessData(businessId).hasInterior = true; getBusinessData(businessId).customInterior = getGameConfig().interiors[getGame()][typeParam][2]; - getBusinessData(businessId).interiorCutscene = getGameConfig().interiors[getGame()][typeParam][3]; + getBusinessData(businessId).interiorScene = getGameConfig().interiors[getGame()][typeParam][3]; } //deleteBusinessExitPickup(businessId); @@ -1903,7 +1915,7 @@ function saveBusinessToDatabase(businessId) { ["biz_entrance_vw", tempBusinessData.entranceDimension], ["biz_entrance_pickup", tempBusinessData.entrancePickupModel], ["biz_entrance_blip", tempBusinessData.entranceBlipModel], - //["biz_entrance_cutscene", tempBusinessData.entranceCutscene], + ["biz_entrance_scene", tempBusinessData.entranceScene], ["biz_exit_pos_x", tempBusinessData.exitPosition.x], ["biz_exit_pos_y", tempBusinessData.exitPosition.y], ["biz_exit_pos_z", tempBusinessData.exitPosition.z], @@ -1912,7 +1924,7 @@ function saveBusinessToDatabase(businessId) { ["biz_exit_vw", tempBusinessData.exitDimension], ["biz_exit_pickup", tempBusinessData.exitPickupModel], ["biz_exit_blip", tempBusinessData.exitBlipModel], - //["biz_exit_cutscene", tempBusinessData.exitCutscene], + ["biz_exit_scene", tempBusinessData.exitScene], ["biz_has_interior", boolToInt(tempBusinessData.hasInterior)], ["biz_interior_lights", boolToInt(tempBusinessData.interiorLights)], ["biz_label_help_type", tempBusinessData.labelHelpType], diff --git a/scripts/server/client.js b/scripts/server/client.js index 9a646fc8..6966d4b3 100644 --- a/scripts/server/client.js +++ b/scripts/server/client.js @@ -126,7 +126,7 @@ class ClientData { this.locale = 0; this.enteringVehicle = null; this.customDisconnectReason = ""; - this.interiorCutscene = -1; + this.scene = ""; this.playerBlip = null; this.alcoholLevel = 0; this.pedState = AGRP_PEDSTATE_NONE; diff --git a/scripts/server/house.js b/scripts/server/house.js index 6819a946..7de3c18e 100644 --- a/scripts/server/house.js +++ b/scripts/server/house.js @@ -55,6 +55,7 @@ class HouseData { this.entranceBlipModel = -1; this.entrancePickup = null; this.entranceBlip = null; + this.entranceScene = ""; this.exitPosition = false; this.exitRotation = 0.0; @@ -64,6 +65,7 @@ class HouseData { this.exitBlipModel = -1; this.exitPickup = null; this.exitBlip = null; + this.exitScene = ""; this.streamingRadioStation = 0; this.streamingRadioStationIndex = -1; @@ -86,6 +88,7 @@ class HouseData { this.entranceDimension = toInteger(dbAssoc["house_entrance_vw"]); this.entrancePickupModel = toInteger(dbAssoc["house_entrance_pickup"]); this.entranceBlipModel = toInteger(dbAssoc["house_entrance_blip"]); + this.entranceScene = toString(dbAssoc["house_entrance_scene"]); this.exitPosition = toVector3(toFloat(dbAssoc["house_exit_pos_x"]), toFloat(dbAssoc["house_exit_pos_y"]), toFloat(dbAssoc["house_exit_pos_z"])); this.exitRotation = toFloat(dbAssoc["house_exit_rot_z"]); @@ -93,6 +96,7 @@ class HouseData { this.exitDimension = toInteger(dbAssoc["house_exit_vw"]); this.exitPickupModel = toInteger(dbAssoc["house_exit_pickup"]); this.exitBlipModel = toInteger(dbAssoc["house_exit_blip"]); + this.exitScene = toString(dbAssoc["house_exit_scene"]); } } }; @@ -211,7 +215,7 @@ function createHouseCommand(command, params, client) { return false; } - createHouse(params, getPlayerPosition(client), toVector3(0.0, 0.0, 0.0), getGameConfig().pickupModels[getGame()].House, -1, getPlayerInterior(client), getPlayerDimension(client), getPlayerData(client).interiorCutscene); + createHouse(params, getPlayerPosition(client), toVector3(0.0, 0.0, 0.0), getGameConfig().pickupModels[getGame()].House, -1, getPlayerInterior(client), getPlayerDimension(client), getPlayerData(client).interiorScene); messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} created house: {houseGreen}${params}`); } @@ -768,7 +772,7 @@ function removePlayersFromHouse(houseIndex) { * @return {bool} Whether or not the player was successfully removed from the house * */ -function createHouse(description, entrancePosition, exitPosition, entrancePickupModel = -1, entranceBlipModel = -1, entranceInterior = 0, entranceDimension = 0, entranceCutscene = -1) { +function createHouse(description, entrancePosition, exitPosition, entrancePickupModel = -1, entranceBlipModel = -1, entranceInterior = 0, entranceDimension = 0, entranceScene = -1) { let tempHouseData = new HouseData(false); tempHouseData.description = description; @@ -778,7 +782,7 @@ function createHouse(description, entrancePosition, exitPosition, entrancePickup tempHouseData.entranceBlipModel = entranceBlipModel; tempHouseData.entranceInterior = entranceInterior; tempHouseData.entranceDimension = entranceDimension; - tempHouseData.entranceCutscene = entranceCutscene; + tempHouseData.entranceScene = entranceScene; tempHouseData.exitPosition = exitPosition; tempHouseData.exitRotation = 0.0; @@ -786,7 +790,7 @@ function createHouse(description, entrancePosition, exitPosition, entrancePickup tempHouseData.exitBlipModel = -1; tempHouseData.exitInterior = 0; tempHouseData.exitDimension = 0; - tempHouseData.exitCutscene = -1; + tempHouseData.exitScene = -1; tempHouseData.needsSaved = true; @@ -917,7 +921,7 @@ function saveHouseToDatabase(houseId) { ["house_entrance_vw", tempHouseData.entranceDimension], ["house_entrance_pickup", tempHouseData.entrancePickupModel], ["house_entrance_blip", tempHouseData.entranceBlipModel], - //["house_entrance_cutscene", tempHouseData.entranceCutscene], + ["house_entrance_scene", tempHouseData.entranceScene], ["house_exit_pos_x", tempHouseData.exitPosition.x], ["house_exit_pos_y", tempHouseData.exitPosition.y], ["house_exit_pos_z", tempHouseData.exitPosition.z], @@ -926,7 +930,7 @@ function saveHouseToDatabase(houseId) { ["house_exit_vw", tempHouseData.exitDimension], ["house_exit_pickup", tempHouseData.exitPickupModel], ["house_exit_blip", tempHouseData.exitBlipModel], - //["house_exit_cutscene", tempHouseData.exitCutscene], + ["house_exit_scene", tempHouseData.exitScene], ["house_buy_price", tempHouseData.buyPrice], ["house_rent_price", tempHouseData.rentPrice], ["house_has_interior", boolToInt(tempHouseData.hasInterior)], diff --git a/scripts/server/misc.js b/scripts/server/misc.js index 1ca906e5..5d55e552 100644 --- a/scripts/server/misc.js +++ b/scripts/server/misc.js @@ -304,35 +304,41 @@ function enterExitPropertyCommand(command, params, client) { } setTimeout(function () { - setPlayerInCutsceneInterior(client, closestProperty.exitCutscene); - setPlayerDimension(client, closestProperty.exitDimension); - setPlayerInterior(client, closestProperty.exitInterior); - setPlayerPosition(client, closestProperty.exitPosition); - setPlayerHeading(client, closestProperty.exitRotation); - setTimeout(function () { - if (isFadeCameraSupported()) { - fadeCamera(client, true, 1.0); + if (closestProperty.exitScene != "" && isGameFeatureSupported("interiorScene")) { + if (isMainWorldScene(closestProperty.exitScene)) { + setPlayerScene(client, getGameConfig().mainWorldScene[getGame()]); + } else { + setPlayerScene(client, closestProperty.exitScene); } - updateInteriorLightsForPlayer(client, closestProperty.interiorLights); - }, 1000); - //setPlayerInCutsceneInterior(client, closestProperty.exitCutscene); - //updateAllInteriorVehiclesForPlayer(client, closestProperty.exitInterior, closestProperty.exitDimension); + } else { + setPlayerDimension(client, closestProperty.exitDimension); + setPlayerInterior(client, closestProperty.exitInterior); + setPlayerPosition(client, closestProperty.exitPosition); + setPlayerHeading(client, closestProperty.exitRotation); + setTimeout(function () { + if (isFadeCameraSupported()) { + fadeCamera(client, true, 1.0); + } + updateInteriorLightsForPlayer(client, closestProperty.interiorLights); + }, 1000); + //updateAllInteriorVehiclesForPlayer(client, closestProperty.exitInterior, closestProperty.exitDimension); + + if (isBusiness) { + if (closestProperty.type == AGRP_BIZ_TYPE_PAINTBALL) { + messagePlayerAlert(client, getLocaleString(client, "JoinedPaintBall")); + startPaintBall(client); + } + } + + let radioStationIndex = closestProperty.streamingRadioStationIndex; + if (radioStationIndex != -1) { + if (getRadioStationData(radioStationIndex)) { + playRadioStreamForPlayer(client, getRadioStationData(radioStationIndex).url); + getPlayerData(client).streamingRadioStation = radioStationIndex; + } + } + } }, 1100); - - if (isBusiness) { - if (closestProperty.type == AGRP_BIZ_TYPE_PAINTBALL) { - messagePlayerAlert(client, getLocaleString(client, "JoinedPaintBall")); - startPaintBall(client); - } - } - - let radioStationIndex = closestProperty.streamingRadioStationIndex; - if (radioStationIndex != -1) { - if (getRadioStationData(radioStationIndex)) { - playRadioStreamForPlayer(client, getRadioStationData(radioStationIndex).url); - getPlayerData(client).streamingRadioStation = radioStationIndex; - } - } return true; } } else { @@ -352,53 +358,59 @@ function enterExitPropertyCommand(command, params, client) { disableCityAmbienceForPlayer(client, true); setTimeout(function () { - setPlayerInCutsceneInterior(client, closestProperty.entranceCutscene); - setPlayerPosition(client, closestProperty.entrancePosition); - setPlayerHeading(client, closestProperty.entranceRotation); - setPlayerDimension(client, closestProperty.entranceDimension); - setPlayerInterior(client, closestProperty.entranceInterior); - setTimeout(function () { - if (isFadeCameraSupported()) { - fadeCamera(client, true, 1.0); + if (closestProperty.entranceScene != "" && isGameFeatureSupported("interiorScene")) { + if (isMainWorldScene(closestProperty.entranceScene)) { + setPlayerScene(client, "agrp.mainWorldScene"); + } else { + setPlayerScene(client, closestProperty.entranceScene); + } + } else { + setPlayerPosition(client, closestProperty.entrancePosition); + setPlayerHeading(client, closestProperty.entranceRotation); + setPlayerDimension(client, closestProperty.entranceDimension); + setPlayerInterior(client, closestProperty.entranceInterior); + setTimeout(function () { + if (isFadeCameraSupported()) { + fadeCamera(client, true, 1.0); + } + + updateInteriorLightsForPlayer(client, true); + }, 1000); + + if (isBusiness) { + if (closestProperty.type == AGRP_BIZ_TYPE_PAINTBALL) { + messagePlayerAlert(client, getLocaleString(client, "LeftPaintBall")); + stopPaintBall(client); + } } - updateInteriorLightsForPlayer(client, true); - }, 1000); + clearLocalPickupsForPlayer(client); + + //setPlayerInCutsceneInterior(client, closestProperty.entranceCutscene); + stopRadioStreamForPlayer(client); + getPlayerData(client).streamingRadioStation = -1; + + // Check if exiting property was into another house/business and set radio station accordingly + let inHouse = getPlayerHouse(client); + let inBusiness = getPlayerBusiness(client); + + if (inBusiness != -1) { + if (getBusinessData(inBusiness).streamingRadioStationIndex != -1) { + if (getRadioStationData(getBusinessData(inBusiness).streamingRadioStationIndex)) { + playRadioStreamForPlayer(client, getRadioStationData(getBusinessData(inBusiness).streamingRadioStationIndex).url); + getPlayerData(client).streamingRadioStation = getBusinessData(inBusiness).streamingRadioStationIndex; + } + } + } else if (inHouse != -1) { + if (getHouseData(inHouse).streamingRadioStationIndex != -1) { + if (getRadioStationData(getHouseData(inHouse).streamingRadioStationIndex)) { + playRadioStreamForPlayer(client, getRadioStationData(getHouseData(inHouse).streamingRadioStationIndex).url); + getPlayerData(client).streamingRadioStation = getHouseData(inHouse).streamingRadioStationIndex; + } + } + } + } }, 1100); - - if (isBusiness) { - if (closestProperty.type == AGRP_BIZ_TYPE_PAINTBALL) { - messagePlayerAlert(client, getLocaleString(client, "LeftPaintBall")); - stopPaintBall(client); - } - } - - clearLocalPickupsForPlayer(client); - - //setPlayerInCutsceneInterior(client, closestProperty.entranceCutscene); - stopRadioStreamForPlayer(client); - getPlayerData(client).streamingRadioStation = -1; - - // Check if exiting property was into another house/business and set radio station accordingly - let inHouse = getPlayerHouse(client); - let inBusiness = getPlayerBusiness(client); - - if (inBusiness != -1) { - if (getBusinessData(inBusiness).streamingRadioStationIndex != -1) { - if (getRadioStationData(getBusinessData(inBusiness).streamingRadioStationIndex)) { - playRadioStreamForPlayer(client, getRadioStationData(getBusinessData(inBusiness).streamingRadioStationIndex).url); - getPlayerData(client).streamingRadioStation = getBusinessData(inBusiness).streamingRadioStationIndex; - } - } - } else if (inHouse != -1) { - if (getHouseData(inHouse).streamingRadioStationIndex != -1) { - if (getRadioStationData(getHouseData(inHouse).streamingRadioStationIndex)) { - playRadioStreamForPlayer(client, getRadioStationData(getHouseData(inHouse).streamingRadioStationIndex).url); - getPlayerData(client).streamingRadioStation = getHouseData(inHouse).streamingRadioStationIndex; - } - } - } - //logToConsole(LOG_DEBUG, `[VRR.Misc] ${getPlayerDisplayForConsole(client)} exited business ${inBusiness.name}[${inBusiness.index}/${inBusiness.databaseId}]`); return true; } diff --git a/scripts/server/netevents.js b/scripts/server/netevents.js index 5842139d..85f245fa 100644 --- a/scripts/server/netevents.js +++ b/scripts/server/netevents.js @@ -1176,9 +1176,9 @@ function requestPlayerPedNetworkId(client) { // ========================================================================== -function setPlayerInCutsceneInterior(client, cutsceneName) { - getPlayerData(client).interiorCutscene = cutsceneName; - sendNetworkEventToPlayer("agrp.cutsceneInterior", client, cutsceneName); +function setPlayerScene(client, sceneName) { + getPlayerData(client).scene = sceneName; + sendNetworkEventToPlayer("agrp.scene", client, sceneName); } // ==========================================================================