From d2dbdf2450fc9111af706d414b36e4672c0e4538 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Tue, 29 Mar 2022 21:05:48 -0500 Subject: [PATCH] Tweaks for MafiaC compatibility --- scripts/client/sync.js | 50 +++++++++++++++++++++++++----------- scripts/server/client.js | 4 +-- scripts/server/event.js | 33 +++++++++++++++++++++--- scripts/server/subaccount.js | 8 +++--- 4 files changed, 71 insertions(+), 24 deletions(-) diff --git a/scripts/client/sync.js b/scripts/client/sync.js index 7a001b37..0f0aa1b2 100644 --- a/scripts/client/sync.js +++ b/scripts/client/sync.js @@ -390,26 +390,46 @@ function syncElementProperties(element) { } } - switch(element.type) { - case ELEMENT_VEHICLE: - syncVehicleProperties(element); - break; + if(getGame() == VRR_GAME_MAFIA_ONE) { + switch(element.type) { + case ELEMENT_VEHICLE: + syncVehicleProperties(element); + break; - case ELEMENT_PED: - syncCivilianProperties(element); - break; + case ELEMENT_PED: + syncCivilianProperties(element); + break; - case ELEMENT_PLAYER: - syncPlayerProperties(element); - break; + case ELEMENT_PLAYER: + syncPlayerProperties(element); + break; - case ELEMENT_OBJECT: - syncObjectProperties(element); - break; + default: + break; + } + } else { + switch(element.type) { + case ELEMENT_VEHICLE: + syncVehicleProperties(element); + break; - default: - break; + case ELEMENT_PED: + syncCivilianProperties(element); + break; + + case ELEMENT_PLAYER: + syncPlayerProperties(element); + break; + + case ELEMENT_OBJECT: + syncObjectProperties(element); + break; + + default: + break; + } } + } diff --git a/scripts/server/client.js b/scripts/server/client.js index 5271e7b7..dc2c1289 100644 --- a/scripts/server/client.js +++ b/scripts/server/client.js @@ -137,7 +137,7 @@ function playerClientStopped(client) { // =========================================================================== -function showGameMessage(client, text, colour, duration) { +function showGameMessage(client, text, colour, duration, fontName = "Pricedown") { logToConsole(LOG_DEBUG, `[VRR.Client] Showing game message to ${getPlayerDisplayForConsole(client)} (${text}) for ${duration} milliseconds`); sendNetworkEventToPlayer("vrr.smallGameMessage", client, text, colour, duration); } @@ -210,7 +210,7 @@ function setPlayer2DRendering(client, hudState = false, labelState = false, smal function syncPlayerProperties(client) { logToConsole(LOG_DEBUG, `[VRR.Client] Sending signal to sync ${getPlayerDisplayForConsole(client)}'s player ped properties`); - sendNetworkEventToPlayer("vrr.player.sync", null, client.player); + sendNetworkEventToPlayer("vrr.syncElement", null, client.player.id); } // =========================================================================== diff --git a/scripts/server/event.js b/scripts/server/event.js index e5c80344..e9492a2b 100644 --- a/scripts/server/event.js +++ b/scripts/server/event.js @@ -117,9 +117,8 @@ function onPlayerQuit(event, client, quitReasonId) { // =========================================================================== async function onPlayerChat(event, client, messageText) { - event.preventDefault(); - processPlayerChat(client, messageText); + event.preventDefault(); } // =========================================================================== @@ -397,7 +396,16 @@ function onPlayerDeath(client, position) { client.despawnPlayer(); getPlayerCurrentSubAccount(client).interior = closestJail.interior; getPlayerCurrentSubAccount(client).dimension = closestJail.dimension; - spawnPlayer(client, closestJail.position, closestJail.heading, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]); + + if(isPlayerWorking(client)) { + stopWorking(client); + } + + if(getGame() == VRR_GAME_MAFIA_ONE) { + spawnPlayer(client, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0], closestJail.position, closestJail.heading); + } else { + spawnPlayer(client, closestJail.position, closestJail.heading, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]); + } if(isFadeCameraSupported()) { fadeCamera(client, true, 1.0); @@ -410,7 +418,16 @@ function onPlayerDeath(client, position) { client.despawnPlayer(); getPlayerCurrentSubAccount(client).interior = closestHospital.interior; getPlayerCurrentSubAccount(client).dimension = closestHospital.dimension; - spawnPlayer(client, closestHospital.position, closestHospital.heading, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]); + + if(isPlayerWorking(client)) { + stopWorking(client); + } + + if(getGame() == VRR_GAME_MAFIA_ONE) { + spawnPlayer(client, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0], closestHospital.position, closestHospital.heading); + } else { + spawnPlayer(client, closestHospital.position, closestHospital.heading, getGameConfig().skins[getGame()][getPlayerCurrentSubAccount(client).skin][0]); + } if(isFadeCameraSupported()) { fadeCamera(client, true, 1.0); @@ -603,3 +620,11 @@ function onPlayerSpawn(client) { } // =========================================================================== + +function onPlayerCommand(event, client, command) { + if(!doesCommandExist(command)) { + processPlayerCommand(command, params, client); + } +} + +// =========================================================================== \ No newline at end of file diff --git a/scripts/server/subaccount.js b/scripts/server/subaccount.js index fbedad0d..7d5658ee 100644 --- a/scripts/server/subaccount.js +++ b/scripts/server/subaccount.js @@ -275,7 +275,7 @@ function checkNewCharacter(client, firstName, lastName) { lastName = lastName.trim(); if(doesNameContainInvalidCharacters(firstName) || doesNameContainInvalidCharacters(lastName)) { - logToConsole(LOG_WARN, `[VRR.Account] Subaccount ${firstName} ${lastName} could not be created (invalid characters in name)`); + logToConsole(LOG_INFO|LOG_WARN, `[VRR.Account] Subaccount ${firstName} ${lastName} could not be created (invalid characters in name)`); showPlayerNewCharacterFailedGUI(client, "Invalid characters in name!"); return false; } @@ -371,7 +371,7 @@ function selectCharacter(client, characterId = -1) { //setPlayerCameraLookAt(client, getPosBehindPos(spawnPosition, spawnHeading, 5), spawnPosition); getPlayerData(client).pedState = VRR_PEDSTATE_SPAWNING; - if(getGame() < VRR_GAME_GTA_IV) { + if(getGame() <= VRR_GAME_GTA_SA) { spawnPlayer(client, spawnPosition, spawnHeading, getGameConfig().skins[getGame()][skin][0], spawnInterior, spawnDimension); } else if(getGame() == VRR_GAME_GTA_IV) { spawnPlayer(client, spawnPosition, spawnHeading, getGameConfig().skins[getGame()][skin][0], spawnInterior, spawnDimension); @@ -382,7 +382,9 @@ function selectCharacter(client, characterId = -1) { //setPlayerInterior(client, spawnInterior); //setPlayerDimension(client, spawnDimension); //restorePlayerCamera(client); - } else if(getGame() >= VRR_GAME_MAFIA_ONE) { + } else if(getGame() == VRR_GAME_MAFIA_ONE) { + //spawnPlayer(client, spawnPosition, spawnHeading, getGameConfig().skins[getGame()][skin][0]); + logToConsole(LOG_DEBUG, `[VRR.SubAccount] Spawning ${getPlayerDisplayForConsole(client)} as ${getGameConfig().skins[getGame()][skin][1]} (${getGameConfig().skins[getGame()][skin][0]})`); spawnPlayer(client, getGameConfig().skins[getGame()][skin][0], spawnPosition, spawnHeading); }