Sign in to follow this  
hartority

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

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

Share this post


Link to post
Share on other sites
В 21.05.2017 в 19:39, kemperrr сказал:

ONLY 0.2 !!!

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

Share this post


Link to post
Share on other sites
12 часа назад, Meido no Hitsuji сказал:

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

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

Edited by HarrWe
  • Like 1

Share this post


Link to post
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 

 

 

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.