• 0
Kurewe

Having trouble customizing some player name code

Question

I'm using a script I found a while back for showing player's names above their heads (linked below). I'm posting this here, as I am not having problem with the base script and the original thread doesn't seem to get much attention.

I'm having an issue with trying to customize the code so that my admin's names show up red, while the player's names continue to show up blue. I did something similar with player markers on the map and it worked perfectly. When I implement the same code in the player names script, the names stop showing up at all. No errors regarding this in the RPT.

I'm stumped.

The code I am using that works:

Spoiler

nameDistance = _this select 0;
showDistance = _this select 1;

while {true} do
{
    _currentPlayerCount = count allPlayers;
    waitUntil {
        _currentPlayerCount > 1;
    };

    ShowPlayerNames = addMissionEventHandler ["Draw3D",
    {
        _players = allPlayers;
        {
            if (!(isNull _x) && (isPlayer _x) && (_x != player)) then
            {
                _distance = cameraOn distance _x;
                _alpha = (1-(_distance/nameDistance));
                _clr = [0, 0, 1, _alpha];
                _crew = crew (vehicle _x);
                _name = '';
                {
                    if (_x != player) then
                    {
                        _name = format ['%3%1%2', ['', format ['%1, ', _name]] select (_name != ''), name _x, ['', format ['[%1] ', round(player distance _x)]] select (showDistance)];
                    };
                } forEach _crew;
                _veh = vehicle _x;
                _bbr = boundingBoxReal _veh;
                _p1 = _bbr select 0;
                _p2 = _bbr select 1;
                _maxHeight = (abs ((_p2 select 2) - (_p1 select 2))) * 1.25; 
                _pos = visiblePosition _veh;
                _pos set[2,(_pos select 2) + _maxHeight];
                
                drawIcon3D['', _clr, _pos, 0, 0, 0, _name, 1, 0.03];
                // texture (null), color (_clr), position (_pos), width (0), height (0), angle (0), text (_name), shadow (1), textSize (0.03), font, textAlign, drawSideArrows
            };
        } forEach _players;
    }];

    _currentPlayerCount = count allPlayers;
    waitUntil {
        _currentPlayerCount != count allPlayers;
    };
    
    removeMissionEventHandler ["Draw3D", ShowPlayerNames];
    
    sleep 1;
};

The code I am trying to use that makes it stop working:

Spoiler

nameDistance = _this select 0;
showDistance = _this select 1;

while {true} do
{
    _currentPlayerCount = count allPlayers;
    waitUntil {
        _currentPlayerCount > 1;
    };
    
    ShowPlayerNames = addMissionEventHandler ["Draw3D",
    {
        _players = allPlayers;
        {
            if (!(isNull _x) && (isPlayer _x) && (_x != player)) then
            {
                _distance = cameraOn distance _x;
                _alpha = (1-(_distance/nameDistance));
                if ((getPlayerUID _x) in ["UID1","UID1","UID1","UID1","UID1"]) then
                {
                    _clr = [0, 1, 0, _alpha];
                }
                else
                {
                    _clr = [0, 0, 1, _alpha];
                };
                _crew = crew (vehicle _x);
                _name = '';
                {
                    if (_x != player) then
                    {
                        _name = format ['%3%1%2', ['', format ['%1, ', _name]] select (_name != ''), name _x, ['', format ['[%1] ', round(player distance _x)]] select (showDistance)];
                    };
                } forEach _crew;
                _veh = vehicle _x;
                _bbr = boundingBoxReal _veh;
                _p1 = _bbr select 0;
                _p2 = _bbr select 1;
                _maxHeight = (abs ((_p2 select 2) - (_p1 select 2))) * 1.25; 
                _pos = visiblePosition _veh;
                _pos set[2,(_pos select 2) + _maxHeight];
                
                drawIcon3D['', _clr, _pos, 0, 0, 0, _name, 1, 0.03];
                // texture (null), color (_clr), position (_pos), width (0), height (0), angle (0), text (_name), shadow (1), textSize (0.03), font, textAlign, drawSideArrows
            };
        } forEach _players;
    }];

    _currentPlayerCount = count allPlayers;
    waitUntil {
        _currentPlayerCount != count allPlayers;
    };
    
    removeMissionEventHandler ["Draw3D", ShowPlayerNames];
    
    sleep 1;
};

 

Share this post


Link to post
Share on other sites

5 answers to this question

  • 0
40 minutes ago, Kurewe said:

I'm using a script I found a while back for showing player's names above their heads (linked below). I'm posting this here, as I am not having problem with the base script and the original thread doesn't seem to get much attention.

I'm having an issue with trying to customize the code so that my admin's names show up red, while the player's names continue to show up blue. I did something similar with player markers on the map and it worked perfectly. When I implement the same code in the player names script, the names stop showing up at all. No errors regarding this in the RPT.

I'm stumped.

The code I am using that works:

  Hide contents

nameDistance = _this select 0;
showDistance = _this select 1;

