Jump to content
RAGE Multiplayer Community

Реализация кастомных нейм тегов


hartority
 Share

Recommended Posts

Привет, я представляю вам мой скрипт, который делает нейм тег, бар жизней и брони похожими на GTA:Online.

qG0EYnA.png

RLxrVIk.gif

Для начала создадим переменные для настройки нейм тегов.

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));
		
            graphics.drawText(player.name.replace('_', ' '), 4, color, 0.4, 0.4, true, x, y);
			
            if(mp.game.player.isFreeAimingAtEntity(player.handle)) {
                let y2 = y + 0.042;
				
                if(armour > 0) {
                    let x2 = x - width / 2 - border / 2;
					
                    graphics.drawRect(x2, y2, width + border * 2, 0.0085, 0, 0, 0, 200);
                    graphics.drawRect(x2, y2, width, height, 150, 150, 150, 255);
                    graphics.drawRect(x2 - width / 2 * (1 - health), y2, width * health, height, 255, 255, 255, 200);

                    x2 = x + width / 2 + border / 2;
				   
                    graphics.drawRect(x2, y2, width + border * 2, height + border * 2, 0, 0, 0, 200);
                    graphics.drawRect(x2, y2, width, height, 41, 66, 78, 255);
                    graphics.drawRect(x2 - width / 2 * (1 - armour), y2, 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);
                }
            }
        }
    })
})

Этот скрипт необходимо положить в папку client_packages и подключить в index.js.

Edited by HarrWe
  • Like 1
Link to comment
Share on other sites

12 часа назад, Meido no Hitsuji сказал:

Ну что так плохо то? Зачем тогда его выкладывать сейчас? Или это намёк? :D

Это не намёк, выложили сейчас чтобы как только 0.2 вышел, люди сразу могли найти нормальные гайды и примеры.

Edited by HarrWe
  • Like 1
Link to comment
Share on other sites

i am trying to make a lan server where we can play, i was able to run the default server files and people could connect. i downloaded the freeroam project by N1ks and tried to launch the server but i kept getting these messages 

 

 

Link to comment
Share on other sites

59 минут назад, imalik сказал:

i am trying to make a lan server where we can play, i was able to run the default server files and people could connect. i downloaded the freeroam project by N1ks and tried to launch the server but i kept getting these messages 

 

 

It do not work on 0.1.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...