Scene stuff

This commit is contained in:
Vortrex
2023-03-05 20:44:34 -06:00
parent dbef2a2d5d
commit 07cd95b861
3 changed files with 74 additions and 36 deletions

View File

@@ -47,6 +47,7 @@ class SubAccountData {
this.inBusiness = 0; this.inBusiness = 0;
this.accent = ""; this.accent = "";
this.payDayAmount = 0; this.payDayAmount = 0;
this.scene = "";
this.bodyParts = { this.bodyParts = {
hair: [0, 0], hair: [0, 0],
@@ -96,6 +97,7 @@ class SubAccountData {
this.inHouse = toInteger(dbAssoc["sacct_inhouse"]); this.inHouse = toInteger(dbAssoc["sacct_inhouse"]);
this.inBusiness = toInteger(dbAssoc["sacct_inbusiness"]); this.inBusiness = toInteger(dbAssoc["sacct_inbusiness"]);
this.accent = toString(dbAssoc["sacct_accent"]); this.accent = toString(dbAssoc["sacct_accent"]);
this.scene = toString(dbAssoc["sacct_svr_scene"]);
this.bodyParts = { this.bodyParts = {
hair: [toInteger(dbAssoc["sacct_svr_hd_part_hair_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_part_hair_texture"]) || 0], hair: [toInteger(dbAssoc["sacct_svr_hd_part_hair_model"]) || 0, toInteger(dbAssoc["sacct_svr_hd_part_hair_texture"]) || 0],
@@ -538,6 +540,8 @@ function selectCharacter(client, characterId = -1) {
//setPlayerCameraLookAt(client, getPosBehindPos(spawnPosition, spawnHeading, 5), spawnPosition); //setPlayerCameraLookAt(client, getPosBehindPos(spawnPosition, spawnHeading, 5), spawnPosition);
getPlayerData(client).pedState = V_PEDSTATE_SPAWNING; getPlayerData(client).pedState = V_PEDSTATE_SPAWNING;
getPlayerData(client).scene = getPlayerCurrentSubAccount(client).scene;
if (getGame() <= V_GAME_GTA_IV_EFLC) { if (getGame() <= V_GAME_GTA_IV_EFLC) {
spawnPlayer(client, spawnPosition, spawnHeading, getGameConfig().skins[getGame()][skin][0], spawnInterior, spawnDimension); spawnPlayer(client, spawnPosition, spawnHeading, getGameConfig().skins[getGame()][skin][0], spawnInterior, spawnDimension);
onPlayerSpawn(client); onPlayerSpawn(client);

View File

@@ -542,33 +542,31 @@ function processPlayerEnteringExitingProperty(client) {
} }
if (pedState == V_PEDSTATE_ENTERINGPROPERTY) { if (pedState == V_PEDSTATE_ENTERINGPROPERTY) {
logToConsole(LOG_VERBOSE, `[V.RP.Utilities]: Processing property ENTER for player ${getPlayerDisplayForConsole(client)} ...`); logToConsole(LOG_DEBUG, `[V.RP.Utilities]: Processing property ENTER for player ${getPlayerDisplayForConsole(client)} ...`);
if (isGameFeatureSupported("interiorScene") && propertyData.exitScene != "") { if (isGameFeatureSupported("interiorScene") && propertyData.exitScene != "") {
logToConsole(LOG_VERBOSE, `[V.RP.Utilities]: Player ${getPlayerDisplayForConsole(client)} is entering a property with interior scene (${propertyData.exitScene})`); logToConsole(LOG_DEBUG, `[V.RP.Utilities]: Player ${getPlayerDisplayForConsole(client)} is entering a property with interior scene (${propertyData.exitScene}). Spawning ...`);
spawnPlayer(client, propertyData.exitPosition, propertyData.exitRotation, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]); spawnPlayer(client, propertyData.exitPosition, propertyData.exitRotation, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]);
onPlayerSpawn(client); getPlayerData(client).scene = propertyData.exitScene;
//onPlayerSpawn(client);
setPlayerControlState(client, false);
} else { } else {
setPlayerPosition(client, propertyData.exitPosition); setPlayerPosition(client, propertyData.exitPosition);
setPlayerHeading(client, propertyData.exitRotation); setPlayerHeading(client, propertyData.exitRotation);
} }
if (isGameFeatureSupported("dimension")) {
setPlayerDimension(client, propertyData.exitDimension);
}
if (isGameFeatureSupported("interior")) {
setPlayerInterior(client, propertyData.exitInterior);
}
setTimeout(function () { setTimeout(function () {
if (isFadeCameraSupported()) { if (isFadeCameraSupported()) {
logToConsole(LOG_DEBUG, `[V.RP.Utilities]: Fading camera OUT for player ${getPlayerDisplayForConsole(client)}`);
fadePlayerCamera(client, true, 1000); fadePlayerCamera(client, true, 1000);
} }
logToConsole(LOG_DEBUG, `[V.RP.Utilities]: Setting interior lights ${getOnOffFromBool(propertyData.interiorLights)} for player ${getPlayerDisplayForConsole(client)}`);
updateInteriorLightsForPlayer(client, propertyData.interiorLights); updateInteriorLightsForPlayer(client, propertyData.interiorLights);
let radioStationIndex = propertyData.streamingRadioStationIndex; let radioStationIndex = propertyData.streamingRadioStationIndex;
if (radioStationIndex != -1) { if (radioStationIndex != -1) {
if (getRadioStationData(radioStationIndex)) { if (getRadioStationData(radioStationIndex)) {
logToConsole(LOG_DEBUG, `[V.RP.Utilities]: Player ${getPlayerDisplayForConsole(client)} entered a property with a radio station set, changing their stream`);
playRadioStreamForPlayer(client, getRadioStationData(radioStationIndex).url); playRadioStreamForPlayer(client, getRadioStationData(radioStationIndex).url);
getPlayerData(client).streamingRadioStation = radioStationIndex; getPlayerData(client).streamingRadioStation = radioStationIndex;
} }
@@ -577,74 +575,110 @@ function processPlayerEnteringExitingProperty(client) {
if (getPlayerData(client).enteringExitingProperty[0] == V_PROPERTY_TYPE_BUSINESS) { if (getPlayerData(client).enteringExitingProperty[0] == V_PROPERTY_TYPE_BUSINESS) {
if (propertyData.type == V_BIZ_TYPE_PAINTBALL) { if (propertyData.type == V_BIZ_TYPE_PAINTBALL) {
logToConsole(LOG_DEBUG, `[V.RP.Utilities]: Starting paintball for player ${getOnOffFromBool(inProperty.interiorLights)}`);
startPaintBall(client); startPaintBall(client);
} }
} }
if (isGameFeatureSupported("dimension")) {
logToConsole(LOG_DEBUG, `[V.RP.Utilities]: Setting dimension for player ${getPlayerDisplayForConsole(client)} to ${propertyData.exitDimension}`);
setPlayerDimension(client, propertyData.exitDimension);
}
if (isGameFeatureSupported("interior")) {
logToConsole(LOG_DEBUG, `[V.RP.Utilities]: Setting interior for player ${getPlayerDisplayForConsole(client)} to ${propertyData.exitInterior}`);
setPlayerInterior(client, propertyData.exitInterior);
}
getPlayerData(client).inProperty = [getPlayerData(client).enteringExitingProperty[0], getPlayerData(client).enteringExitingProperty[1]]; getPlayerData(client).inProperty = [getPlayerData(client).enteringExitingProperty[0], getPlayerData(client).enteringExitingProperty[1]];
getPlayerData(client).enteringExitingProperty = null; getPlayerData(client).enteringExitingProperty = null;
getPlayerData(client).pedState = V_PEDSTATE_READY; getPlayerData(client).pedState = V_PEDSTATE_READY;
setTimeout(function () {
logToConsole(LOG_DEBUG, `[V.RP.NetEvents] Enabling all rendering states for player ${getPlayerDisplayForConsole(client)} since map switch finished`);
setPlayer2DRendering(client, true, true, true, true, true, true);
setPlayerControlState(client, true);
}, 2500);
} else if (pedState == V_PEDSTATE_EXITINGPROPERTY) { } else if (pedState == V_PEDSTATE_EXITINGPROPERTY) {
logToConsole(LOG_VERBOSE, `[V.RP.Utilities]: Processing property EXIT for player ${getPlayerDisplayForConsole(client)} from property ID ${propertyData.index}/${propertyData.databaseId} ...`); logToConsole(LOG_DEBUG, `[V.RP.Utilities]: Processing property EXIT for player ${getPlayerDisplayForConsole(client)} from property ID ${propertyData.index}/${propertyData.databaseId} ...`);
if (isGameFeatureSupported("interiorScene") && propertyData.entranceScene != "") { if (isGameFeatureSupported("interiorScene") && propertyData.entranceScene != "") {
logToConsole(LOG_VERBOSE, `[V.RP.Utilities]: Player ${getPlayerDisplayForConsole(client)} is exiting a property with external interior scene (${propertyData.entranceScene})`); logToConsole(LOG_DEBUG, `[V.RP.Utilities]: Player ${getPlayerDisplayForConsole(client)} is exiting a property with external interior scene (${propertyData.entranceScene})`);
spawnPlayer(client, propertyData.entrancePosition, propertyData.entranceRotation, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]); spawnPlayer(client, propertyData.entrancePosition, propertyData.entranceRotation, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]);
onPlayerSpawn(client); getPlayerData(client).scene = propertyData.entranceScene;
//onPlayerSpawn(client);
setPlayerControlState(client, false);
} else { } else {
setPlayerPosition(client, propertyData.entrancePosition); setPlayerPosition(client, propertyData.entrancePosition);
setPlayerHeading(client, propertyData.entranceRotation); setPlayerHeading(client, propertyData.entranceRotation);
} }
if (isGameFeatureSupported("dimension")) {
setPlayerDimension(client, propertyData.entranceDimension);
}
if (isGameFeatureSupported("interior")) {
setPlayerInterior(client, propertyData.entranceInterior);
}
// Check if exiting property was into another house/business // Check if exiting property was into another house/business
let inProperty = false; let inProperty = false;
let inPropertyType = V_PROPERTY_TYPE_NONE; let inPropertyType = V_PROPERTY_TYPE_NONE;
let inBusiness = getPlayerBusiness(client); if (getPlayerDimension(client) != getGameConfig().mainWorldDimension[getGame()]) {
if (inBusiness != -1) { let inBusiness = getPlayerBusiness(client);
inProperty = getBusinessData(inBusiness); if (inBusiness != -1) {
inPropertyType = V_PROPERTY_TYPE_BUSINESS; inProperty = getBusinessData(inBusiness);
} else { inPropertyType = V_PROPERTY_TYPE_BUSINESS;
let inHouse = getPlayerHouse(client); } else {
if (inHouse != -1) { let inHouse = getPlayerHouse(client);
inProperty = getHouseData(inHouse); if (inHouse != -1) {
inPropertyType = V_PROPERTY_TYPE_HOUSE; inProperty = getHouseData(inHouse);
inPropertyType = V_PROPERTY_TYPE_HOUSE;
}
} }
} }
setTimeout(function () { setTimeout(function () {
if (getGame() != V_GAME_MAFIA_ONE && getGame() != V_GAME_GTA_IV) { if (getGame() != V_GAME_MAFIA_ONE && getGame() != V_GAME_GTA_IV) {
if (isFadeCameraSupported()) { if (isFadeCameraSupported()) {
logToConsole(LOG_DEBUG, `[V.RP.Utilities]: Fading camera IN for player ${getPlayerDisplayForConsole(client)}`);
fadePlayerCamera(client, true, 1000); fadePlayerCamera(client, true, 1000);
} }
} }
logToConsole(LOG_DEBUG, `[V.RP.Utilities]: Setting interior lights ${getOnOffFromBool(inProperty.interiorLights)} for player ${getPlayerDisplayForConsole(client)}`);
updateInteriorLightsForPlayer(client, (inProperty != false) ? inProperty.interiorLights : true); updateInteriorLightsForPlayer(client, (inProperty != false) ? inProperty.interiorLights : true);
}, 1000); }, 1000);
logToConsole(LOG_DEBUG, `[V.RP.Utilities]: Attempting to stop paintball for player ${getOnOffFromBool(inProperty.interiorLights)}`);
stopPaintBall(client); stopPaintBall(client);
if (inProperty != false) { if (inProperty != false) {
if (getBusinessData(inBusiness).streamingRadioStationIndex != -1) { logToConsole(LOG_DEBUG, `[V.RP.Utilities]: Player ${getPlayerDisplayForConsole(client)} exited property into another property, changing radio station`);
if (getRadioStationData(getBusinessData(inBusiness).streamingRadioStationIndex)) { if (inProperty.streamingRadioStationIndex != -1) {
playRadioStreamForPlayer(client, getRadioStationData(getBusinessData(inBusiness).streamingRadioStationIndex).url); if (getRadioStationData(inProperty.streamingRadioStationIndex)) {
getPlayerData(client).streamingRadioStation = getBusinessData(inBusiness).streamingRadioStationIndex; playRadioStreamForPlayer(client, getRadioStationData(inProperty.streamingRadioStationIndex).url);
getPlayerData(client).streamingRadioStation = inProperty.streamingRadioStationIndex;
} }
} }
} else { } else {
logToConsole(LOG_DEBUG, `[V.RP.Utilities]: Player ${getPlayerDisplayForConsole(client)} exited property into main world, stopping radio station`);
stopRadioStreamForPlayer(client); stopRadioStreamForPlayer(client);
getPlayerData(client).streamingRadioStation = -1; getPlayerData(client).streamingRadioStation = -1;
} }
if (isGameFeatureSupported("dimension")) {
logToConsole(LOG_DEBUG, `[V.RP.Utilities]: Setting dimension for player ${getPlayerDisplayForConsole(client)} to ${propertyData.entranceDimension}`);
setPlayerDimension(client, propertyData.entranceDimension);
}
if (isGameFeatureSupported("interior")) {
logToConsole(LOG_DEBUG, `[V.RP.Utilities]: Setting interior for player ${getPlayerDisplayForConsole(client)} to ${propertyData.entranceInterior}`);
setPlayerInterior(client, propertyData.entranceInterior);
}
getPlayerData(client).inProperty = [inPropertyType, inProperty.index]; getPlayerData(client).inProperty = [inPropertyType, inProperty.index];
getPlayerData(client).enteringExitingProperty = null; getPlayerData(client).enteringExitingProperty = null;
getPlayerData(client).pedState = V_PEDSTATE_READY; getPlayerData(client).pedState = V_PEDSTATE_READY;
setTimeout(function () {
logToConsole(LOG_DEBUG, `[V.RP.NetEvents] Enabling all rendering states for player ${getPlayerDisplayForConsole(client)} since map switch finished`);
setPlayer2DRendering(client, true, true, true, true, true, true);
setPlayerControlState(client, true);
}, 2500);
} }
} }

View File

@@ -3227,7 +3227,7 @@ function fillLeadingZeros(number, length) {
// =========================================================================== // ===========================================================================
function isMainWorldScene(sceneName) { function isMainWorldScene(sceneName) {
return (sceneName == "V.RP.MAINWORLD"); return (sceneName == "V.RP.MAINWORLD" || sceneName == "");
} }
// =========================================================================== // ===========================================================================