Jump to content

stuguy

Member
  • Content Count

    107
  • Joined

  • Last visited

  • Medals

Everything posted by stuguy

  1. { _grp = _x _grp = createGroup east; { switch(_forEachIndex) do { case 0 : {_x = "O_T_Recon_M_F" createunit [position [0,0,0], _grp]; removeallweapons _x; removevest _x; removeuniform _x; removeheadgear _x; removebackpack _x; _x unassignItem "NVGoggles"; _x removeItem "NVGoggles"; removeallitems _x; //add gear commands }; case 1 : { //repeat above case for next type of unit }; case 2 : { //rinse repeat but different }; case 3 : { //again here }; }; }forEach _x; _x set [_forEachIndex, _grp]; }forEach _reconGroups; yes the switch statement's condition is the numerical index of the current iterated index for the forEachLoop it is executed in. The case # fires off if it is equal to the current index.
  2. switch do statement will allow you to set the type of unit class or even loadouts for that index of unit.
  3. { _grp = _x _grp = createGroup east; { switch(_forEachIndex) do { case 0 : {}; case 1 : {}; case 2 : {}; case 3 : {}; case 4 : {}; case 5 : {}; default : {}; }; }forEach _x; _x set [_forEachIndex, _grp]; }forEach _groupArray;
  4. I can teach you to do it with loops... Especially if all of your groups have the same loadouts. Hell, I can even show you how to make different load outs and still apply them to squad leader, medic, marksman, at soldier, mg, etc.
  5. just be sure to change "_groupArray" to be the list of groups you made. Just one more query, are your groups empty or do they have a unit or units in them already?
  6. So you are serving multidimensional arrays. You have to iterate the column A, B, C, and D on your excel sheet. Each column has a list of names going down it. You are thinking, "I need 4 loops to handle this". Wrong. Two at most. One forEach loop to cycle through your 4 groups, and one more forEach loop inside of the first loop to cycle through the list of men. { { //do stuff //_x is once again the unit from the group supplied by the parent forEach. }forEach _x; //this _x is the magic variable for the group from forEach _groupArray }forEach _groupArray; This loop is like cycling through A-1,2,3,4etc, then B-1,2,3,4etc, and so on
  7. forEach is a type of for loop that iterates, or counts, through an array. units is an arma command that returns a list of units in a group that you specify. groupNameVariable will need to be changed to be a group variable name that you made, like _recon0 or _sniper1. So the forEach statement that I supplied you will count through a list of units belonging to a group you give it. The group you give it is just a list of men in it, like an excel spread sheet with a roster of people in it going down a column or row. Each iteration of the loop goes through one space of that list at a time, or "index" as we call it. It goes in order, or in an order you specify with more advanced commands. That index's contents is represented inside the braces by the magic variable _x. The index number is represented by magic variable _forEachIndex. The forEach loop begins by default at index 0, then goes to 1, 2 ,3 etc. Whatever code you put in the braces gets applied to each unit in that group. So if you put inventory commands from the virtual arsenal, that loadout gets applied to every unit in the group you write in for the groupNameVariable.
  8. { //code _x is the unit }forEach units groupNameVariable; edit units that you already defined in a group ^ The code I already gave you can assign new units to new groups or be tweaked to add troops to existing groups.
  9. //reconGroup array _reconGroup = []; _reconGroup resize 4; //create units array _units = []; _units resize 4; { //create temporary east group for each iteration of this loop _tmpGrp = createGroup east; //change position to wherever you need them, _x is a dude being added to the _tmpGrp (leader) _x = "O_T_Recon_M_F" createunit [position [0,0,0], _tmpGrp]; removeallweapons _x; removevest _x; removeuniform _x; removeheadgear _x; removebackpack _x; _x unassignItem "NVGoggles"; _x removeItem "NVGoggles"; removeallitems _x; //apply the _tmpGrp into your reconGroup array at the same index position of you units loop program. //both arrays are equal, so the indexes line up perfect _reconGroup set [ _forEachIndex, _tmpGrp ]; //if that don't work try _reconGroup set [ _forEachIndex, [_tmpGrp] ]; }forEach _units; This program is pretty straight forward. I create two local arrays, _units and _reconGroup. I set both size 4, as in 4 indexes. I then loop through the _units array with the command {}forEach _units; Since there are 4 indexes, the loop will cycle 4 times and then exit, so I can create 4 units with the magic variable _x. Also, assigning magic variable _x to equal a unit makes that _units index equal to that dude, so the _units array could technically be called again if the namespace for the local variable doesn't disappear from your program. I also make use of the _units forEach loop and assign a temporary east group to add the newly created unit to. Since nobody will be in that group, those new dudes will be leader. At the end of the script, I set those temporary groups to be indexed into the _reconGroup array. So the leaders can be found in Leader _reconGroup select # later in your program.
  10. //declare computer variable globally somewhere in your program fn_mrapBoom = { params ["_vehicle"]; addac = computer addAction ["Boom!",{ params[ "_target", "_caller", "_ID", "_args" ]; _args setdammage 1},_vehicle,1,false,true,"","(_target distance _this) < 150"]; publicVariable "addac"; }; [ vehicleVariableName ] call fn_mrapBoom; fixed and works
  11. I saw that part, but then some of the conditions inside the brackets don't have parenthesis, and some do. Also, when I try to cleanly expand some of the conditions to add checks for group leaders and what not, the code crashes the addAction. Like the fn joinHCGroup. You start up the conditions with no null cursor target: !(isnull cursortarget) then follow that up with AND _this isEqualTo _target: && _this isEqualTo _target This was evaluated not with parenthesis or brackets. Then you moved into lazy eval and the next two conditions are not in parenthesis but inside the brackets, understandably, {} instead of (). However, we move further into lazy eval and you start comparing two things in an OR statement, and that is inside {( A || B )}. I can take a wild guess and say that comparing two things in a singular parenthesis would be a requirement if in this particular instance you are evaluating if the unit is either on player's side or is captive. Then AND not cursortarget's group isEqualTo the passed in group. That's inside of parenthesis, but I want to guess that it was required because you used the NOT wildcard to turn the expression into the opposite. Then the last two statements are two separate conditions evaluating the alive units in the passed in group. I am guessing we are comparing two things, the number of units alive in the pass in group and the set limit required to be evaluated. Once again, we are using wildcards inside of a requirement, so I am guessing we have to use parenthesis. Whereas above, some of the statements like: cursorTarget isKindof 'Man' alive cursortarget Do not use parenthesis. Again, I am simply guessing because the documentation Bohemia provides is not as elaborate as I would like. Some of their examples contradict what I just said, like: if (_group knowsAbout _vehicle object > 0 && {alive _object} && {canMove _object} && {count magazines _object > 0}) then { //custom code }; This is lazy eval, but the statements comparing certain variables and conditions comparing the results to a number do not use parenthesis, namely: _group knowsAbout _vehicle object > 0 What I am driving at is, I certainly understand conditions and understand the {} and () versions. But not everything follows that criteria. Some things just kind of free ball there and I haven't found any explanation why. It's problematic because I get syntax errors when the code compiles, or entire segments of my action break because I am not doing something particularly correct in some positions, and that's frustrating. edit: what's more, some of your conditions have semi-colon. I have no idea why this is a thing or if it is valid syntax. " !(isnull cursortarget) && _this isEqualTo _target && { cursorTarget isKindof 'Man' && { alive cursortarget && { ( side cursortarget isEqualTo side player || captive cursorTarget ) && { leader group cursorTarget isEqualTo cursorTarget && { group cursorTarget isEqualTo ( _x select 0 ) }count myGrps > 0 }; ///THIS GUY ^^^ } } }"
  12. @Larrow I cannot modify the conditions in the addAction "Form New HC Group" without breaking everything in TAG_fnc_HCActions. Do you have documentation on lazy eval? I tried adding several different versions of the below condition, even following the examples of other addActions you wrote, but anything I put in to Form New HC Group breaks the entire function after I add units into my group. && {!(leader group cursorTarget isEqualTo cursorTarget) } I am also unable to modify my new function TAG_fnc_groupJoinHCGroup to prevent singular units, and non leader units from using the function. I want to eliminate redundant commands in the menu. Only squad leaders with troops should have the option to group join the player or another squad. Any singular man should be able to join with the program as is. I am also using my new join command now in most cases where units join other groups. My TAG_fnc_JoinFunction automatically finds the highest ranking man and selects him to be leader when two groups, or a singular man, is added to another group. This is not applicable to the functions that add units or groups to player, naturally. New program. The game throws a syntax bug. It doesn't seem to like the Dismiss HC Group action. I cannot fix it. Nothing I try works. I don't have a resource on how you do your conditional syntax. myGrps = []; myGrps resize 10; myGrps = myGrps apply { [ grpNull ] }; TAG_fnc_createNewHCGroup = { params[ "_unit", [ "_create", true ], [ "_wholeGroup", false ] ]; _CompanyNames = ["CompanyXray","CompanyNovember","CompanyNovember","CompanyNovember","CompanyNovember","CompanyWhiskey","CompanyWhiskey","CompanyWhiskey","CompanyWhiskey","CompanyXray"]; _PlatoonNames = ["Platoon1","Platoon1","Platoon1","Platoon2","Platoon2","Platoon1","Platoon1","Platoon2","Platoon2","Platoon1"]; _SquadNames = ["Squad1","Squad1","Squad2","Squad1","Squad2","Squad1","Squad2","Squad1","Squad2","Squad2"]; { _x params[ "_HCGrp", "_HCActionID" ]; if ( !isNull _HCGrp && { { alive _x }count units _HCGrp isEqualTo 0 } ) then { deleteGroup _HCGrp; player hcRemoveGroup _HCGrp; if ( _HCActionID isEqualType 0 ) then { player removeAction _HCActionID; }; myGrps set [ _forEachIndex, [ grpNull ] ]; _HCGrp = grpNull; }; if ( _create && { isNull _HCGrp } ) then { private [ "_group" ]; if !( isPlayer _unit ) then { _group = createGroup side player; }else{ _group = group player; }; _group setGroupIdGlobal [ "%GroupNames %GroupCompany %GroupPlatoon-%GroupSquad", "Yankee", _CompanyNames select _forEachIndex, _PlatoonNames select _forEachIndex, _SquadNames select _forEachIndex ]; if !( _unit in units _group ) then { _oldGroup = group _unit; if ( _wholeGroup ) then { units _oldGroup joinSilent _group; }else{ [ _unit ] joinSilent _group; }; if ( count units _oldGroup isEqualTo 0 ) then { deleteGroup _oldGroup; }; }; _actionID = if !( isPlayer _unit ) then { player hcSetGroup [ _group ]; [ _group ] call TAG_fnc_joinHCGroup }else{ objNull }; myGrps set [ _forEachIndex, [ _group, _actionID ] ]; _create = false; }; }forEach myGrps; }; TAG_fnc_recruitFriendly = { player addAction [ "Join Me", { cursorTarget setCaptive false; [ cursorTarget ] joinSilent group player; [ objNull, false ] call TAG_fnc_createNewHCGroup; }, [], 1, false, true, "", " !(isnull cursortarget) && _this isEqualTo _target && { cursorTarget isKindof 'Man' && { alive cursortarget && { ( side cursortarget isEqualTo side player || captive cursorTarget ) && { !(group cursortarget isEqualTo group player) && { ({ alive _x } count units group player < 12) } } } } }" ]; }; TAG_fnc_joinHCGroup = { params[ "_HCGrp" ]; _actionID = player addAction [ format [ "Join %1", groupID _HCGrp ], { params[ "_target", "_caller", "_ID", "_args" ]; [ cursorTarget ] joinSilent _args; [ objNull, false ] call TAG_fnc_createNewHCGroup; }, _HCGrp, 1, false, true, "", format [ " _group = %1 call BIS_fnc_groupFromNetId; !(isnull cursortarget) && _this isEqualTo _target && { cursorTarget isKindof 'Man' && { alive cursortarget && { ( side cursortarget isEqualTo side player || captive cursorTarget ) && { !(group cursortarget isEqualTo _group) && { ({ alive _x } count units (_group) > 0) && ({ alive _x } count units (_group) < 12) } } } } }", str ( _HCGrp call BIS_fnc_netId ) ] ]; _actionID }; TAG_fnc_HCActions = { player addAction [ "Unit to HC Group", { [ cursorTarget, true ] call TAG_fnc_createNewHCGroup; }, [], 1, false, true, "", " !(isnull cursortarget) && _this isEqualTo _target && { cursorTarget isKindof 'Man' && { alive cursortarget && { ( side cursortarget isEqualTo side player || captive cursorTarget ) } } }" ]; player addAction [ "Group to HC Group", { [ cursorTarget, true, true ] call TAG_fnc_createNewHCGroup; }, [], 1, false, true, "", " !(isnull cursortarget) && _this isEqualTo _target && { cursorTarget isKindof 'Man' && { alive cursortarget && { ( side cursortarget isEqualTo side player || captive cursorTarget ) && { leader group cursorTarget isEqualTo cursorTarget && count units group cursorTarget > 1 }; } } }" ]; player addAction [ "Dismiss HC Group", { player hcRemoveGroup group cursorTarget; { _x params[ "_group", "_action" ]; if ( _group isEqualTo group cursorTarget ) exitWith { player removeAction _action; player hcRemoveGroup _group; myGrps set [ _forEachIndex, [ grpNull ] ]; }; }forEach myGrps; }, [], 1, false, true, "", " !(isnull cursortarget) && _this isEqualTo _target && { cursorTarget isKindof 'Man' && { alive cursortarget && { ( side cursortarget isEqualTo side player || captive cursorTarget ) && { leader group cursorTarget isEqualTo cursorTarget && { group cursorTarget isEqualTo ( _x select 0 ) }count myGrps > 0 }; } } }" ]; }; _null = [ player, true ] call TAG_fnc_createNewHCGroup; _null = [] call TAG_fnc_recruitFriendly; _null = [] call TAG_fnc_HCActions; There are a few quirks in the program, but for the most part, it works. Dismiss does not function, as your conditions had a syntax error. I tried fixing it, but no dice. I still need to figure out how to do lazy syntax better. Adding the conditions I know works when everything is not lazy breaks the action or doesn't register if I try lazy.
  13. I'm also thinking about writing up a call function for adding units to groups instead of using joinSilent in the addAction code block. I like joinAsSilent because I can specify an index. I usually select 2 because it is not leader. I do, however, want all units being added individually to the group check their ranks. I always want the highest rank to promote himself to 1. Thus, I will write a call function for adding units individually. I'm thinking along the lines of checking forEach units in the receiving group, and mark which index is highest rank. Then compare the index with the unit being added and see which is higher. Whoever is higher joinAsSilent 1 and the other joinAsSilent 2. I'm not asking for a code, I want to try something first :) fn_GetRankNum = { _rankNum = "none"; switch (rank _this) do { case "PRIVATE" : {_rankNum = 1;}; case "CORPORAL" : {_rankNum = 2;}; case "SERGEANT" : {_rankNum = 3;}; case "LIEUTENANT" : {_rankNum = 4;}; case "CAPTAIN" : {_rankNum = 5;}; case "MAJOR" : {_rankNum = 6;}; case "COLONEL" : {_rankNum = 7;}; default {_rankNum = 0;}; }; _rankNum; }; TAG_fnc_JoinFunction = { _unit = _this select 0; _grp = _this select 1; _str = _this select 2; //accepting variable "unit or from Group" and "target group" if (_str == "unit") then { [_unit] joinSilent _grp; }else { { [ _x ] joinSilent _grp; }forEach units _unit; }; _leader = units _grp select 0; { if !(isNil {units _grp select (_forEachIndex + 1)}) then { if((units _grp select (_forEachIndex + 1) call fn_GetRankNum) > (_leader call fn_GetRankNum) ) then { _leader = units _grp select (_forEachIndex+1); }; }; }forEach units _grp; _grp selectLeader _leader; }; This is my new join. It works.
  14. EDIT: I'm dumb. I was editing the wrong files. I got the group add to me feature working. I added this little doodad and it will not work. I checked the individual conditions and they should work... TAG_fnc_grpJoinMe = { player addAction [ "Group Join Me", { cursorTarget setCaptive false; {[ _x ] joinSilent group player;}forEach units group cursorTarget; [ objNull, false ] call TAG_fnc_createNewHCGroup; }, [], 1, false, true, "", " !(isnull cursortarget) && (_this isEqualTo _target) && { (cursorTarget isKindof 'Man') && { (alive cursortarget) && { ( side cursortarget isEqualTo side player || captive cursorTarget ) && { (leader group cursorTarget isEqualTo cursorTarget) && { ({alive _x} count units group cursorTarget > 1) && (({ alive _x } count units group cursorTarget) + ({ alive _x } count units group player) < 12) }; } } } } }" ]; }; _null = [] call TAG_fnc_grpJoinMe; I figured out how to use the HCActions. So I was able to get a mock draft of groupJoinHCGroup working. However, I cannot modify the conditions. The game ignores any attempt I make to add logic to prevent redundant commands or ineligible conditions. Below, the game ignores the ({ alive _x } count units (group cursorTarget) > 1) condition. To fire this function, I added an additional call in the TAG_fnc_createNewHCGroup function. TAG_fnc_groupJoinHCGroup = { params[ "_HCGrp" ]; _actionID = player addAction [ format [ "Group Join %1", groupID _HCGrp ], { params[ "_target", "_caller", "_ID", "_args" ]; [ Group cursorTarget, _args, "" ] call TAG_fnc_JoinFunction; //{[ _x ] joinSilent _args;}forEach units Group cursorTarget; if (Group cursorTarget in myGrps) then { [ objNull, false ] call TAG_fnc_createNewHCGroup; }; }, _HCGrp, 1, false, true, "", format [ " _group = %1 call BIS_fnc_groupFromNetId; !(isnull cursortarget) && _this isEqualTo _target && { cursorTarget isKindof 'Man' && { alive cursortarget && { ( side cursortarget isEqualTo side player || captive cursorTarget ) && { !(group cursortarget isEqualTo _group) && { (leader group cursorTarget isEqualTo cursorTarget) && { ({ alive _x } count units (group cursorTarget) > 1) && { ({ alive _x } count units (_group) > 0) && (({ alive _x } count units (_group)) + ({ alive _x } count units cursorTarget) < 12) { } } } } } }", str ( _HCGrp call BIS_fnc_netId ) ] ]; _actionID };
  15. stuguy

    Custom keys to activate scripts

    Just like this. There are a multitude of options available. Thanks for bringing this one up.
  16. My God man! You coded like a maniac there. Yes, this program is solid. I could either have a working program with a bug that prevented other units from joining an HC squad if he had previously joined my squad, or had a program that constantly listed all options in order to function. What you have here is brilliant. I saw how you check in and out the old squads by removing them if someone leaves a group. I think that would help efficiency by erasing unused assets. I like the group join feature as well. I was thinking to add those in myself but you beat me to it. There are just a few more conditions I need to add, like not allowing for the option to create new teams if units are present in all HC groups, not allowing team leaders to create new groups, apply add group feature only to group leaders, and allow players to add groups to his own squad too. Thanks again. I hope you enjoy your frosty beverage :D edit: @Larrow I keep seeing _this isEqualTo _target is _this the group argument? I am unsure what is passed into the string section of addAction, or how _target and _ID and all those others are passed in. I do understand params aand how it can be used to pull out variables. So my guess is that addAction passes in certain criteria in a certain order, though I am unsure what that is.
  17. stuguy

    Custom keys to activate scripts

    No problem. If you need any help, just ask. Oh, and inputAction is definitely a good starting point. It's what will drive your program. Especially keys that are assigned to things that aren't applicable in the situation you are in. There are crap loads of key assignments in the game. Not all of them are work while running around as infantry, and not all of them work when you are driving. Just find one in the area of the keyboard you like that works in cars or planes but not as a foot soldier, or vice versa, and then look up what that assignment is in the Key Actions. https://community.bistudio.com/wiki/inputAction/actions That's for Arma3. inputAction "reloadMagazine" that just happens to be a valid command in game and one of the actions in the list. edit: you can even use the compass or watch key. It doesn't matter. Here is an example.... TAG_fn_yourKeyListener = { while (true) do { if (inputAction "reload" == 1) then { //your code }; sleep 1; }; [] spawn TAG_fn_yourKeyListener; }; [] spawn TAG_fn_yourKeyListener; //you may have to hold the key down for a second.
  18. Fair game as long as you aren't monetizing it. Bohemia does not like it if you sell their copyrighted material. However, using game assets for missions to make the game fun is fine.
  19. stuguy

    Custom keys to activate scripts

    https://community.bistudio.com/wiki/actionKeys https://community.bistudio.com/wiki/Category:Key_Actions https://community.bistudio.com/wiki/DIK_KeyCodes actionKeys can be set to variables. The key input is a type string, but the actionKey / variable returned is a number. You can use a switch do statement with conditions equal to the key pressed to make it do something, in theory. Oh, you will probably need the inputAction command as well. edit: https://community.bistudio.com/wiki/switch https://community.bistudio.com/wiki/inputAction edit2: in general programming, we use keyListeners to listen out for user input on the keyboard. Those keys can either return a string or ASCII numerical value. I personally use switch statements, dependent on situations, to give directives to my program what to do when certain keys are detected by my keyListener. The switch statement has cases in it that handle the particular key I pressed. IE: case "k" : { do stuff }; Arma will require you to use their command syntax, however.
  20. yes. https://community.bistudio.com/wiki/nearTargets https://community.bistudio.com/wiki/cursorTarget https://community.bistudio.com/wiki/reveal
  21. I can't figure it out. I've been at it all day. I've tried hundreds of different ways of creating my teams using loops for the addActions but they just don't seem to want to cooperate. Manually assigning them one by one just seems to be the easiest way. I will submit two programs. Both are similar, but only one allows you to fully add and remove the units from all teams at once. I have a third program, but it was miles long and i wanted to avoid such travesty. Doesn't quite work, all teams other than player's team do not register as select-able options: myGrps = []; myGrps resize 10; myGrps = myGrps apply { grpNull }; TAG_fnc_initHCGrps = { { _newGrp = createGroup side player; _newGrp setGroupIdGlobal [ "%GroupNames %GroupCompany %GroupPlatoon-%GroupSquad","Yankee",CompanyNames select _forEachIndex,PlatoonNames select _forEachIndex,SquadNames select _forEachIndex]; myGrps set [ _forEachIndex, _newGrp ]; }forEach myGrps; }; TAG_fnc_frmNewHCGrp = { params[ "_unit" ]; _CompanyNames = ["CompanyXray","CompanyNovember","CompanyNovember","CompanyNovember","CompanyNovember","CompanyWhiskey","CompanyWhiskey","CompanyWhiskey","CompanyWhiskey","CompanyXray"]; _PlatoonNames = ["Platoon1","Platoon1","Platoon1","Platoon2","Platoon2","Platoon1","Platoon1","Platoon2","Platoon2","Platoon1"]; _SquadNames = ["Squad1","Squad1","Squad2","Squad1","Squad2","Squad1","Squad2","Squad1","Squad2","Squad2"]; { _x params[ "_grp" ]; switch (_unit) do { case "init": { _newGrp = createGroup side player; _newGrp setGroupIdGlobal [ "%GroupNames %GroupCompany %GroupPlatoon-%GroupSquad", "Yankee", _CompanyNames select _forEachIndex, _PlatoonNames select _forEachIndex, _SquadNames select _forEachIndex ]; if !(Group player isEqualTo (myGrps select 0)) then { [ player ] joinSilent _newGrp select 0; }; myGrps set [ _forEachIndex, _newGrp ]; }; default { if (( isNull _grp ) || ( { alive _x } count units _grp == 0 )) exitWith { _newGrp = createGroup side player; _newGrp setGroupIdGlobal [ "%GroupNames %GroupCompany %GroupPlatoon-%GroupSquad", "Yankee", _CompanyNames select _forEachIndex, _PlatoonNames select _forEachIndex, _SquadNames select _forEachIndex ]; [ _unit ] joinSilent _newGrp; player hcSetGroup [ _newGrp ]; myGrps set [ _forEachIndex, _newGrp ]; }; }; }; }forEach myGrps; }; TAG_fnc_joinMe = { params[ "_unit","_grp" ]; _unit setCaptive false; _unit joinAsSilent [ _grp, 2 ]; }; TAG_fnc_recUnit = { { player addAction [ format [ "Join %1", groupID _x ], { params[ "_target", "_caller", "_ID", "_args" ]; [ cursorTarget, _args ] call TAG_fnc_JoinMe; },_x,1,false,true,"",format [' _group = %1 call BIS_fnc_groupFromNetId; !(isnull cursortarget) && (_this isEqualTo _target) && {(cursorTarget isKindof "Man") && {(alive cursortarget) && {( side cursortarget isEqualTo side player || captive cursorTarget ) && {!(group cursortarget isEqualTo _group) && {({ alive _x } count units (_group) > 0 ) && ({ alive _x } count units (_group) < 12) } } } } }', str ( _x call BIS_fnc_netId )],15,false]; }forEach myGrps; }; TAG_fnc_mkSqLead = { player addaction ["Team Lead", {cursorTarget call TAG_fnc_frmNewHCGrp},nil,1,false,true,"",format ['( !(isnull cursortarget) && {(cursorTarget isKindof "Man") && {(alive cursortarget) && {( side cursortarget isEqualTo side player || captive cursorTarget ) && {!(Group cursortarget in myGrps ) || ( Group cursorTarget isEqualTo Group player) } } } })'],15,false]; }; _null = "init" spawn TAG_fnc_frmNewHCGrp; _null = [] spawn TAG_fnc_recUnit; _null = [] spawn TAG_fnc_mkSqLead; If I remove some of the conditions from the program in the recUnit function, I can assign units to all teams, but it is unsightly and I can add units to a team until the game crashes: myGrps = []; myGrps resize 10; myGrps = myGrps apply { grpNull }; TAG_fnc_initHCGrps = { { _newGrp = createGroup side player; _newGrp setGroupIdGlobal [ "%GroupNames %GroupCompany %GroupPlatoon-%GroupSquad","Yankee",CompanyNames select _forEachIndex,PlatoonNames select _forEachIndex,SquadNames select _forEachIndex]; myGrps set [ _forEachIndex, _newGrp ]; }forEach myGrps; }; TAG_fnc_frmNewHCGrp = { params[ "_unit" ]; _CompanyNames = ["CompanyXray","CompanyNovember","CompanyNovember","CompanyNovember","CompanyNovember","CompanyWhiskey","CompanyWhiskey","CompanyWhiskey","CompanyWhiskey","CompanyXray"]; _PlatoonNames = ["Platoon1","Platoon1","Platoon1","Platoon2","Platoon2","Platoon1","Platoon1","Platoon2","Platoon2","Platoon1"]; _SquadNames = ["Squad1","Squad1","Squad2","Squad1","Squad2","Squad1","Squad2","Squad1","Squad2","Squad2"]; { _x params[ "_grp" ]; switch (_unit) do { case "init": { _newGrp = createGroup side player; _newGrp setGroupIdGlobal [ "%GroupNames %GroupCompany %GroupPlatoon-%GroupSquad", "Yankee", _CompanyNames select _forEachIndex, _PlatoonNames select _forEachIndex, _SquadNames select _forEachIndex ]; if !(Group player isEqualTo (myGrps select 0)) then { [ player ] joinSilent _newGrp select 0; }; myGrps set [ _forEachIndex, _newGrp ]; }; default { if (( isNull _grp ) || ( { alive _x } count units _grp == 0 )) exitWith { _newGrp = createGroup side player; _newGrp setGroupIdGlobal [ "%GroupNames %GroupCompany %GroupPlatoon-%GroupSquad", "Yankee", _CompanyNames select _forEachIndex, _PlatoonNames select _forEachIndex, _SquadNames select _forEachIndex ]; [ _unit ] joinSilent _newGrp; player hcSetGroup [ _newGrp ]; myGrps set [ _forEachIndex, _newGrp ]; }; }; }; }forEach myGrps; }; TAG_fnc_joinMe = { params[ "_unit","_grp" ]; _unit setCaptive false; _unit joinAsSilent [ _grp, 2 ]; }; TAG_fnc_recUnit = { { player addAction [ format [ "Join %1", groupID _x ], { params[ "_target", "_caller", "_ID", "_args" ]; [ cursorTarget, _args ] call TAG_fnc_JoinMe; },_x,1,false,true,"",format [' _group = %1 call BIS_fnc_groupFromNetId; !(isnull cursortarget) && {(cursorTarget isKindof "Man") && {(alive cursortarget) && {( side cursortarget isEqualTo side player || captive cursorTarget) //&& {!(group cursortarget isEqualTo _group) //&& {({ alive _x } count units (_group) > 0 ) && ({ alive _x } count units (_group) < 12) //} //} } } }', str ( _x call BIS_fnc_netId )],15,false]; }forEach myGrps; }; TAG_fnc_mkSqLead = { player addaction ["Team Lead", {cursorTarget call TAG_fnc_frmNewHCGrp},nil,1,false,true,"",format ['( !(isnull cursortarget) && {(cursorTarget isKindof "Man") && {(alive cursortarget) && {( side cursortarget isEqualTo side player || captive cursorTarget ) && {!(Group cursortarget in myGrps ) || ( Group cursorTarget isEqualTo Group player) } } } })'],15,false]; }; _null = "init" spawn TAG_fnc_frmNewHCGrp; _null = [] spawn TAG_fnc_recUnit; _null = [] spawn TAG_fnc_mkSqLead;
  22. I just updated the program. See two posts above your last response. edit: mostly squashed now. In the last test, myGrps selec 1 didn't register as an option for other men to join, but all the other HC squads, including mine, did register in the action menu. I am retesting and making sure this isn't some wierd delay. edit2: I figured out what was going on. Though I am still stumped. I updated my post above.
  23. Hmm. It seems your code does not pass any arguments when the forEach loop iterates through the next cycle. For the next 9 squads, there is no squad ID, and selecting the action does nothing because no arguments were passed into TAG_fnc_joinMe edit: I know why. The squads are not created at compilation, they are created during runtime as needed. So when the addActions are created, there are no squad strings or group variables for it to pass, as the 9 of them are grpNull until assigned. I will have to force the code to createGroup and ID on compilation, but keep the squads blank of units, save the player's group. edit2: I just want to clarify, your code was most likely written for the singular part of the program, and it works with minor syntax corrections. However, I have to change the program to work with your code, which I needed and thank you for :) edit3: I updated the program above this post. It still has bugs and I am trying to squash, if you don't see an update, feel free to give your thoughts.
  24. I updated the code to where I was going with it. There were some syntax errors in what you had, but for the most part, once again, solid code. There was a bug, or I say, a lack of compatibility between your code and my entire program. So I rewrote the program and edited this post. edit: There is now a bug in this program that prevents the player from joining myGrps select 0 and forces the myGrps select 0 to always be used for all joining. I am trying to squash. edit2: I squashed most bugs. I had to rewrite fnc_frmNewHCGrp a tad in the middle. I also wasn't evaluating the if conditions to fit what I was trying to do exactly right. There was still a hiccup, but the code seemed to execute mostly correct. I am checking multiple times to make sure this isn't some sort of problem with the scheduler. edit3: I reproduced the "bug". So the code executes and runs fine, but if I add a guy to a new team and bring him back into my squad, that team is no longer available to my recUnit function. It would have to do with a condition in that function... I can, however, add a leader back into that squadron, but the recUnit will not see him anymore. I am leaning on: myGrps = []; myGrps resize 10; myGrps = myGrps apply { grpNull }; TAG_fnc_frmNewHCGrp = { params[ "_unit" ]; _CompanyNames = ["CompanyXray","CompanyNovember","CompanyNovember","CompanyNovember","CompanyNovember","CompanyWhiskey","CompanyWhiskey","CompanyWhiskey","CompanyWhiskey","CompanyXray"]; _PlatoonNames = ["Platoon1","Platoon1","Platoon1","Platoon2","Platoon2","Platoon1","Platoon1","Platoon2","Platoon2","Platoon1"]; _SquadNames = ["Squad1","Squad1","Squad2","Squad1","Squad2","Squad1","Squad2","Squad1","Squad2","Squad2"]; { _x params[ "_grp" ]; if ( isNull _grp ) then { _newGrp = createGroup side player; _newGrp setGroupIdGlobal [ "%GroupNames %GroupCompany %GroupPlatoon-%GroupSquad", "Yankee", _CompanyNames select _forEachIndex, _PlatoonNames select _forEachIndex, _SquadNames select _forEachIndex ]; myGrps set [ _forEachIndex, _newGrp ]; }; if (!( isNull _unit ) && ( { alive _x } count units _grp == 0 )) exitWith { [ _unit ] joinSilent _grp; if !( isPlayer _unit ) then { player hcSetGroup [ _grp ]; }; }; }forEach myGrps; }; TAG_fnc_joinMe = { params[ "_unit","_grp" ]; _unit setCaptive false; _unit joinAsSilent [ _grp, 2 ]; }; TAG_fnc_recUnit = { { player addAction [ format [ "Join %1", groupID _x ], { params[ "_target", "_caller", "_ID", "_args" ]; [ cursorTarget, _args ] call TAG_fnc_JoinMe; },_x,1,false,true,"",format [' _group = %1 call BIS_fnc_groupFromNetId; !(isnull cursortarget) && (_this isEqualTo _target) && {(cursorTarget isKindof "Man") && {(alive cursortarget) && {( side cursortarget isEqualTo side player || captive cursorTarget ) && {!(group cursortarget isEqualTo _group) && {({ alive _x } count units (_group) > 0 ) && ({ alive _x } count units (_group) < 12) } } } } }', str ( _x call BIS_fnc_netId ) ],15,false]; }forEach myGrps; }; TAG_fnc_mkSqLead = { player addaction ["Team Lead", {cursorTarget call TAG_fnc_frmNewHCGrp},nil,1,false,true,"",format ['(!(isnull cursortarget) && (alive cursortarget) && ((side cursortarget) == side player) && !(Group cursortarget in mygrps) || (Group cursorTarget == Group player) && (cursorTarget isKindof "Man")) && !((side cursortarget) == civilian) || (captive cursorTarget)'],15,false]; }; _null = objNull spawn TAG_fnc_frmNewHCGrp; _null = [player, (myGrps select 0)] spawn TAG_fnc_frmNewHCGrp; _null = [] spawn TAG_fnc_recUnit; _null = [] spawn TAG_fnc_mkSqLead; but I don't see yet why this would permanently remove an option for a squad that should eventually become true again. Current Program: myGrps = []; myGrps resize 10; myGrps = myGrps apply { grpNull }; TAG_fnc_frmNewHCGrp = { params[ "_unit" ]; _CompanyNames = ["CompanyXray","CompanyNovember","CompanyNovember","CompanyNovember","CompanyNovember","CompanyWhiskey","CompanyWhiskey","CompanyWhiskey","CompanyWhiskey","CompanyXray"]; _PlatoonNames = ["Platoon1","Platoon1","Platoon1","Platoon2","Platoon2","Platoon1","Platoon1","Platoon2","Platoon2","Platoon1"]; _SquadNames = ["Squad1","Squad1","Squad2","Squad1","Squad2","Squad1","Squad2","Squad1","Squad2","Squad2"]; { _x params[ "_grp" ]; if ( isNull _grp ) then { _newGrp = createGroup side player; _newGrp setGroupIdGlobal [ "%GroupNames %GroupCompany %GroupPlatoon-%GroupSquad", "Yankee", _CompanyNames select _forEachIndex, _PlatoonNames select _forEachIndex, _SquadNames select _forEachIndex ]; myGrps set [ _forEachIndex, _newGrp ]; }; if (!( isNull _unit ) && !( { alive _x } count units _grp > 0 )) exitWith { [ _unit ] joinSilent _grp; if !( isPlayer _unit ) then { player hcSetGroup [ _grp ]; }; }; }forEach myGrps; }; TAG_fnc_joinMe = { params[ "_unit","_grp" ]; _unit setCaptive false; _unit joinAsSilent [ _grp, 2 ]; }; TAG_fnc_recUnit = { { player addAction [ format [ "Join %1", groupID _x ], { params[ "_target", "_caller", "_ID", "_args" ]; [ cursorTarget, _args ] call TAG_fnc_JoinMe; },_x,1,false,true,"",format [' _group = %1 call BIS_fnc_groupFromNetId; !(isnull cursortarget) && (_this isEqualTo _target) && {(cursorTarget isKindof "Man") && {(alive cursortarget) && {( side cursortarget isEqualTo side player || captive cursorTarget ) && {!(group cursortarget isEqualTo _group) && {({ alive _x } count units (_group) > 0 ) && ({ alive _x } count units (_group) < 12) } } } } }', str ( _x call BIS_fnc_netId ) ],15,false]; }forEach myGrps; }; TAG_fnc_mkSqLead = { player addaction ["Team Lead", {cursorTarget call TAG_fnc_frmNewHCGrp},nil,1,false,true,"",format ['(!(isnull cursortarget) && (alive cursortarget) && ((side cursortarget) == side player) && !(Group cursortarget in mygrps) || (Group cursorTarget == Group player) && (cursorTarget isKindof "Man")) && !((side cursortarget) == civilian) || (captive cursorTarget)'],15,false]; }; _null = objNull spawn TAG_fnc_frmNewHCGrp; _null = player spawn TAG_fnc_frmNewHCGrp; _null = [] spawn TAG_fnc_recUnit; _null = [] spawn TAG_fnc_mkSqLead; edit: The bug, I believe, is in the conditions. For some odd reason, it only allows for the joining of the player group. I am going to set the whole condition to "true" and see if there are any other errors.
  25. Thanks for the response. Just wanted to point out that in the addAction condition section, you are correct that it takes string. However, if we use format in place of the string, you can't use format [" ",_vars]. You must use format[' ',_vars]. Because the section is technically a string, putting a string type command in a string requires the inverse character ', not ".
×