red62 1 Posted May 26, 2017 I am trying to assign different team colors using assignTeam, depending on their role description in a squad (Where a role description would look like 1'1A Team Lead, 1'1B Assistant Automatic Rifleman etc). This is what I have currently, I have tried to make this work for a couple hours with no luck. It looks like the "roleDescription" function doesn't return anything when called on the unit in the forEach. //preset fireteam group colours //id = ["RED", this] execVM "Teams.sqf"; sleep 10; private ["_type", "_unit"]; _type = _this select 0; _unit = _this select 1; Sleep 5; { color = if (((roleDescription _x) find "A ") > 0) then { "BLUE" } else { "RED" }; _x assignTeam color; } forEach units group _unit; I am calling it from the squad lead's init using ["RED", this] execVM "quickteams.sqf"; . The first param is unused as of now. The script currently just assigns everyone in the team to RED, which I interpret as it not finding "A " in any of the unit's role descriptions (even though I set them myself and can view them in the editor). I appreciate the help. Share this post Link to post Share on other sites
pierremgi 4905 Posted May 26, 2017 This should be >=0 because your find returns 0! Each time you have a doubt with such condition, use it in debug console (watch lines). Share this post Link to post Share on other sites
red62 1 Posted May 26, 2017 The documentation page for find (https://community.bistudio.com/wiki/find) says that it returns -1 if it is not found... But I tried the logic color = if (((roleDescription _x) find "B ") >= 0) then { "BLUE" } else { "RED" }; with no luck. Every squad member is still colored RED Share this post Link to post Share on other sites
pierremgi 4905 Posted May 26, 2017 Just because you're testing in SP, and, regardless of what BIKI says, in SP (preview at least) roledescription returns "". So allow debug console for all players in generality params, and run it in MP preview session. NB: roleDescription works for playableUnits only. That means not on AI disabled in lobby and not in SP (even for player). Share this post Link to post Share on other sites
red62 1 Posted May 27, 2017 Thanks for the help, it looks like it works now! One more thing, I tried to write a script to assign the correct net in ACRE to each unit based on their squad, using the ACRE api. It seems to have worked in singleplayer, but when we tested it in multiplayer it seemed to work about 50% of the time and assign a random channel the other 50% of the time (aka one of the other squads' net). Here is the code: //preset fireteam group colours //[3, this] execVM "radioDefault.sqf"; sleep 10; private ["_channel", "_unit"]; _channel = _this select 0; _unit = _this select 1; Sleep 5; waitUntil { ([] call acre_api_fnc_isInitialized) }; { [(["ACRE_PRC343"] call acre_api_fnc_getRadioByType), _channel] call acre_api_fnc_setRadioChannel; } forEach units group _unit; I am calling [3, this] execVM "radioDefault.sqf"; in the init of each squad lead, replacing the 3 with the correct net. I am wondering if this is not the correct way to try to work this script in, and instead if I should include some code in initPlayerLocal to run individually and switch on the player's group. Share this post Link to post Share on other sites