diff --git a/scripts/client/server.js b/scripts/client/server.js index 41bf72d6..74c97b37 100644 --- a/scripts/client/server.js +++ b/scripts/client/server.js @@ -41,7 +41,7 @@ function addAllNetworkHandlers() { addNetworkEventHandler("vrr.fadeCamera", fadeLocalCamera); addNetworkEventHandler("vrr.removeFromVehicle", removeLocalPlayerFromVehicle); addNetworkEventHandler("vrr.clearWeapons", clearLocalPlayerWeapons); - addNetworkEventHandler("vrr.giveWeapon", giveLocalPlayerWeapon); + addNetworkEventHandler("vrr.giveWeapon", giveLocalPlayerWeapon); addNetworkEventHandler("vrr.position", setLocalPlayerPosition); addNetworkEventHandler("vrr.heading", setLocalPlayerHeading); addNetworkEventHandler("vrr.interior", setLocalPlayerInterior); @@ -59,6 +59,7 @@ function addAllNetworkHandlers() { addNetworkEventHandler("vrr.spawn", serverRequestedLocalPlayerSpawn); addNetworkEventHandler("vrr.clearPedState", clearLocalPedState); addNetworkEventHandler("vrr.drunkEffect", setLocalPlayerDrunkEffect); + addNetworkEventHandler("vrr.deleteLocalPlayerPed", deleteLocalPlayerPed); // Vehicle addNetworkEventHandler("vrr.vehicle", receiveVehicleFromServer); @@ -166,7 +167,7 @@ function sendResourceStartedSignalToServer() { // =========================================================================== function sendResourceStoppedSignalToServer() { - if(isConnected) { + if (isConnected) { sendNetworkEventToServer("vrr.clientStopped"); } } @@ -177,14 +178,14 @@ function set2DRendering(hudState, labelState, smallGameMessageState, scoreboardS 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(getGame() == VRR_GAME_GTA_IV) { + if (getGame() == VRR_GAME_GTA_IV) { natives.displayCash(hudState); natives.displayAmmo(hudState); natives.displayHud(hudState); natives.displayRadar(hudState); natives.displayAreaName(hudState); } else { - if(typeof setHUDEnabled != "undefined") { + if (typeof setHUDEnabled != "undefined") { setHUDEnabled(hudState); } } @@ -202,8 +203,8 @@ function onServerSpawnedLocalPlayer(state) { logToConsole(LOG_DEBUG, `[VRR.Main] Setting spawned state to ${state}`); isSpawned = state; setUpInitialGame(); - if(state) { - setTimeout(function() { + if (state) { + setTimeout(function () { calledDeathEvent = false; }, 1000); @@ -243,7 +244,7 @@ function tellServerItemActionDelayComplete() { function sendServerClientInfo() { let clientVersion = "0.0.0.0"; - if(typeof CLIENT_VERSION_MAJOR != "undefined") { + if (typeof CLIENT_VERSION_MAJOR != "undefined") { clientVersion = `${CLIENT_VERSION_MAJOR}.${CLIENT_VERSION_MINOR}.${CLIENT_VERSION_PATCH}.${CLIENT_VERSION_BUILD}`; } sendNetworkEventToServer("vrr.clientInfo", clientVersion, game.width, game.height); @@ -282,7 +283,7 @@ function updateInteriorLightsState(state) { // =========================================================================== function forceSyncElementProperties(elementId) { - if(getElementFromId(elementId) == null) { + if (getElementFromId(elementId) == null) { return false; } @@ -292,7 +293,7 @@ function forceSyncElementProperties(elementId) { // =========================================================================== function setElementCollisionsEnabled(elementId, state) { - if(getElementFromId(elementId) == null) { + if (getElementFromId(elementId) == null) { return false; } @@ -302,7 +303,7 @@ function setElementCollisionsEnabled(elementId, state) { // =========================================================================== function setLocalPlayerArmour(armour) { - if(typeof localPlayer.armour != "undefined") { + if (typeof localPlayer.armour != "undefined") { localPlayer.armour = armour; } } @@ -322,8 +323,8 @@ function setLogLevel(level) { // =========================================================================== function setLocalPlayerInfiniteRun(state) { - if(localPlayer != null) { - if(getGame() == VRR_GAME_GTA_III || getGame() == VRR_GAME_GTA_VC) { + if (localPlayer != null) { + if (getGame() == VRR_GAME_GTA_III || getGame() == VRR_GAME_GTA_VC) { game.SET_PLAYER_NEVER_GETS_TIRED(game.GET_PLAYER_ID(), boolToInt(state)); } } @@ -333,7 +334,7 @@ function setLocalPlayerInfiniteRun(state) { function setLocalPlayerSkin(skinId) { logToConsole(LOG_INFO, `[VRR.Server] Setting locale player skin to ${skinId}`); - if(getGame() == VRR_GAME_GTA_IV) { + if (getGame() == VRR_GAME_GTA_IV) { natives.changePlayerModel(natives.getPlayerId(), skinId); } else { localPlayer.skin = skinId; @@ -343,7 +344,7 @@ function setLocalPlayerSkin(skinId) { // =========================================================================== function makePedHoldObject(pedId, modelIndex) { - if(getGame() == VRR_GAME_GTA_IV) { + if (getGame() == VRR_GAME_GTA_IV) { natives.givePedAmbientObject(natives.getPedFromNetworkId(pedId), getGameConfig().objects[getGame()][modelIndex][1]) } } @@ -357,11 +358,11 @@ function sendLocalPlayerNetworkIdToServer() { // =========================================================================== function setCutsceneInterior(cutsceneName) { - if(getGame() == VRR_GAME_GTA_IV) { - if(cutsceneName == "") { + if (getGame() == VRR_GAME_GTA_IV) { + if (cutsceneName == "") { natives.clearCutscene(); } else { - if(natives.isInteriorScene()) { + if (natives.isInteriorScene()) { natives.clearCutscene(); } natives.initCutscene(cutsceneName); @@ -372,16 +373,16 @@ function setCutsceneInterior(cutsceneName) { // =========================================================================== function makeLocalPlayerPedSpeak(speechName) { - if(getGame() == VRR_GAME_GTA_IV) { + if (getGame() == VRR_GAME_GTA_IV) { // if player is in vehicle, allow megaphone (if last arg is "1", it will cancel megaphone echo) // Only speeches with _MEGAPHONE will have the bullhorn effect // Afaik it only works on police voices anyway - if(localPlayer.vehicle != null) { + if (localPlayer.vehicle != null) { natives.sayAmbientSpeech(localPlayer, speechName, true, false, 0); } else { natives.sayAmbientSpeech(localPlayer, speechName, true, false, 1); } - } else if(getGame() == VRR_GAME_GTA_III || getGame() == VRR_GAME_GTA_VC) { + } else if (getGame() == VRR_GAME_GTA_III || getGame() == VRR_GAME_GTA_VC) { // Don't have a way to get the ped ref ID and can't use ped in arg //game.SET_CHAR_SAY(game.GET_PLAYER_ID(), int); } @@ -390,7 +391,7 @@ function makeLocalPlayerPedSpeak(speechName) { // =========================================================================== function setLocalPlayerAsCopState(state) { - if(getGame() == VRR_GAME_GTA_IV) { + if (getGame() == VRR_GAME_GTA_IV) { natives.setPlayerAsCop(natives.getPlayerId(), state); natives.setPoliceIgnorePlayer(natives.getPlayerId(), state); } @@ -399,7 +400,7 @@ function setLocalPlayerAsCopState(state) { // =========================================================================== function serverRequestedLocalPlayerSpawn(skinId, position) { - if(getGame() == VRR_GAME_GTA_IV) { + if (getGame() == VRR_GAME_GTA_IV) { natives.createPlayer(skinId, position); //if(isCustomCameraSupported()) { // game.restoreCamera(true);