Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const bgWidth = 0.06;
- const bgHeight = 0.015;
- const marginLeft = 0.0015;
- const marginTop = 0.0015;
- const armourWidth = bgWidth - marginLeft * 2;
- const armourHeight = bgHeight - marginTop * 2;
- function drawRectangle(x, y, width, height, r, g, b, alpha) {
- if (!x || !y || !width || !height)
- return;
- r = r ? r : 0;
- r = g ? g : 0;
- r = b ? b : 0;
- alpha = alpha ? alpha : 255;
- return mp.game.graphics.drawRect(x+width/2, y+height/2, width, height, r, g, b, alpha);
- }
- mp.events.add('render', () => {
- const screenResolution = mp.game.graphics.getScreenActiveResolution(0, 0);
- const localPlayer = mp.players.local;
- const armour = localPlayer.getArmour();
- const headPosition = localPlayer.getBoneCoords(12844, 0, 0, 0);
- const headPositionTo2d = mp.game.graphics.world3dToScreen2d(headPosition.x, headPosition.y, headPosition.z+0.44);
- if(headPositionTo2d) {
- if(armour > 0) {
- const armourCurrentWidth = armour/100.0*armourWidth;
- const armourCurrentLess = armourWidth * Math.abs(1 - (armour/100.0)) / 2;
- drawRectangle(headPositionTo2d.x-bgWidth/2, headPositionTo2d.y-bgHeight/2, bgWidth, bgHeight, 0, 0, 0, 150);
- drawRectangle(headPositionTo2d.x-bgWidth/2+marginLeft, headPositionTo2d.y-bgHeight/2+marginTop,
- armourCurrentWidth, armourHeight, 155, 89, 182, 255);
- }
- }
- });
Add Comment
Please, Sign In to add comment