From d501e0009250455b0d0ee113435bffb6b061d6a6 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Sat, 20 Feb 2021 20:09:07 -0600 Subject: [PATCH] Add some IV support --- scripts/client/main.js | 6 ++++-- scripts/client/nametag.js | 9 +++++++++ scripts/server/client.js | 14 ++++++++------ scripts/server/subaccount.js | 6 +++++- third-party/mexui/Core/Native.js | 10 +++++----- third-party/mexui/mexui.js | 14 ++++++++------ 6 files changed, 39 insertions(+), 20 deletions(-) diff --git a/scripts/client/main.js b/scripts/client/main.js index 9b70293c..9c85fa6a 100644 --- a/scripts/client/main.js +++ b/scripts/client/main.js @@ -311,7 +311,9 @@ addNetworkHandler("ag.removeFromVehicle", function() { // --------------------------------------------------------------------------- function processEvent(event, deltaTime) { - gta.clearMessages(); + if(gta.game != GAME_GTA_IV) { + gta.clearMessages(); + } if(localPlayer != null) { if(isSpawned) { @@ -436,7 +438,7 @@ addEventHandler("OnDrawnHUD", function (event) { } } - if(renderLabels) { + if(renderLabels && gta.game != GAME_GTA_IV) { processLabelRendering(); } diff --git a/scripts/client/nametag.js b/scripts/client/nametag.js index 744c1996..32a2cb85 100644 --- a/scripts/client/nametag.js +++ b/scripts/client/nametag.js @@ -36,6 +36,15 @@ addNetworkHandler("ag.nametag", function(clientName, characterName, colour, paus playerColours[clientName] = colour; playerPaused[clientName] = paused; playerPing[clientName] = ping; + + if(gta.game == GAME_GTA_IV) { + let client = getPlayerFromParams(clientName); + if(client != false) { + if(client.player != null) { + client.player.setNametag(characterName, colour); + } + } + } }); // ------------------------------------------------------------------------- diff --git a/scripts/server/client.js b/scripts/server/client.js index 8fa88f39..898f0ffe 100644 --- a/scripts/server/client.js +++ b/scripts/server/client.js @@ -67,7 +67,7 @@ function addAllNetworkHandlers() { // --------------------------------------------------------------------------- function updatePlayerNameTag(client) { - logToConsole(LOG_DEBUG, `[Asshat.Client] Sending ${getPlayerDisplayForConsole(client)}'s updated nametag to all players`); + //logToConsole(LOG_DEBUG, `[Asshat.Client] Sending ${getPlayerDisplayForConsole(client)}'s updated nametag to all players`); triggerNetworkEvent("ag.nametag", null, client.name, getPlayerNameForNameTag(client), getPlayerColour(client), false, client.ping); } @@ -84,7 +84,7 @@ function updateAllPlayerNameTags() { // --------------------------------------------------------------------------- function updatePlayerPing(client) { - logToConsole(LOG_DEBUG, `[Asshat.Client] Sending ${getPlayerDisplayForConsole(client)}'s ping to all players`); + //logToConsole(LOG_DEBUG, `[Asshat.Client] Sending ${getPlayerDisplayForConsole(client)}'s ping to all players`); triggerNetworkEvent("ag.ping", null, client.name, client.ping); } @@ -187,8 +187,10 @@ function syncPlayerProperties(client) { // --------------------------------------------------------------------------- function updatePlayerSnowState(client) { - logToConsole(LOG_DEBUG, `[Asshat.Client] Setting ${getPlayerDisplayForConsole(client)}'s snow state (Falling: ${toUpperCase(getOnOffFromBool(getServerConfig().fallingSnow))}, Ground: ${toUpperCase(getOnOffFromBool(getServerConfig().groundSnow))})`); - triggerNetworkEvent("ag.snow", client, getServerConfig().fallingSnow, getServerConfig().groundSnow); + if(doesGameHaveSnow(getServerGame())) { + logToConsole(LOG_DEBUG, `[Asshat.Client] Setting ${getPlayerDisplayForConsole(client)}'s snow state (Falling: ${toUpperCase(getOnOffFromBool(getServerConfig().fallingSnow))}, Ground: ${toUpperCase(getOnOffFromBool(getServerConfig().groundSnow))})`); + triggerNetworkEvent("ag.snow", client, getServerConfig().fallingSnow, getServerConfig().groundSnow); + } } // --------------------------------------------------------------------------- @@ -444,14 +446,14 @@ function sendPlayerSetHeading(client, heading) { // --------------------------------------------------------------------------- function sendPlayerSetInterior(client, interior) { - logToConsole(LOG_DEBUG, `[Asshat.Client] Sending set heading signal to ${getPlayerDisplayForConsole(client)} (Interior: ${interior})`); + logToConsole(LOG_DEBUG, `[Asshat.Client] Sending set interior signal to ${getPlayerDisplayForConsole(client)} (Interior: ${interior})`); triggerNetworkEvent("ag.interior", client, interior); } // --------------------------------------------------------------------------- function sendPlayerFrozenState(client, state) { - logToConsole(LOG_DEBUG, `[Asshat.Client] Sending set heading signal to ${getPlayerDisplayForConsole(client)} (State: ${toUpperCase(getYesNoFromBool(state))})`); + logToConsole(LOG_DEBUG, `[Asshat.Client] Sending set frozen signal to ${getPlayerDisplayForConsole(client)} (State: ${toUpperCase(getYesNoFromBool(state))})`); triggerNetworkEvent("ag.frozen", client, state); } diff --git a/scripts/server/subaccount.js b/scripts/server/subaccount.js index 77e9641e..01c25192 100644 --- a/scripts/server/subaccount.js +++ b/scripts/server/subaccount.js @@ -245,7 +245,11 @@ function selectCharacter(client, characterId = -1) { logToConsole(LOG_DEBUG, `[Asshat.SubAccount] Spawning ${getPlayerDisplayForConsole(client)} as character ID ${getPlayerData(client).currentSubAccount} with skin ${skin} (${spawnPosition.x}, ${spawnPosition.y}, ${spawnPosition.z})`); //setPlayerCameraLookAt(client, getPosBehindPos(spawnPosition, spawnHeading, 5), spawnPosition); - spawnPlayer(client, spawnPosition, spawnHeading, skin, spawnInterior, spawnDimension); + if(getServerGame() == GAME_GTA_IV) { + spawnPlayer(client, spawnPosition, spawnHeading, skin); + } else { + spawnPlayer(client, spawnPosition, spawnHeading, skin, spawnInterior, spawnDimension); + } //spawnPlayer(p(0), getServerConfig().newCharacter.spawnPosition, 0.0, 26); logToConsole(LOG_DEBUG, `[Asshat.SubAccount] Spawned ${getPlayerDisplayForConsole(client)} as character ID ${getPlayerData(client).currentSubAccount} with skin ${skin} (${spawnPosition.x}, ${spawnPosition.y}, ${spawnPosition.z})`); diff --git a/third-party/mexui/Core/Native.js b/third-party/mexui/Core/Native.js index e3a2a96e..43746aed 100644 --- a/third-party/mexui/Core/Native.js +++ b/third-party/mexui/Core/Native.js @@ -14,9 +14,9 @@ mexui.native.loadImage = function(imageFilePath, imageName) var parts = imageFilePath.split('.'); var ext = parts[parts.length - 1].toLowerCase(); if(ext == 'png') - image = graphics.loadPNG(file); + image = drawing.loadPNG(file); else if(ext == 'bmp') - image = graphics.loadBMP(file); + image = drawing.loadBMP(file); else { logToConsole(LOG_DEBUG, 'ERROR [IMAGE LOAD] - Unsupported image file path extension. Currently only supports PNG or BMP.'); @@ -93,7 +93,7 @@ mexui.native.drawRectangleBackground = function(position, size, styles) if(backgroundColour == null || backgroundColour == 'none') return; - graphics.drawRectangle(null, position, size, backgroundColour, backgroundColour, backgroundColour, backgroundColour); + drawing.drawRectangle(null, position, size, backgroundColour, backgroundColour, backgroundColour, backgroundColour); }; mexui.native.drawRectangleBorder = function(position, size, styles) @@ -133,7 +133,7 @@ mexui.native.drawAALine = function(point1, point2, styles) if(lineColour == null || lineColour == 'none') return; - graphics.drawRectangle(null, point1, new Vec2((point2.x - point1.x) + styles.lineWeight, (point2.y - point1.y) + styles.lineWeight), lineColour, lineColour, lineColour, lineColour); + drawing.drawRectangle(null, point1, new Vec2((point2.x - point1.x) + styles.lineWeight, (point2.y - point1.y) + styles.lineWeight), lineColour, lineColour, lineColour, lineColour); }; mexui.native.drawText = function(position, size, text, styles) @@ -149,6 +149,6 @@ mexui.native.drawText = function(position, size, text, styles) mexui.native.drawImage = function(position, size, image, styles) { - graphics.drawRectangle(image, position, size); + drawing.drawRectangle(image, position, size); }; diff --git a/third-party/mexui/mexui.js b/third-party/mexui/mexui.js index e3298dc9..758ec750 100644 --- a/third-party/mexui/mexui.js +++ b/third-party/mexui/mexui.js @@ -287,12 +287,14 @@ mexui.isAnyWindowShown = function() mexui.setInput = function(showInput) { gui.showCursor(showInput, !showInput); - if(localPlayer) - { - if(showInput) - gta.setCameraLookAt(new Vec3(gta.cameraMatrix.m41, gta.cameraMatrix.m42, gta.cameraMatrix.m43), localPlayer.position, false); - else - gta.restoreCamera(false); + if(gta.game != GAME_GTA_IV) { + if(localPlayer) + { + if(showInput) + gta.setCameraLookAt(new Vec3(gta.cameraMatrix.m41, gta.cameraMatrix.m42, gta.cameraMatrix.m43), localPlayer.position, false); + else + gta.restoreCamera(false); + } } };