Jump to content
JollyZEGoattt

help with showing player names above heads in PvP

Recommended Posts

Hello im new to the forums and new to making arma 3 mission i have made my first pvp conquest mission were players have to capture the zone and hold it i am wanting to show player names above there heads so people no there friendly at about 200m but only to show player names at further distances when there in line of sight ill post the code that i have so far any help would be great thanks.

 

  

onEachFrame {
  _units = nearestObjects[(visiblePosition player),["Man"],500];
  _units = _units - [player];

    {
    _color = switch (playerSide) do {
        case (EAST): {[1,0,0,1]};
        case (WEST): {[0,0,1,1]};
        case (independent): {[0,1,0,1]};
        case default {[1,1,1,1]};
    };
    if (side _x isEqualto playerSide) then {
      if (!(lineIntersects [getPos player, getPos _x, player, _x]) && alive _x) then {
        drawIcon3D [
          "",
          _color,
          [visiblePosition _x select 0,visiblePosition  _x select 1, ((_x modelToWorld (_x selectionPosition "head")) select 2)+.5],
          1,
          2,
          45,
          name _x,
          1,
          0.04,
          "PuristaMedium",
          "center"
        ];
      };
    };
  }forEach _units;
};

  • Like 1

Share this post


Link to post
Share on other sites
On 13/2/2018 at 10:48 PM, JollyZEGoattt said:

show player names above there heads

 

Hello there JollyZEGoattt!

 

Welcome to the forum!

But since you are asking about scripting , then you should write your problem in this session:

https://forums.bohemia.net/forums/forum/154-arma-3-mission-editing-scripting/

Share this post


Link to post
Share on other sites

I got a script , that maybe you can base on and also will change the colour , if injured:

 

drawIcon3D.sqf

//Marker color above the head 07/12/2017
fnc_color = {
private ["_unit","_he","_b","_ha","_l","_color"];
_unit = _this select 0;

_he = _unit getHitPointDamage "HitHead";//head
_b = _unit getHitPointDamage "HitBody";//body
_ha =_unit getHitPointDamage "HitHands";//Arms
_l = _unit getHitPointDamage "HitLegs";//Legs

//[r, g, b, a] - Color format. R-red, g-green, b-blue. Values from 0 to 1.- alpha channel. (0 -valued, 1-opaque)
_color = [];
    //green
    if(((_he) == 0) || ((_b) == 0) || ((_ha) == 0) || ((_l) == 0)) then  
    {
	   _color set [0,0];
	   _color set [1,1];
	   _color set [2,0];
	   _color set [3,1];
	   //[0.08,0.99,0,1]
	};
    //pink	
    if(((_he) >0.1) || ((_b) >0.1) || ((_ha) >0.1) || ((_l) >0.1)) then  
    {
	  _color set [0,1];
	  _color set [1,0.5];
	  _color set [2,0.5];
	  _color set [3,1];
	  //[0.99,0.85,0.13,1]-Orange
	  //[1,0.5,0.5,1]-pink
	};
	//red
    if(((_b) >0.6) || ((_ha) >0.6) || ((_l) >0.6)) then  
    {
	  _color set [0,1];
	  _color set [1,0];
	  _color set [2,0];
	  _color set [3,1];
	  //[1,0,0,1]
	};
	
_color	
};

addMissionEventHandler 
["Draw3D",
	{
		{
		    if((player!=_x)&&((side _x) == playerSide)) then 
		    {
			    if(_x distance player < 1000) then
			    {
				    if((((vehicle _x)!=_x)&&(_x==effectiveCommander (vehicle _x)))||((vehicle _x)==_x)) then
				    {
 				        drawIcon3D 
					    [
						  "",
                            //Colour
 							[_x] call fnc_color,
						    //position
				            if(((vehicle _x)!=_x)&&(_x==effectiveCommander (vehicle _x))) then {(vehicle _x) modelToWorld [0,0,3]}
						    else 
						    {if((vehicle _x)==_x) then {_x modelToWorld [0,0,2.3]}},
						    //width
					        if(_x distance player > 500) then { 0.05 } else { if(_x distance player > 100) then{ 0.10 } else { 0.25 }},
						    //height
					        if(_x distance player > 500) then { 0.05 } else { if(_x distance player > 100) then { 0.10 } else { 0.25 }},
						    //angle
						    0,
						    //text
                            //if(_x distance player > 500 ) then{ nil } else{
							if(_x distance player > 500 ) then{""} else{
                            if(((_x getHitPointDamage "HitHead") >0.1) || ((_x getHitPointDamage "HitBody") >0.1) || ((_x getHitPointDamage "HitHands") >0.1) || ((_x getHitPointDamage "HitLegs") >0.1)) then
							{format ["%1[injured]",name _x]}else{name _x}},
						    //shadow
						   1,
						   //Text size
						    if(_x distance player > 250) then { 0.01 } else {if(_x distance player > 100) then { 0.02} else {0.03}},
						   //font
						   "PuristaMedium"
					    ];
   				    };
				};
		    };
        } forEach playableUnits;
	}
];

 

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×