From 8e225ed4806461432f9e239f12dcf1dabdc76e31 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Sat, 26 Feb 2022 22:30:39 -0600 Subject: [PATCH] Fixes for IV --- scripts/client/animation.js | 14 +++++++++----- scripts/client/server.js | 22 ++++++++++++++++++---- scripts/client/skin-select.js | 9 ++++++--- scripts/client/utilities.js | 2 +- scripts/server/native/connected.js | 6 +++++- scripts/server/subaccount.js | 6 ++++-- 6 files changed, 43 insertions(+), 16 deletions(-) diff --git a/scripts/client/animation.js b/scripts/client/animation.js index 044d3899..2d5760e5 100644 --- a/scripts/client/animation.js +++ b/scripts/client/animation.js @@ -56,14 +56,18 @@ function makePedStopAnimation(pedId) { return false; } - if(getGame() == VRR_GAME_GTA_VC || getGame() == VRR_GAME_GTA_SA) { - getElementFromId(pedId).clearAnimations(); - } else { - getElementFromId(pedId).clearObjective(); + if(getGame() != VRR_GAME_GTA_IV) { + if(getGame() == VRR_GAME_GTA_VC || getGame() == VRR_GAME_GTA_SA) { + getElementFromId(pedId).clearAnimations(); + } else { + getElementFromId(pedId).clearObjective(); + } } if(getElementFromId(pedId) == localPlayer) { - localPlayer.collisionsEnabled = true; + if(getGame() != VRR_GAME_GTA_IV) { + localPlayer.collisionsEnabled = true; + } setLocalPlayerControlState(true, false); } } diff --git a/scripts/client/server.js b/scripts/client/server.js index a74df6f0..b5bb5da8 100644 --- a/scripts/client/server.js +++ b/scripts/client/server.js @@ -82,6 +82,7 @@ function addAllNetworkHandlers() { addNetworkEventHandler("vrr.pedAnim", makePedPlayAnimation); addNetworkEventHandler("vrr.pedStopAnim", makePedStopAnimation); + addNetworkEventHandler("vrr.localPlayerSkin", setLocalPlayerSkin); addNetworkEventHandler("vrr.forcePedAnim", forcePedAnimation); addNetworkEventHandler("vrr.hideAllGUI", hideAllGUI); addNetworkEventHandler("vrr.gameScript", setGameScriptState); @@ -128,10 +129,12 @@ function setPlayer2DRendering(hudState, labelState, smallGameMessageState, score logToConsole(LOG_DEBUG, `[VRR.Main] Updating render states (HUD: ${hudState}, Labels: ${labelState}, Bottom Text: ${smallGameMessageState}, Scoreboard: ${scoreboardState}, HotBar: ${hotBarState}, Item Action Delay: ${itemActionDelayState})`); renderHUD = hudState; - if(typeof setHUDEnabled != "undefined") { - if(getGame() == VRR_GAME_GTA_IV) { - natives.displayHud(false); - } else { + if(getGame() == VRR_GAME_GTA_IV) { + natives.displayCash(hudState); + natives.displayAmmo(hudState); + natives.displayHud(hudState); + } else { + if(typeof setHUDEnabled != "undefined") { setHUDEnabled(hudState); } } @@ -297,4 +300,15 @@ function setLocalPlayerInfiniteRun(state) { } } +// =========================================================================== + +function setLocalPlayerSkin(skinId) { + if(getGame() == VRR_GAME_GTA_IV) { + //natives.changePlayerModel(natives.getPlayerId(), skinId); + localPlayer.skin = allowedSkins[skinSelectorIndex][0]; + } else { + localPlayer.skin = skinId; + } +} + // =========================================================================== \ No newline at end of file diff --git a/scripts/client/skin-select.js b/scripts/client/skin-select.js index 95e97eff..2f3149e7 100644 --- a/scripts/client/skin-select.js +++ b/scripts/client/skin-select.js @@ -54,7 +54,8 @@ function processSkinSelectKeyPress(keyCode) { logToConsole(LOG_DEBUG, `Switching to skin ${allowedSkins[skinSelectorIndex][1]} (Index: ${skinSelectorIndex}, Skin: ${allowedSkins[skinSelectorIndex][0]})`); skinSelectMessageTextTop = allowedSkins[skinSelectorIndex][1]; if(getGame() == VRR_GAME_GTA_IV) { - natives.changePlayerModel(natives.getPlayerId(), allowedSkins[skinSelectorIndex][0]); + //natives.changePlayerModel(natives.getPlayerId(), allowedSkins[skinSelectorIndex][0]); + localPlayer.skin = allowedSkins[skinSelectorIndex][0]; } else { localPlayer.skin = allowedSkins[skinSelectorIndex][0]; } @@ -67,7 +68,8 @@ function processSkinSelectKeyPress(keyCode) { logToConsole(LOG_DEBUG, `Switching to skin ${allowedSkins[skinSelectorIndex][1]} (Index: ${skinSelectorIndex}, Skin: ${allowedSkins[skinSelectorIndex][0]})`); skinSelectMessageTextTop = allowedSkins[skinSelectorIndex][1]; if(getGame() == VRR_GAME_GTA_IV) { - natives.changePlayerModel(natives.getPlayerId(), allowedSkins[skinSelectorIndex][0]); + //natives.changePlayerModel(natives.getPlayerId(), allowedSkins[skinSelectorIndex][0]); + localPlayer.skin = allowedSkins[skinSelectorIndex][0]; } else { localPlayer.skin = allowedSkins[skinSelectorIndex][0]; } @@ -118,7 +120,8 @@ function toggleSkinSelect(state) { } if(getGame() == VRR_GAME_GTA_IV) { - natives.changePlayerModel(natives.getPlayerId(), allowedSkins[skinSelectorIndex][0]); + //natives.changePlayerModel(natives.getPlayerId(), allowedSkins[skinSelectorIndex][0]); + localPlayer.skin = allowedSkins[skinSelectorIndex][0]; } else { localPlayer.skin = allowedSkins[skinSelectorIndex][0]; } diff --git a/scripts/client/utilities.js b/scripts/client/utilities.js index 62dd0f53..0e09cedb 100644 --- a/scripts/client/utilities.js +++ b/scripts/client/utilities.js @@ -837,7 +837,7 @@ function setUpInitialGame() { natives.setPlayersDropMoneyInNetworkGame(false); natives.setSyncWeatherAndGameTime(false); natives.usePlayerColourInsteadOfTeamColour(true); - natives.setDisplayPlayerNameAndIcon(false); + natives.setDisplayPlayerNameAndIcon(natives.getPlayerId(), false); natives.removeTemporaryRadarBlipsForPickups(); natives.setPickupsFixCars(false); natives.displayCash(true); diff --git a/scripts/server/native/connected.js b/scripts/server/native/connected.js index 7197d326..7f855eb3 100644 --- a/scripts/server/native/connected.js +++ b/scripts/server/native/connected.js @@ -196,7 +196,11 @@ function removePlayerFromVehicle(client) { function setPlayerSkin(client, skinIndex) { logToConsole(LOG_DEBUG, `Setting ${getPlayerDisplayForConsole(client)}'s skin to ${getGameData().skins[getGame()][skinIndex][0]} (Index: ${skinIndex}, Name: ${getGameData().skins[getGame()][skinIndex][1]})`); - client.player.modelIndex = getGameData().skins[getGame()][skinIndex][0]; + if(getGame() == VRR_GAME_GTA_IV) { + triggerNetworkEvent("vrr.localPlayerSkin", client, getGameData().skins[getGame()][skinIndex][0]); + } else { + client.player.modelIndex = getGameData().skins[getGame()][skinIndex][0]; + } } // =========================================================================== diff --git a/scripts/server/subaccount.js b/scripts/server/subaccount.js index b0e14ecb..9428626d 100644 --- a/scripts/server/subaccount.js +++ b/scripts/server/subaccount.js @@ -371,9 +371,11 @@ function selectCharacter(client, characterId = -1) { //setPlayerCameraLookAt(client, getPosBehindPos(spawnPosition, spawnHeading, 5), spawnPosition); getPlayerData(client).pedState = VRR_PEDSTATE_SPAWNING; - if(getGame() < VRR_GAME_MAFIA_ONE) { + if(getGame() < VRR_GAME_GTA_IV) { spawnPlayer(client, spawnPosition, spawnHeading, getGameData().skins[getGame()][skin][0], spawnInterior, spawnDimension); - } else { + } else if(getGame() == VRR_GAME_GTA_IV) { + spawnPlayer(client, spawnPosition, spawnHeading, getGameData().skins[getGame()][skin][0], spawnInterior, spawnDimension); + } else if(getGame() >= VRR_GAME_MAFIA_ONE) { spawnPlayer(client, getGameData().skins[getGame()][skin][0], spawnPosition, spawnHeading); }