Jump to content

Northup

Member
  • Content Count

    55
  • Joined

  • Last visited

  • Medals

Posts posted by Northup


  1. 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.


  2. 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.


  3. 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];

     


  4. On 4/8/2024 at 8:43 PM, Gyu7 said:

    First of all, I'm a non-English speaking player, so I'm relying on a translator since my English skills are terrible. (Translating using Naver’s Papago.) 

     

    I'm trying to help famous Korean streamers enjoy Arma 3. In Korea, Arma 3 had a lot of difficulty accessing various information as the number of people active in it decreased significantly due to the DDoS incident that lasted about two years. (I feel infinite envy for those whose native language is English.)

     

    This streamer continues to enjoy Arma 3 with his fans and other streamers. In 2022, about 80 people gathered to enjoy the simplified King of the Hill, and in 2023 and at the end of March this year, about 80 people gathered in Altis and Tanoa to enjoy the marathon. 

     

    Before enjoying content focused on war and combat, research is needed on server problems and optimization, but it is difficult to get help from the Korean community because such a large server has never been serviced in Korea. 

     

    Our goal is to have 100+ people in one session playing PvP, and I was wondering if I could get some help. 

     

    Q1. Would using TFAR or ACRE rather than Arma 3's VON reduce the burden on the server? 

     

    Q2. I saw a topic saying that increasing server bandwidth can reduce desynchronization. Is this still valid? And what is the maximum? 

     

    Q3. How much will the frame rate drop when 100+ players battle across the area?

     

     

     

    Please understand that I have too many questions. I hope you have a nice day. 🙂

     

    Add, I think I picked the wrong topic. This is my mistake as I am not familiar with the forum. 

    Q1. Not sure, but probably not. 
    Q2. Arma has to sync an exceptionally large amount of data between the server and client. It's not so much the bandwidth these days as it is that the systems Arma was programmed to work on didn't have things like 3d vcache, and multicore processing wasn't anywhere near what it is today. Arma mostly runs on a single core, where clock speed, ram, network and vcache are king.
    Q3. That's impossible to answer unless you can somehow predict what players (or AI for that matter) are going to be doing at every exact moment during a match. That said, C4G recently held an event for KOTH servers that saw them increase the playercount to 150 on some servers. People complained, and there was an increase in desync, but not enough that I was personally bothered by it. That's the thing though. I have a 7800x3d, and I use a custom memalloc. Generally in the AO on a full infantry server, I can get 60 mostly solid fps if my viewdistance is lowered to around  1500-1000. VD down to 200 gets me 100+. There's also a public King of the Hill server maintained by Dwarden, iirc. That has something like 150 player slots. It's rarely full but when it is, it can be an interesting experience. Check it out if you can. All that is to say that your client's fps will largely be a result of their own hardware. Making a blazingly fast, state of the art server with space lasers still wouldn't overcome the limits of outdated client hardware. 


  5. It certainly helps bridge the curiosity gap that would otherwise compel some to give up, but it has way too many issues to be reliable. It invents commands that don't exist, and will then gaslight you about their existence. It has trouble understanding more of the convoluted ways Arma works under the hood. Like anything, it does a lot better if you do things in very small segments with lots of logging. It will insist your defined variable lack of capitalization is the issue, especially when it isn't.

     

    • Like 1

  6. On 10/20/2023 at 3:00 PM, tobias-ripper said:

    hi everyone. this might not be the right place to ask but its related to spawning compos. i just can't, for the life of me, find a reliable way to get an actually flat and empty area to spawn some rather large compos (20x20 being the largest). i've tried shk_pos script, isFlatEmpty, findSafePos and combinations of them all. im pretty sure the way im scripting it is flawed but at this point i just have a very bad headache from trying to figure this out. so to save you time... got something wokring that your a willing to share?
    im creating a marker randomly around the map (invade and annex style) and spawning my stuff in it's area. only 2 tasks, so far, are meant to spawn a compo. 1 is "working" cos the compo is rather small. the 20x20 is just way more complex with items inside a building (large hq type). im just overwelmed.. HELP?

    Hmm. Might make use of setterrainheight and triggers. Name the triggers something like terrainTrigger_%1. Make sure trigger c - trigger area Z size is 0.002, set itz height pos to 0. Make sure it is level with ground in vr when you save it as a comp. Then, reference those triggers in your script:

    private _triggerNames = [terrainTrigger_01, terrainTrigger_02, terrainTrigger_03, terrainTrigger_04];
    
    {
        private _triggerPos = getPosWorld _x;
        private _triggerSize = triggerArea _x;
        private _height = _triggerPos select 2;
        private _position = getPosWorld _x;
        private _triggerLength = (_triggerSize) # 0;
        private _triggerWidth = (_triggerSize) # 1;
        private _triggerAngle = (_triggerSize) # 2;
    
        private _pos = [(_position#0 + cos(_triggerAngle) * _triggerLength + sin(_triggerAngle) * _triggerWidth), (_position#1 - sin(_triggerAngle) * _triggerLength + cos(_triggerAngle) * _triggerWidth)];
        private _positionsAndHeights = [];
        _pos pushBack _height;
    
        for "_i" from 0 to (_triggerLength * 8) do {
            private _pos2 = _pos;
    
            for "_j" from 0 to (_triggerWidth * 8) do {
                _positionsAndHeights pushBack _pos2;
                _pos2 = _pos2 vectorAdd [-0.25 * sin(_triggerAngle), -0.25 * cos(_triggerAngle), 0];
            };
    
            _pos = _pos  vectorAdd [-0.25 * cos(_triggerAngle), 0.25 * sin(_triggerAngle), 0];
        };
    
        setTerrainHeight[_positionsAndHeights, true];
                
    } forEach _triggerNames;

    The downside is I'm not near math smart enough to smooth the edges, so you'll have to find a relatively open area to minimize jarring transitions (don't place it partially on a hill. 


  7. On 3/15/2023 at 2:43 PM, aurora1-4 said:

    Excellent job with this. I have been trying to find out how to do this for over a year...

    It works perfectly, apart from one thing. How would I use this if I wanted to different polygons on the map? i.e A green zone and a red zone?
    I have managed to change the colour, but can only get one polygon to show at a time.

    New to this stuff, but maybe changing the naming convention for markers based on what they are for might work (opforSpawn_1, independentSpawn_6, etc,) store them to arrays, then run the function separately on each array.


  8.  

    Hi all.

    Starting a new mission, and I want the weather to be configurable by an authorized in game admin via the parameters menu. Since it's a multiplayer mission, I want to ensure all clients match the intended setting.

    In description.ext:

    class Params
    {
        
        class BR_TimeOfDay                                                                                                
        {
            title = "Environment: Time of Day";
            values[] = {0,4,8,12,16,18,20,24};
            texts[] = {"Random Time of Day", "Dawn","Mid Morning","Noon","Afternoon","Evening","Night","Midnight"};
            default = 0;
            
        };
    };


    In initServer.sqf:

     

    // === Get the BR_daytime variable from Params in description.ext
    _BR_Time = ["BR_TimeOfDay"] call BIS_fnc_getParamValue;
    
    // === Check if host selected random. If so, select a random value from the options available, if not, use the value they selected, set date on server and broadcast to all clients. 
    if (_BR_Time == 0) then {
    _randomTime = [4, 8, 12, 16, 18, 20, 24] call BIS_fnc_selectRandom;
    [_randomTime] call BIS_fnc_paramDaytime;
    diag_log format["_randomTime value: %1", _randomTime]; // Debug output
    ["setDate", [2024, 10, 10, _randomTime, 0]] call BIS_fnc_MP;
    } else {
    [_BR_Time] call BIS_fnc_paramDaytime;
     diag_log format["_BR_Time value: %1", _BR_Time]; // Debug output
    ["setDate", [2024, 10, 10, _BR_Time, 0]] call BIS_fnc_MP;
    };



    The code "works" but I get a hint error:
     

    [BIS_fnc_MP] Error: type Array, expected string, on index 1, in ["setDate"[2024,10,10,8,0],0,false,false]



    In this case, the "8" in ["setDate"[2024,10,10,8,0],0,false,false] does represent the correct value being passed, so I am at a loss as to what is causing it. The same is true when "random" is selected. The time of day changes, but I still get a hint error.

     

     8:22:15 "3den Enhanced: Debug Options initialized."
     8:22:57 A null object passed as a target to RemoteExec(Call) 'bis_fnc_objectvar'
     8:23:00 Starting mission:
     8:23:00  Mission file: SomeName%2eAltis
     8:23:00  Mission world: Stratis
     8:23:00  Mission directory: C:\Users\Username\Documents\Arma 3\mpmissions\SomeName%2eAltis.Stratis\
     8:23:01 No more slot to add connection at 033057 (3386.8,5735.4)
     8:23:01 d:\bis\source\stable\futura\lib\network\networkserver.cpp NetworkServer::OnClientStateChanged:NOT IMPLEMENTED - briefing!
     8:23:03 "_BR_Time value: 8"
     8:23:04  Mission id: 1c9cc5d519ba6c4a31aabc2dc1d86b6da522b887

     


  9. Subjugation Protocol [Altis]

    Subjugation Protocol [Malden]

    Also available:
    Subjugation [Framework] by @alpha993 
     

    Subjugation Protocol is a PVP focused, sector control game mode that is similar to King of the Hill, but with a renewed emphasis on both player and community agency. Subjugation Protocol is based on the Subjugation Framework.

    Subjugation features a requisition system that allows players to earn points by holding position, and giving them the ability to scan sectors, initiate artillery strikes, air-drop vehicles and more, as enabled by the host. Use the built in Arsenal and Garage to customize your player and vehicles with granularity. Subjugation features no perks, no weapon unlocks and no grinding. Play Arma the way it's meant to be played. Level the playing field. Pull out all the stops to lead your team to victory and subjugate the enemy. For the community, the most important aspect of this game mode is that it is completely open to the public to host and to make copies and/or derivative missions.

     

    The Subjugation Protocol [Altis] variant features 25+ zones.
    The Subjugation Protocol [Malden] variant features 15 zones.
    The Subjugation [Framework] is the basic sector control framework from which Subjugation Protocol is based. It is an example mission set on Altis. You can think of Subjugation Protocol missions as "fleshed out" missions.


  10. Ok. So I've got a mission I had to add icons to the player map and GPS. 

    Depends on how you are running the mission. If it's a self hosted thing on your own PC, things that would work in that environment won't work the same way in a dedicated server environment. I'm learning this is true for a lot of stuff: Weather, Time, and.... drawing stuff on the map and GPS.

    Long and short of it is, anything you draw needs to be drawn on all client machines. Here's a snippet of some code I use to draw an icon on the player map and GPS. Works in a dedicated server environment. Should work regardless.

     

    //Draw on Map
    waitUntil {!isNull findDisplay 12};
    
    findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["Draw", 
    { 
        _ALP_towers = missionNamespace getVariable "ALP_triggerTowers";
        {
            _this select 0 drawIcon [getMissionPath format ["\images\tower%1_ca.paa", (_forEachIndex + 1)], [1,1,1,1], (getPos (_x select 0)), 24, 24, 0, "", 1, 0.03, "TahomaB", "right"];
        } forEach _ALP_towers;
    }];
    
    //Draw on GPS
    private _displays = uiNamespace getVariable ["igui_displays", []];
    {
        private _ctrl = _x displayCtrl 101;
    
        if (!isNull _ctrl && ctrlType _ctrl == 101) then {
            _ctrl ctrlAddEventHandler ["Draw", 
            {
                _ALP_towers = missionNamespace getVariable "ALP_triggerTowers";
    
                {
                    _this select 0 drawIcon [getMissionPath format ["\images\tower%1_ca.paa", (_forEachIndex + 1)], [1,1,1,1], (getPos (_x select 0)), 24, 24, 0, "", 1, 0.03, "TahomaB", "right"];
                } forEach _ALP_towers;
            }];
        };
    } forEach _displays;

    I have this code running in initplayerlocal. 
    This is a mission with no addons, no mods, pure vanilla.

    • Like 1

  11. 19 hours ago, Larrow said:

    See the download in the previous post. I fixed some things that were not quite working correctly in MP.

    Just got around to testing it.

    Issue: Seems only one marker updates.

    In the mission I have currently, I have anywhere between 1 and 7 such "capturable" flags. 

    Reproduce:
    Copy and paste the flag and marker in the 3d editor. Start the mission and capture both flags.
     

    Context:
    The flag (and everything else) is part of a larger mission. I was using attempting to  use capturable flags to change the color of a marker, then using the markercolor to act as a switch of sorts. 
    Each flag (will) belong to a composition that spawns in via LARs. The composition is a simple "base" with 3 cargo houses (two military and one medical) and a numbered tower. The idea is that the flag can be captured by any side at any time, and recaptured by another side, ad infinitum, until the match ends. 

    Each cargo house has an object. In the military houses, that object is a supply crate. In the medical it is also a supply crate. The supply crate will restore the players last arsenal loadout, presumably with a timed hold object counter like the flag capture has. The (object that I haven't decided) in the medical house would restore a player's health via addaction, presumably with a hold object counter like the flag capture has. Why a marker? A, to visually ID who owns a given post on the player map and gps, and B, to retrieve who owns the flag --> so that the addactions/hold actions can be restricted to only work with the side that currently "owns" the flag/marker. The post will also contain a respawn point, llso only available to the side holding the flag, which on mission start would ideally be empty (so no spawn at towerpost), instead of a white flag (I couldn't figure out out to default an empty flagpole in my original init). Both the medical and rearm features will have a 5 minute timeout for that player, to prevent pumping and dumping. In addition, there are 3 triggers, each with a veh repair script. Those will be side restricted as well.

    I've gotten as far as getting my original solution to work with loadouts, but there is no timer yet. 


    Mission File
     


  12. 22 hours ago, Larrow said:
      Hide contents
    
    
    //Description.ext
    
    class CfgFunctions {
    	class NUP_flagCapture {
    		tag = "NUP";
    		class flagCapture {
    			file = "NUP\NUP_flagCapture\functions";
    			
    			class initFlag {  };
    			class captureFlag {  };
    		};
    	};
    };
    
    
    //NUP\NUP_flagCapture\functions\fn_initFlag.sqf
    
    params[
    	[ "_flag", objNull, [ objNull ] ],
    	[ "_marker", "", [ "" ] ],
    	[ "_side", civilian, [ sideUnknown ] ]
    ];
    
    //Make sure parameters are valid
    if ( isNull _flag || { !( _flag isKindOf "FlagCarrierCore" ) } ) exitWith{ [ "Invalid Flag given" ] call BIS_fnc_error };
    if ( _marker == "" || { getMarkerPos _marker == [0,0,0] } ) exitWith{ [ "Invalid Flag Marker given" ] call BIS_fnc_error };
    if !( _side in [ east, west, independent, civilian ] ) exitWith{ [ "Invalid Flag Side given" ] call BIS_fnc_error };
    
    
    //Set defaults
    _flag setVariable[ "NUP_flagMarker", _marker ];
    [ _flag, civilian, true ] call NUP_fnc_captureFlag;
    
    //Add flags holdAction
    _icon = "\a3\ui_f\data\igui\cfg\holdactions\holdaction_takeoff2_ca.paa";
    _duration = 10;
    
    [
    	_flag,
    	"Capture Post",
    	_icon,
    	_icon,
    	"_target getVariable[ ""TER_flagSide"", civilian ] != side _this",
    	"true",
    	//Start
    	{
    	},
    	//Progress
    	{
    		params[ "_flag", "", "", "", "_progress", "_maxProgress" ];
    
    		_relProgress = _progress/_maxProgress;
    
    		_progress = if ( _relProgress <= 0.5 ) then {
    			linearConversion[ 0, 0.5, _relProgress, 1, 0 ]
    		}else{
    			linearConversion[ 0.5, 1, _relProgress, 0, 1 ]
    		};
    		_flag setFlagAnimationPhase _progress;
    	},
    	//Completed
    	{
    		params["_flag", "_caller" ];
    		
    		[ _flag, side _caller ] call NUP_fnc_captureFlag;
    	},
    	//Interrupt
    	{
    		params[ "_flag", "_caller" ];
    		
    		_flag setFlagAnimationPhase 1;
    	},
    	[], 
    	_duration,
    	1.5,
    	false
    ] call BIS_fnc_holdActionAdd;
    
    
    //NUP\NUP_flagCapture\functions\fn_captureFlag.sqf
    
    params[
    	[ "_flag", objNull, [ objNull ] ],
    	[ "_side", civilian, [ sideUnknown ] ],
    	[ "_init", false, [ false ] ]
    ];
    
    //Get flags marker
    _marker = _flag getVariable "NUP_flagMarker";
    
    //Set flags owner
    _flag setVariable[ "TER_flagSide", _side ];
    
    //Set flags texture	
    _sideID = _side call BIS_fnc_sideID;
    _fileFlag = [ "flag_csat_co", "flag_nato_co", "flag_aaf_co", "flag_white_co" ] select _sideID;
    _flag setFlagTexture format[ "\a3\data_f\flags\%1.paa", _fileFlag ];
    
    //Make sure flag is at full hoist
    _flag setFlagAnimationPhase 1;
    
    //Set flags marker color
    _marker setMarkerColor ( [ "ColorOPFOR", "ColorBLUFOR", "ColorIndependent", "ColorGrey" ] select _sideID );
    
    //Call SEH event that flag has changed
    //So you can register to this for owner changed notifications
    if !( _init ) then {
    	[ missionNamespace, "NUP_onFlagOwnerChanged", [ _flag, _marker, _side ] ] remoteExec [ "BIS_fnc_callScriptedEventHandler" ];
    };
    
    
    
    //Each flags init in the editor
    
    [ this, "flagsMarkerName" ] call NUP_fnc_initFlag;
    
    
    //Register somewhere to OnFlagOwnerChanged event
    
    [
    	missionNamespace, 
    	"NUP_onFlagOwnerChanged",
    	{
    		params[ "_flag", "_marker", "_side" ];
    		
    		//Do something
    		systemChat format[ "Flag: %1, Marker: %2 changed to side %3", _flag, _marker, _side ];
    	};
    ] call BIS_fnc_addScriptedEventHandler;

    TEST_MISSION

     

    I'll work on switching to this over the next couple days. This is good stuff. Thanks @Larrow


  13. 1 hour ago, pierremgi said:

     

    You should add your action on box instead of player. (this instead of player in init field of the box)

    You just have to add a condition in your addAction (at the condition param):
     

    
    this addAction [ "Rearm at box", {
      params ["_target", "_caller", "_actionId", "_arguments"];
      }, nil, 1.5, true, true, "", "side _this == TowerPost1Side  ", 10, false, "", "" ];

     

    TowerPost1Side can be set at start by:

    
    if (isServer) then {towerPost1Side == sideUnknown; publicVariable "towerPost1Side"};

     

    Up to you for changing TowerPost1Side along with your captures. Playing with the color of a marker is not the best solution... because the marker color change already met a condition which could be used for the addAction as well.

     

    Anyway, you can use an event handler for that:
     

    
    addMissionEventHandler ["MarkerUpdated", {
      params ["_marker", "_local"];
      if (_marker == "towerPost1") then {
        call {
          if (markerColor _marker == "colorWest" exitWith {towerPost1Side = WEST};
          if (markerColor _marker == "colorEAST" exitWith {towerPost1Side = EAST};
          ....  // what you need
          towerPost1Side = sideUnknown;
        };
      };
    }];

     

    Works great! Thanks!


  14. 29 minutes ago, _foley said:

    The trouble is that "_canRearm" is a local variable and it's only evaluated once, at the beginning of the script.

     

    Try this, first define a function that checks if player can rearm:

    
    fnc_canRearm = {
      _mrkr = "TowerPost1";  
      _mrkrcolor = getMarkerColor _mrkr;  
      _color = switch (side player) do  
      {  
       case west: { "ColorBlufor" };  
       case east: { "ColorOpfor" };  
       case independent: { "ColorIndependent" };  
       default { "ColorGrey" };  
      };  
      
      (_color == _mrkrcolor)
    }

    then in the addAction set the condition to "call fnc_canRearm" instead of "_canRearm".

     

    Keep in mind that this condition will be checked on every frame. It's fine in this case but if the function were more complex then it could affect performance.

    In that case, what would be a better, more efficient approach?


  15. 4 hours ago, ghostrider-GRG said:

    Did you look into determining the side of the player to start then setting marker colors and anything else you need base on that?

    https://community.bistudio.com/wiki/side

    Not sure what you mean.

    For context, I am creating a small Outpost that will be capturable in a larger MP mission with 3 teams fighting over a single sector.
    The idea is that a player captures an outpost by capturing a flag (with code from here). Doing so changes the color of a named marker specific to that base, to not only show who controls it, but to act as a switch of sorts for a couple of things in the outpost.This particular one is a supply crate. The addaction by itself works splendidly, filtering it seems to be quite the chore. Beyond that there will be a healing create, three vehicle repair areas and a respawn location -- all which are only meant to work for the team matching the marker color.


  16. 5 hours ago, _foley said:

    Did you consider using the "condition" parameter of addAction to check if player can rearm?

    You can't really update an action, you'd have to delete it and create again when needed but I think using the condition is cleaner.

    I have tried

    if (_mrkrcolor == _color) then { 
        player addAction ["Rearm", { 
            _mrkrcolor = getMarkerColor _mrkr; 

    and 
     

    if (_canRearm) then {
        player addAction ["Rearm", {
            private _customLoadout = player getVariable "enh_savedloadout";
            if (isNil "_customLoadout") exitWith {
                player setUnitLoadout (configFile >> "CfgVehicles" >> typeOf player);
                systemChat "Could not find custom loadout";
                systemChat "Restored default unit loadout";
            };
            player setUnitLoadout _customLoadout;
            systemChat "Rearmed and Reloaded";
        }, [], 0, true, true, "", "_canRearm"];
    };

    Neither throw errors, nor appears to have any effect.


  17. Trying to enable an addaction based on the player side and color marker matching. This is in the init of a supply box on mission start. 

    Anyone know how I would go about updating it whenever a marker color changes?

    _mrkr = "TowerPost1";  
    _mrkrcolor = getMarkerColor _mrkr;  
    _color = switch (side player) do  
    {  
     case west: { "ColorBlufor" };  
     case east: { "ColorOpfor" };  
     case independent: { "ColorIndependent" };  
     default { "ColorGrey" };  
    };  
      
    _canRearm = (_color == _mrkrcolor);
      
    if (_canRearm) then {   
        player addAction ["Rearm", {   
            private _customLoadout = player getVariable "enh_savedloadout";       
            if (isNil "_customLoadout") exitWith {       
                player setUnitLoadout (configFile >> "CfgVehicles" >> typeOf player);       
                systemChat "Could not find custom loadout";       
                systemChat "Restored default unit loadout";       
            };       
            player setUnitLoadout _customLoadout;       
            systemChat "Rearmed and Reloaded";       
        }];   
    }; 


  18. Context:
    I have mission that contains multiple flagpoles. Each is named (Flag_1, Flag_2)
    Player captures a flagpole, it should change the marker color of TowerPost%1. Marker will stay the same until another team captures the flagpole.

    I've tried this, and ultimately, I am unsure of what to use to determine if a flag has been captured, and returning it's name for a split string. 

    Edit:
     

    I just modified the aftercommand to get the flagside the same way the existing code did, then use that to set the markercolor. I wasn't able to figure out how to get the name of flag1, split the string, and format towerpost%1 based on that, but this really isn't that much more work.

    _flag = this;
    params ["_winSide"];
    _afterCommand = {**_get = _flag getVariable ["TER_flagSide",civilian];**
    _marker1 = "TowerPost1";
    _mkrcolor = switch (_get) do {
    case west: {
    _marker1 setmarkerColor "ColorBLUFOR";
    };
    case east: {
    _marker1 setmarkerColor "ColorOPFOR";
    };
    case independent: {
    _marker1 setmarkerColor "ColorIndependent";
    };
    default {
    _marker1 setmarkerColor "ColorGrey";
    };
    };
    };
    
    _fncOwnFlag = {
    params ["_winSide"];
    _flagPath = "\a3\data_f\flags\%1.paa";
    _fileFlag = switch _winSide do {
    case west: {"flag_nato_co"};
    case east: {"flag_csat_co"};
    case independent: {"flag_aaf_co"};
    default {"flag_white_co"}
    };
    format [_flagPath,_fileFlag];
    };
    _actionParams = ["_flag", "_caller", "_actionId", "_arguments"];
    
    _flag setflagAnimationPhase 1;
    _flag setFlagTexture (civilian call _fncOwnFlag);
    
    _flag setVariable ["TER_flagSide",civilian];
    _icon = "\a3\ui_f\data\igui\cfg\holdactions\holdaction_takeoff2_ca.paa";
    _duration = 10;
    _addID = [_flag, "Capture Post", _icon, _icon,
    "_target getVariable [""TER_flagSide"",civilian] != side _this",
    "true",
    {
    },
    {
    params ["_flag", "_caller", "_actionId", "_arguments","_progress","_maxProgress"];
    _arguments params ["_actionParams","_fncOwnFlag","_afterCommand"];
    _relProgress = _progress/_maxProgress;
    if (_relProgress < 0.5) then {
    _flag setFlagAnimationPhase (1-(2*_relProgress));
    } else {
    if (_relProgress == 0.5) then {_flag setFlagTexture (side _caller call _fncOwnFlag)};
    _flag setFlagAnimationPhase ((2*_relProgress)-1);
    };
    },
    {
    params ["_flag", "_caller", "_actionId", "_arguments"];
    _arguments params ["_actionParams","_fncOwnFlag","_afterCommand"];
    _flag setVariable ["TER_flagSide",side _caller];
    [] call _afterCommand;
    },
    {
    params ["_flag", "_caller", "_actionId", "_arguments"];
    _arguments params ["_actionParams","_fncOwnFlag","_afterCommand"];
    _flag setFlagAnimationPhase 1;
    _side = _flag getVariable ["TER_flagSide",civilian];
    _flag setFlagTexture (_side call _fncOwnFlag);
    },
    [_actionParams,_fncOwnFlag,_afterCommand], _duration, 1.5, false] call BIS_fnc_holdActionAdd;
    
    _addID

     


  19. On 4/26/2022 at 6:09 PM, Stormmy1950 said:

    Ok so i think i have manage to get it working here is the final product of this script:
     

    
    /*
    First of i wonna give big tanks to:
    -Dslyecxi - for idea.
    -dreadedentity
    -Harzach
    -Leopard20
    and me L3gion (old name Stormmy1950)
    
    without them this wouldn't be possible at least for me :) 
    
    To execute this you need to create 2 files in your mission directory.
    1.InitPlayerLocal.sqf
    2. [somename].sqf
    
    in InitPlayerLocal.sqf put this line of code:
    
    null = [] execVM "[somename].sqf";
    
    and in [somename].sqf copy all of this and paste it and it should work
    
    Note: its tested on singleplayer and hosted server not tested in Dedicated server.
    Note2: if you copyied this from BI Forums they may be hidden characters so double check to make shure there is no hidden characters.
    
    */
    
    //EH that gets where player Shift + Left Click on the map
    addMissionEventHandler ["MapSingleClick", { 
    	params ["_units", "_pos", "_alt", "_shift"]; 
    	if (_shift) then { 
    	player setVariable ["ClickedMapPos", _pos];
    }}]; 
    
    
    private _map = findDisplay 12 displayCtrl 51;
    //small wait becouse we are calling this script from InitPlayerLocal.sqf so it get initiliazes
    while {isNull _map} do {
      uiSleep 0.1;
      _map = findDisplay 12 displayCtrl 51;
    };
    
    //EH Draw witch draws Line and pointers and distance text.
    _map ctrlAddEventHandler ["Draw", {
    	_pos = player getVariable "ClickedMapPos";
    	_dist = (player distance2d _pos) / 1000 toFixed 1; //_dist = (player distance2d _pos) / 1000 toFixed 2;  - will now show two decimal places e.g. "4.75 km"
    	/*
    	if you just want it in meters with no decimal places
    
    		_dist = round (player distance2d _pos);  //  e.g. "4752 meters"
    
    		//don't forget to change drawIcon's 7th param e.g. 
    
    		format ["%1 m", _dist]
    	*/
    	if (!isNil "_pos") then {
    		_this#0 drawLine [getpos player, _pos, [1,1,1,1]];
    		_this#0 drawIcon  
    		[ 
    			"IconControlPoint", [0,0,0,1], _pos, 24, 24, 45, format ["%1 km", _dist], 1, 0.03, "TahomaB", "right" 
    		]; 
    	};
    }];
    
    //These lines of code eneables to show on GPS regadlers are you in vehicle or not.
    private _displays = uiNameSpace getVariable ["igui_displays", []];
    {
      private _ctrl = _x displayCtrl 101;
    
      if (!isNull _ctrl && ctrlType _ctrl == 101) then {
    
    		_ctrl ctrlAddEventHandler ["Draw", {
    		_pos = player getVariable "ClickedMapPos";
    		_dist = (player distance2d _pos) / 1000 toFixed 1;
    		if (!isNil "_pos") then {
    			_this#0 drawLine [getpos player, _pos, [1,1,1,1]];
    			_this#0 drawIcon  
    			[ 
    				"IconControlPoint", [0,0,0,1], _pos, 24, 24, 45, format ["%1 km", _dist], 1, 0.03, "TahomaB", "right" 
    			]; 
    		};
    		}];
      };
    } forEach _displays;

     

    I managed to get this to work in one instance but not work in another. It's confounding!

    In some_1.sqf the following works:
      

     private _displays = uiNameSpace getVariable ["igui_displays", []];
        {
            private _ctrl = _x displayCtrl 101;
    
            if (!isNull _ctrl && ctrlType _ctrl == 101) then {
            _ctrl ctrlAddEventHandler ["Draw", 
                {
                    _this#0 drawIcon [getMissionPath "\images\attack.paa", [1,1,1,1], (getMarkerPos "BZMarker"), 30, 30, 0, "", 1, 0.03, "TahomaB", "right"];
                }];
        };
    } forEach _displays;

    In some_2.sqf:
     

    //This works and displays an icon on the player map
    findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["Draw", 
    { 
        _ALP_towers = ALP_mainZone getVariable "ALP_triggerTowers";
        {
            _this select 0 drawIcon [getMissionPath format ["\images\tower%1_ca.paa", (_forEachIndex + 1)], [1,1,1,1], (getPos (_x select 0)), 24, 24, 0, "", 1, 0.03, "TahomaB", "right"];
        } forEach _ALP_towers;
    }];
    //This does NOT work, but doesn't throw any errors!
    private _displays = uiNameSpace getVariable ["igui_displays", []];
    {
        private _ctrl = _x displayCtrl 101;
        _ALP_towers = ALP_mainZone getVariable "ALP_triggerTowers";
        if (!isNull _ctrl && ctrlType _ctrl == 101) then {
            {
                _ctrl ctrlAddEventHandler ["Draw", 
                           
                {
                   _this#0 drawIcon [getMissionPath format ["\images\tower%1_ca.paa", (_forEachIndex + 1)], [1,1,1,1], (getPos (_x select 0)), 24, 24, 0, "", 1, 0.03, "TahomaB", "right"];
                }];
            } forEach _ALP_towers;
        };
    } forEach _displays;

     


  20. Trying to pass a variable through to the custom function that spawns comps. The function works in other tests just fine. However, I am trying to call it on initServer.
     

    _ZoneComp = missionNamespace getVariable ["ALP_mainZone", ""];
    
    diag_log format ["_ZoneComp value:%1", _ZoneComp];
    
    _compReference = [_ZoneComp, [], [0,0,0], 0, true, true, false] call LARs_fnc_spawnComp;



    And just to verify here is my compositions.cfg:
     

    //LARs_spawnComp_debug = 1; //1 = RPT output, 2 = RPT output and ingame visual positioning info
    
    class CfgCompositions {
        class ALP_Area_01 { //Name that the composition is spawned by
            #include "ALP_Area_01.sqe" //Renamed composition.sqe
        };
    };

     

    Upon mission start, I get the Error >>: Type Object, expected string. In the RPT, this pops out:

    11:17:13 "_ZoneComp value:ALP_Area_01" 11:17:13 Error in expression < missionConfigFile >> "CfgCompositions" >> _compName;

    Any ideas ?

    Edit: Fixed

    Quote

    _ZoneComp = str(missionNamespace getVariable ["ALP_mainZone", ""]);
    diag_log format ["_ZoneComp value: %1", _ZoneComp];
    _compReference = [_ZoneComp, [], [0,0,0], 0, true, true, false] call LARs_fnc_spawnComp;



    Thanks. Great Script!

     


  21. 2 minutes ago, demonline said:

    I initially attempted using yours, but because of my inexperience, I was unable to add the lines to the description. ext, since my mission was throwing me errors and is quite complicated and has many more features. Not secure enough to operate that way on scripts and functions that already exist.
    Also, I was unable to figure out how to just spawn in a location upon mission start without the use of addactions.

    I'm just attempting to come up with a short, straightforward script that will accomplish my goals.

    ??? 

×