dr death jm 117 Posted June 19, 2016 I'm finding some difficulty: in a few cases I'm seeing that count will not work and will not cause an error.. only way I figured this out is playing around with forEach ... ie: count allUnits; works count _Units; doesn't cause error "but" doesn't work I could be mistaken , I'm very tierd.. anyone else having any issues with this? Share this post Link to post Share on other sites
Neviothr 102 Posted June 19, 2016 _units is a special variable. http://killzonekid.com/arma-scripting-tutorials-special-variables/ Share this post Link to post Share on other sites
M1ke_SK 230 Posted June 19, 2016 _units is a special variable. http://killzonekid.com/arma-scripting-tutorials-special-variables/ Could you use it in example that you are trying to use? Share this post Link to post Share on other sites
killzone_kid 1333 Posted June 19, 2016 _units is a special variable. http://killzonekid.com/arma-scripting-tutorials-special-variables/ It only has special meaning in certain concepts (listed on the right), other times it would be undefined. 2 Share this post Link to post Share on other sites
dr death jm 117 Posted June 19, 2016 Could you use it in example that you are trying to use? tlq_killTicker = { _this addMPEventHandler ['MPKilled',{ _unit = _this select 0; _killer = _this select 1; _newKill = [_unit,_killer]; if (count tlq_killArray > 100) then {tlq_killArray = []}; tlq_killArray set [count tlq_killArray,_newKill call tlq_parseKill]; //[] spawn tlq_killList; if (player isEqualTo _killer) then {_newKill spawn tlq_killPopUp}; } ]; }; tlq_parseKill = { _line = ""; _killerName = ""; _victimName = ""; _killerString = ""; _victimString = ""; _killerColor = "#99D5FF"; _victimColor = "#99D5FF"; _victim = _this select 0; _killer = _this select 1; if (!(isplayer _killer)) then { _killerName = getText (configFile >> "CfgVehicles" >> format["%1",typeOf _killer] >> "Displayname"); if(vehicle _killer != _killer) then {_killerName = getText (configFile >> "CfgVehicles" >> format["%1 crew",typeof vehicle _killer] >> "Displayname")}; }else{_killerName = name _killer}; if (!(isplayer _victim)) then { _victimName = getText (configFile >> "CfgVehicles" >> format["%1",typeOf _victim] >> "Displayname"); if(vehicle _victim != _victim) then {_victimName = getText (configFile >> "CfgVehicles" >> format["%1 crew",typeof vehicle _victim] >> "Displayname")}; }else{_victimName = name _victim}; if ((_killer isEqualTo player) or (_killer isEqualTo vehicle player)) then { _killerColor = "#ffff00"; //yellow } else { _killerColor = side group _killer call BIS_fnc_sideColor; _r = _killerColor select 0; _g = _killerColor select 1; _b = _killerColor select 2; _killerColor = [_r+0.1,_g+0.1,_b+0.1]; _killerColor = _killerColor call BIS_fnc_colorRGBtoHTML; }; if (_victim isEqualTo player) then { _victimColor = "#ffff00"; //yellow } else { _victimColor = side group _victim call BIS_fnc_sideColor; _r = _victimColor select 0; _g = _victimColor select 1; _b = _victimColor select 2; _victimColor = [_r+0.1,_g+0.1,_b+0.1]; _victimColor = _victimColor call BIS_fnc_colorRGBtoHTML; }; _killerString = format["<t color='%1'>%2</t>",_killerColor ,_killerName]; _victimString = format["<t color='%1'>%2</t>",_victimColor,_victimName]; //the line which shows the final formatted kill _line = switch(true) do { case(_killer isEqualTo _victim): {format ["%1 killed themselves",_killerString]}; case(isNull _killer): {format ["Bad luck for %1",_victimString]}; default {format ["%1 killed %2",_killerString,_victimString]}; }; _line; }; tlq_killPopUp = { _victim = _this select 0; _killer = _this select 1; _victimName = ""; _victimString = ""; _victimColor = "#99D5FF"; if (!(isplayer _victim)) then { _victimName = getText (configFile >> "CfgVehicles" >> format["%1",typeOf _victim] >> "Displayname"); if(vehicle _victim != _victim) then {_victimName = getText (configFile >> "CfgVehicles" >> format["%1 crew",typeof vehicle _victim] >> "Displayname")}; }else{_victimName = name _victim}; _victimColor = (side group _victim call BIS_fnc_sideColor) call BIS_fnc_colorRGBtoHTML; _victimString = format["<t color='%1'>%2</t>",_victimColor,_victimName]; _line = if ((_killer isEqualTo player) and (_victim isEqualTo player)) then { "<t size='0.5'>You killed yourself</t>"; } else { format ["<t size='0.5'>You killed %1</t>",_victimString]; }; [_line,0,0.8,2,0,0,7017] spawn bis_fnc_dynamicText; }; //declare global variables tlq_killArray = []; tlq_displayedKills = []; tlq_killTime = 0; //start kill registration for player if (!isNull player) then { player spawn tlq_killTicker; }; if (isServer) then { //ai { if (!(isPlayer _x)) then { _x spawn tlq_killTicker}; }count allUnits;<---------------------------only works if its foreach }; Share this post Link to post Share on other sites
sarogahtyp 1109 Posted June 19, 2016 you could try to return true inside ur count. i do that in each count with code in it. Share this post Link to post Share on other sites
M1ke_SK 230 Posted June 19, 2016 Are you running this script with doFSM? Description is saying: _units list of all persons in subgroup try debug _units. See what is in that variable before using it. systemChat format ["%1", _units]; Share this post Link to post Share on other sites
Neviothr 102 Posted June 19, 2016 (edited) (removed) Edited June 20, 2016 by cx64 Share this post Link to post Share on other sites
kylania 568 Posted June 19, 2016 Hmm, am I seeing multiple functions in the same file? I think it would be wise to put each function inside a different file, if it actually looks like this. Nothing wrong with having multiple functions declared in a single file. I found the original post for this script and it's using allUnits. It's also meant to be called from the init.sqf so it just loads once and not run as an FSM. I can only imagine in his sleep delirium dr death jm remembered that _units can be a special variable and thought it always was, so he tried it? :) 1 Share this post Link to post Share on other sites
serena 151 Posted June 19, 2016 I think it would be wise to put each function inside a different file, if it actually looks like this. I want to improve this a wise idea - it is better to put each command in a separate file! Sarcasm mode OFF. Sorry 1 Share this post Link to post Share on other sites
Tankbuster 1747 Posted June 19, 2016 I want to improve this a wise idea - it is better to put each command in a separate file! Sarcasm mode OFF. Sorry How about each character in it's own file? Share this post Link to post Share on other sites
serena 151 Posted June 19, 2016 How about each character in it's own file? Fn_WiseExecute = { call compile (_this apply {loadFile _x} joinString "") }; Fn_TestWiseExecute = { ["s.sqf", "y.sqf", "s.sqf", "t.sqf", "e.sqf", "m.sqf", "C.sqf", "h.sqf", "a.sqf", "t.sqf", "spc.sqf", "dqt.sqf", "C.sqf", "o.sqf", "d.sqf", "e.sqf", "spc.sqf", "W.sqf", "i.sqf", "s.sqf", "e.sqf", "l.sqf", "y.sqf", "xcl.sqf", "dqt.sqf"] call Fn_WiseExecute }; Demo mission: CodeWisely.Altis Now I am considering idea how to put each file containing a character on a separate hard drive 1 Share this post Link to post Share on other sites
serena 151 Posted June 19, 2016 _unit = _this select 0; _killer = _this select 1; _newKill = [_unit,_killer]; if (count tlq_killArray > 100) then {tlq_killArray = []}; tlq_killArray set [count tlq_killArray,_newKill call tlq_parseKill]; if (player isEqualTo _killer) then {_newKill spawn tlq_killPopUp}; // instead of _newKill = [_unit, _killer] you can use _this variable containing same values _this call tlq_parseKill; _this spawn tlq_killPopup; // if you want to add something at the end of array you can use more effective pushBack command tlq_killArray pushBack (_this call tlq_parseKill); 1 Share this post Link to post Share on other sites
serena 151 Posted June 19, 2016 if (isServer) then { //ai { if (!(isPlayer _x)) then { _x spawn tlq_killTicker}; }count allUnits;<---------------------------only works if its foreach }; In this case you execute something for each element of array. Who you trying to enumerate array elements using count command instead of forEach? Share this post Link to post Share on other sites
dr death jm 117 Posted June 19, 2016 Nothing wrong with having multiple functions declared in a single file. I found the original post for this script and it's using allUnits. It's also meant to be called from the init.sqf so it just loads once and not run as an FSM. I can only imagine in his sleep delirium dr death jm remembered that _units can be a special variable and thought it always was, so he tried it? :) yup... you figured it... I was trying ... (I'm still a noob). it seems as I learn new code/scripts/engine is updated.. I'm gone 12 hours a day (work) I cant keep up, lol I get up 4am just to look thru things arma3 related .. get to work at 530 am... get home anywere from 4pm to 6 pm... cook and clean (kids)... shower and then arma3 till bed ... (what a life I have ) Share this post Link to post Share on other sites
dr death jm 117 Posted June 19, 2016 I want to improve this a wise idea - it is better to put each command in a separate file! Sarcasm mode OFF. Sorry I like this way of thinking Share this post Link to post Share on other sites
dr death jm 117 Posted June 19, 2016 // instead of _newKill = [_unit, _killer] you can use _this variable containing same values _this call tlq_parseKill; _this spawn tlq_killPopup; // if you want to add something at the end of array you can use more effective pushBack command tlq_killArray pushBack (_this call tlq_parseKill); I'm still a noob... I understand but :banghead: Share this post Link to post Share on other sites
dr death jm 117 Posted June 19, 2016 In this case you execute something for each element of array. Who you trying to enumerate array elements using count command instead of forEach? count is a tiny little faster... optimizing is my ocd Share this post Link to post Share on other sites
dr death jm 117 Posted June 19, 2016 also .. script above is just an example... its edited to fit my needs... but we all should maybe make a thread somewhere, just for optimizing code. id love to post some code and have you pro's rip into it... ;) Share this post Link to post Share on other sites
kylania 568 Posted June 19, 2016 id love to post some code and have you pro's rip into it... ;) I'll start! Click MultiQuote on the various messages you want to reply to, then click the "Reply to X posts" at the very bottom to condense them all into one post. :) 1 Share this post Link to post Share on other sites