Jump to content
Northup

[SOLVED] Getting player team markers on player respawn screen

Recommended Posts

I have a custom player marker system. For the most part, it functions fine. However I had to implement some workarounds. 4 sides PVP only (Blufor, Opfor, Independent and Civilian.)
Simply put, it creates markers on the map and gps minimap for each teammate, in addition to one for the player. 

However, since I am making use of civilians as a playable faction, they occasionally showed up with Blufor's team markers until I set side relations and -10000 rating for each civilian. Once that was solved I ran into a new issue: (I didn't know this) Players apparently become civilians from the moment they die until they respawn - meaning civilian positions would be relayed to a non civilian player. 
As such, I figured I might be able to make the regular markers only appear when the player is alive. That worked. So I also figured I could make some OTHER markers display based on _oldUnit in onPlayerRespawn. But I get nothing. My intent is to have RespawnOnStart = 0, so that _oldunit would have a chance to be set, because while I am sure there's a way to get the team the player selected in the lobby and display markers based on that but I wouldn't quite know where to begin.

onPlayerRespawn.sqf

params ["_oldUnit", "_killer", "_respawn", "_respawnDelay"];


_miniMapEH = ((uiNamespace getVariable "RscCustomInfoMiniMap") displayCtrl 101) ctrlAddEventHandler ["Draw", 
{
        private ["_color"];
        
        
         switch (side _oldUnit) do 
            {
                case west: 
                {
                    _color = [0, 0.3, 0.6, 1]; // Blue color for BLUFOR
                };
                case east: 
                {
                    _color = [0.5, 0, 0, 1]; // Red color for OPFOR
                };
                case independent: 
                {
                    _color = [0, 0.5, 0, 1]; // Green color for Independent
                };
                default
                {
                    _color = [0.4, 0, 0.5, 1]; // Purple color for Civilian
                };
            };
        
            // Loop through all playable units to draw icons for each player on the same side
            {
                if (side _x == side _oldUnit) then 
                {
                    // Draw colored dot icons for team players on the map
                    _this select 0 drawIcon [
                    "\A3\ui_f\data\map\markers\military\dot_CA.paa", // Icon path
                    _color, // Color based on player's side
                    getPosASLVisual _x,
                    32, // Icon width
                    32, // Icon height
                    getDirVisual _x,
                    "", // Empty text
                    1, // Scale
                    0.04, // Text size
                    "PuristaMedium", // Text font
                    "right" // Text align
                    ];
                    
                 
                  
                        _this select 0 drawIcon [
                        "\A3\ui_f\data\map\vehicleicons\iconManVirtual_ca.paa", // Icon path
                        [1, 1, 1, 0.65], // White color with 65% opacity
                        getPosASLVisual _x,
                        25, // Icon width
                        25, // Icon height
                        getDirVisual _x,
                        name _x, // Name
                        1, // Scale
                        0.04, // Text size
                        "PuristaMedium", // Text font
                        "right" // Text align
                        ];
                  
                };
            } forEach allUnits;
        
    }];
diag_log format ["_oldUnit Side: %1", side _oldUnit];

 

Share this post


Link to post
Share on other sites
2 hours ago, Northup said:

Players apparently become civilians from the moment they die until they respawn

When dealing with this you can use the side of the group of the unit.

_realSide = side group _deadUnit; 

 

2 hours ago, Northup said:

((uiNamespace getVariable "RscCustomInfoMiniMap") displayCtrl 101)

Does this exist? This variable will be Nil until the display is being shown and its onLoad has happened.

 

This...

Spoiler

         private ["_color"];        
        
         switch (side _oldUnit) do 
            {
                case west: 
                {
                    _color = [0, 0.3, 0.6, 1]; // Blue color for BLUFOR
                };
                case east: 
                {
                    _color = [0.5, 0, 0, 1]; // Red color for OPFOR
                };
                case independent: 
                {
                    _color = [0, 0.5, 0, 1]; // Green color for Independent
                };
                default
                {
                    _color = [0.4, 0, 0.5, 1]; // Purple color for Civilian
                };
            };

 

... can be replaced with just...

_color = side group _oldUnit call BIS_fnc_sideColor;

 

2 hours ago, Northup said:

while I am sure there's a way to get the team the player selected in the lobby and display markers based on that but I wouldn't quite know where to begin

Surely when the mission starts this is just the side/group of the player. Not quite sure what you mean by team.

 

Could this not be done with createMarker of type ICON, then the information would be available to all maps rather than handling them individually by placing drawIcon's on them all/

  • Like 1

Share this post


Link to post
Share on other sites
23 hours ago, Larrow said:

When dealing with this you can use the side of the group of the unit.


_realSide = side group _deadUnit; 

 

Does this exist? This variable will be Nil until the display is being shown and its onLoad has happened.

 

This...

  Reveal hidden contents


         private ["_color"];        
        
         switch (side _oldUnit) do 
            {
                case west: 
                {
                    _color = [0, 0.3, 0.6, 1]; // Blue color for BLUFOR
                };
                case east: 
                {
                    _color = [0.5, 0, 0, 1]; // Red color for OPFOR
                };
                case independent: 
                {
                    _color = [0, 0.5, 0, 1]; // Green color for Independent
                };
                default
                {
                    _color = [0.4, 0, 0.5, 1]; // Purple color for Civilian
                };
            };

 

... can be replaced with just...


_color = side group _oldUnit call BIS_fnc_sideColor;

 

Surely when the mission starts this is just the side/group of the player. Not quite sure what you mean by team.

 

Could this not be done with createMarker of type ICON, then the information would be available to all maps rather than handling them individually by placing drawIcon's on them all/


It doesn't exist, not there. That's how I display the other GPS icons. I was trying gps and map by process of elimination. 

And yes, I meant side, not team.

I wasn't aware that ICON would do that. As for groups, I was reading about them but hadn't gotten that far with it yet. Brilliant. o7

Edit: Only potential issue with markers vs icons is inability to change fonts.

Share this post


Link to post
Share on other sites

Solved.

Didn't know about factions either. 

Stored the faction as a variable in the player once they are "in game".

in initplayerlocal.ini:

params[ "_player" ];
    
    //Draw player side icons
    [] spawn NUP_fnc_playerMarkers;
    
        waitUntil {getClientStateNumber > 7};
    
    player setVariable ["playerFaction", faction player];


in fn_playerMarkers:

if (isServer) then 
    {
        waitUntil { !isNull findDisplay 12 };
        ((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["Draw", 
        {
            private ["_color", "_playerFaction"];
            diag_log format ["step 1 faction player: %1",_playerFaction];
            _playerFaction = player getVariable "playerFaction";

    switch (_playerFaction) do 
    {
        case "BLU_F": 
        {
            _color = [0, 0.3, 0.6, 1]; // Blue color for BLUFOR
        };
        case "OPF_F": 
        {
            _color = [0.5, 0, 0, 1]; // Red color for OPFOR
        };
        case "IND_F": 
        {
            _color = [0, 0.5, 0, 1]; // Green color for Independent
        };
        default
        {
            _color = [0.4, 0, 0.5, 1]; // Purple color for Civilian
        };
    };



Edit: Big thanks to you Larrow for again pointing me in the right direction.

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

×