while {true} do
{
    _currentPlayerCount = count allPlayers;
    waitUntil {
        _currentPlayerCount > 1;
    };

    ShowPlayerNames = addMissionEventHandler ["Draw3D",
    {
        _players = allPlayers;
        {
            if (!(isNull _x) && (isPlayer _x) && (_x != player)) then
            {
                _distance = cameraOn distance _x;
                _alpha = (1-(_distance/nameDistance));
                _clr = [0, 0, 1, _alpha];
                _crew = crew (vehicle _x);
                _name = '';
                {
                    if (_x != player) then
                    {
                        _name = format ['%3%1%2', ['', format ['%1, ', _name]] select (_name != ''), name _x, ['', format ['[%1] ', round(player distance _x)]] select (showDistance)];
                    };
                } forEach _crew;
                _veh = vehicle _x;
                _bbr = boundingBoxReal _veh;
                _p1 = _bbr select 0;
                _p2 = _bbr select 1;
                _maxHeight = (abs ((_p2 select 2) - (_p1 select 2))) * 1.25; 
                _pos = visiblePosition _veh;
                _pos set[2,(_pos select 2) + _maxHeight];
                
                drawIcon3D['', _clr, _pos, 0, 0, 0, _name, 1, 0.03];
                // texture (null), color (_clr), position (_pos), width (0), height (0), angle (0), text (_name), shadow (1), textSize (0.03), font, textAlign, drawSideArrows
            };
        } forEach _players;
    }];

    _currentPlayerCount = count allPlayers;
    waitUntil {
        _currentPlayerCount != count allPlayers;
    };
    
    removeMissionEventHandler ["Draw3D", ShowPlayerNames];
    
    sleep 1;
};

The code I am trying to use that makes it stop working:

  Hide contents

nameDistance = _this select 0;
showDistance = _this select 1;

while {true} do
{
    _currentPlayerCount = count allPlayers;
    waitUntil {
        _currentPlayerCount > 1;
    };
    
    ShowPlayerNames = addMissionEventHandler ["Draw3D",
    {
        _players = allPlayers;
        {
            if (!(isNull _x) && (isPlayer _x) && (_x != player)) then
            {
                _distance = cameraOn distance _x;
                _alpha = (1-(_distance/nameDistance));
                if ((getPlayerUID _x) in ["UID1","UID1","UID1","UID1","UID1"]) then
                {
                    _clr = [0, 1, 0, _alpha];
                }
                else
                {
                    _clr = [0, 0, 1, _alpha];
                };
                _crew = crew (vehicle _x);
                _name = '';
                {
                    if (_x != player) then
                    {
                        _name = format ['%3%1%2', ['', format ['%1, ', _name]] select (_name != ''), name _x, ['', format ['[%1] ', round(player distance _x)]] select (showDistance)];
                    };
                } forEach _crew;
                _veh = vehicle _x;
                _bbr = boundingBoxReal _veh;
                _p1 = _bbr select 0;
                _p2 = _bbr select 1;
                _maxHeight = (abs ((_p2 select 2) - (_p1 select 2))) * 1.25; 
                _pos = visiblePosition _veh;
                _pos set[2,(_pos select 2) + _maxHeight];
                
                drawIcon3D['', _clr, _pos, 0, 0, 0, _name, 1, 0.03];
                // texture (null), color (_clr), position (_pos), width (0), height (0), angle (0), text (_name), shadow (1), textSize (0.03), font, textAlign, drawSideArrows
            };
        } forEach _players;
    }];

    _currentPlayerCount = count allPlayers;
    waitUntil {
        _currentPlayerCount != count allPlayers;
    };
    
    removeMissionEventHandler ["Draw3D", ShowPlayerNames];
    
    sleep 1;
};

 

                if ((getPlayerUID _x) in ["UID1","UID1","UID1","UID1","UID1"]) then

 

I'm on mobile, by this is my guess

1 person likes this

Share this post


Link to post
Share on other sites
  • 0
11 minutes ago, GamersRoost said:

                if ((getPlayerUID _x) in ["UID1","UID1","UID1","UID1","UID1"]) then

I'm on mobile, by this is my guess

Not sure what you mean. As in that's what's breaking it?

Share this post


Link to post
Share on other sites
Advertisement
  • 0
On 9/15/2017 at 7:24 PM, Kurewe said:

Not sure what you mean. As in that's what's breaking it?

Meaning if you look in the RPT you may see this as an issue when this script is run. It will not find UID1 ECT since it does not match.

Again, this is my best guess, based on some scripts I have tried with the same UID exclusions.

Josh

Share this post


Link to post
Share on other sites
  • 0
26 minutes ago, GamersRoost said:

Meaning if you look in the RPT you may see this as an issue when this script is run. It will not find UID1 ECT since it does not match.

Again, this is my best guess, based on some scripts I have tried with the same UID exclusions.

Josh

I only put "UID" so as to not include the actual UIDs. I run with script with the proper UID numbers.

Share this post


Link to post
Share on other sites
  • 0
8 minutes ago, Kurewe said:

I only put "UID" so as to not include the actual UIDs. I run with script with the proper UID numbers.

OK thanks for clarifying.

I am at a loss. @kuplion may be able to offer more than I.

Sorry man.

Josh

Share this post


Link to post
Share on other sites
Advertisement

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

  • Recently Browsing   0 members

    No registered users viewing this page.