SHOW:
|
|
- or go back to the newest paste.
| 1 | const bgWidth = 0.06; | |
| 2 | const bgHeight = 0.015; | |
| 3 | ||
| 4 | const marginLeft = 0.0015; | |
| 5 | const marginTop = 0.0015; | |
| 6 | ||
| 7 | const armourWidth = bgWidth - marginLeft * 2; | |
| 8 | const armourHeight = bgHeight - marginTop * 2; | |
| 9 | ||
| 10 | function drawRectangle(x, y, width, height, r, g, b, alpha) {
| |
| 11 | if (!x || !y || !width || !height) | |
| 12 | return; | |
| 13 | ||
| 14 | r = r ? r : 0; | |
| 15 | r = g ? g : 0; | |
| 16 | r = b ? b : 0; | |
| 17 | alpha = alpha ? alpha : 255; | |
| 18 | ||
| 19 | return mp.game.graphics.drawRect(x+width/2, y+height/2, width, height, r, g, b, alpha); | |
| 20 | } | |
| 21 | ||
| 22 | mp.events.add('render', () => {
| |
| 23 | const screenResolution = mp.game.graphics.getScreenActiveResolution(0, 0); | |
| 24 | const localPlayer = mp.players.local; | |
| 25 | ||
| 26 | const armour = localPlayer.getArmour(); | |
| 27 | ||
| 28 | const headPosition = localPlayer.getBoneCoords(12844, 0, 0, 0); | |
| 29 | const headPositionTo2d = mp.game.graphics.world3dToScreen2d(headPosition.x, headPosition.y, headPosition.z+0.44); | |
| 30 | ||
| 31 | if(headPositionTo2d) {
| |
| 32 | if(armour > 0) {
| |
| 33 | const armourCurrentWidth = armour/100.0*armourWidth; | |
| 34 | const armourCurrentLess = armourWidth * Math.abs(1 - (armour/100.0)) / 2; | |
| 35 | ||
| 36 | drawRectangle(headPositionTo2d.x-bgWidth/2, headPositionTo2d.y-bgHeight/2, bgWidth, bgHeight, 0, 0, 0, 150); | |
| 37 | ||
| 38 | drawRectangle(headPositionTo2d.x-bgWidth/2+marginLeft, headPositionTo2d.y-bgHeight/2+marginTop, | |
| 39 | armourCurrentWidth, armourHeight, 155, 89, 182, 255); | |
| 40 | } | |
| 41 | } | |
| 42 | }); |