diff --git a/Client/Gui/infobox.js b/Client/Gui/infobox.js index 48461bb6..9be428fa 100644 --- a/Client/Gui/infobox.js +++ b/Client/Gui/infobox.js @@ -49,14 +49,15 @@ mp.events.add("toggleUi", (show) => { mp.game.ui.displayRadar(false); mp.game.ui.displayHud(false); mp.gui.chat.show(false); - + globalData.HideGui = true; } else { draw = true; mp.game.ui.displayRadar(true); mp.game.ui.displayHud(true); mp.gui.chat.show(true); + globalData.HideGui = false; } -}) +}); //function currencyFormatDE(num) { // return ('$' + num.toFixed(2).replace('.', ',').replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1.')); diff --git a/Client/Gui/nametags.js b/Client/Gui/nametags.js new file mode 100644 index 00000000..271064e1 --- /dev/null +++ b/Client/Gui/nametags.js @@ -0,0 +1,59 @@ +const maxDistance = 25 * 25; +const width = 0.03; +const height = 0.0065; +const border = 0.001; +const color = [255, 255, 255, 255]; + +mp.nametags.enabled = false; + +mp.events.add('render', (nametags) => { + const graphics = mp.game.graphics; + const screenRes = graphics.getScreenResolution(0, 0); + + nametags.forEach(nametag => { + let [player, x, y, distance] = nametag; + + if (distance <= maxDistance) { + let scale = (distance / maxDistance); + if (scale < 0.6) scale = 0.6; + + var health = player.getHealth(); + health = health < 100 ? 0 : ((health - 100) / 100); + + var armour = player.getArmour() / 100; + + y -= scale * (0.005 * (screenRes.y / 1080)); + + mp.game.graphics.drawText(player.name + " (" + mp.players.at(player.id).id + ")", [x, y], + { + font: 4, + color: [255, 255, 255, 255], + scale: [0.4, 0.4], + outline: true + }); + + if (mp.game.player.isFreeAimingAtEntity(player.handle)) { + let y2 = y + 0.042; + + if (armour > 0) { + let x2 = x - width / 2 - border / 2; + + graphics.drawRect(x, y2, width + border * 2, 0.0085, 0, 0, 0, 200); + graphics.drawRect(x, y2, width, height, 150, 150, 150, 255); + graphics.drawRect(x - width / 2 * (1 - health), y2, width * health, height, 255, 255, 255, 200); + + x2 = x + width / 2 + border / 2; + + graphics.drawRect(x, y2 + height, width + border * 2, height + border * 2, 0, 0, 0, 200); + graphics.drawRect(x, y2 + height, width, height, 41, 66, 78, 255); + graphics.drawRect(x - width / 2 * (1 - armour), y2 + height, width * armour, height, 48, 108, 135, 200); + } + else { + graphics.drawRect(x, y2, width + border * 2, height + border * 2, 0, 0, 0, 200); + graphics.drawRect(x, y2, width, height, 150, 150, 150, 255); + graphics.drawRect(x - width / 2 * (1 - health), y2, width * health, height, 255, 255, 255, 200); + } + } + } + }) +}) \ No newline at end of file diff --git a/Client/Speedometer/index.js b/Client/Speedometer/index.js index 8432188c..3527a91e 100644 --- a/Client/Speedometer/index.js +++ b/Client/Speedometer/index.js @@ -4,7 +4,7 @@ let player = mp.players.local; mp.events.add('render', () => { - if (player.vehicle && player.vehicle.getPedInSeat(-1) === player.handle && !globalData.InTuning) // Check if player is in vehicle and is driver + if (player.vehicle && player.vehicle.getPedInSeat(-1) === player.handle && !globalData.InTuning && !globalData.HideGui) // Check if player is in vehicle and is driver { if(showed === false) // Check if speedo is already showed { diff --git a/Client/index.js b/Client/index.js index 09716b71..97cb6b39 100644 --- a/Client/index.js +++ b/Client/index.js @@ -5,7 +5,8 @@ */ let globalData = { - InTuning: false + InTuning: false, + HideGui: false }; require('./CharCreator/index.js'); @@ -16,6 +17,7 @@ require('./Save/main.js'); require('./Gui/deathscreen.js'); require('./Gui/infobox.js'); +require('./Gui/nametags.js'); require('./Gui/playerlist.js'); require('./Player/keys.js');