Praxtor 0 Posted November 10, 2008 Hello: I want create one script that create one action to the leader of the group with the name of the inhured player in his group for can select ans send one medic to this unit to heal, if i have several inhured units i create several actions in one time with this code: TAH =[]; _Units = Units Player; For [{_i=0}, {_i <= (Count _Units)}, {_i=_i+1}] do { Â If (Damage (_Units Select _i)>0.1 && Damage (_Units Select _i) < 1) Then { Â Â Â TAH Set [_i,Format["ASH%1",_i]]; Â Â Â Â Â Â Â Â Player addaction [name(_Units select _i),"Scripts\Medic\Heal.sqf",(_Units select _i)]; Â Â Â Â }; }; With This code i can create one action in the leader for every player or Ia inhured inside of the Leader group but i want create one Index for can delete all the actions when you click in one of this, for this i create the table TAH=[]; I go inserting in this line TAH Set [_i,Format["ASH%1",_i]]; Â one new element to the talbe like this ASH0, ASH1, ASH2 etc etc, and if i put this index to the action like this: (TAH Select _i) = Player addaction [name(_Units select _i),"Scripts\Medic\Heal.sqf",(_Units select _i)]; I get one error. The other problem is in the Scripts that i call when i press the action, i can not delete all the Actions because i have not index for this, i try to made some thing like this: _Units = Units Player; For [{_i=0}, {_i <= (Count _Units)}, {_i=_i+1}] do { Â Â If (Damage (_Units Select _i)>0.1 && Damage (_Units Select _i) < 1) Then { Â Â Â Â Â Â Â player removeaction (TAH Select _i); Â Â Â Â Â Â Â Â Â }; }; Â I get other error here: player removeaction (TAH Select _i); and (TAH Select _i) is ASH0 but the game say waiting number and it is one String. Can some guy help me?? Regards Share this post Link to post Share on other sites
squeeze 22 Posted November 10, 2008 I've fallin for the "loop count this trap" so many times. for [{BEGIN}, {CONDITION}, {STEP}] do { STATEMENT; ... }; * BEGIN is a number of statements executed before the loop starts * CONDITION is a Boolean condition evaluated before each loop * STEP is a number of statements executed after each loop this might work better For [{_i=0}, {_i <= ((Count _Units)-1)}, {_i=_i+1}] do { or I've change to this type of loop now for my "count this" for "_i" from 1 to (count _Units) do { I didn't look at the rest of the code. Share this post Link to post Share on other sites
Synide 0 Posted November 10, 2008 haven't read you post too thoroughly... but... your making an array... what 'type' are the items in the array... hmmm, 'string' i'd say... so, when you are setting up your addaction you are currently saying... string = addaction stuff... which would be the wrong syntax... you can still use your array of strings if you want... but when you go to setup your addaction you want to do something like... <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">call compile format["%1 = Player addaction [name %2,""Scripts\Medic\Heal.sqf"",%2];", TAH Select _i, _Units select _i]; Get it? PS. The above may not be verbatim syntax but it's the concept that's the point... What you are trying todo is create multiple consequtively numbered variables that will hold the 'pointer index' returned by the addaction scripting command/function. Share this post Link to post Share on other sites
Praxtor 0 Posted November 10, 2008 Ok Synide i will try your call compile, is correct like you say i want create multiple variables for can index the addactions and later can delete. Regards Share this post Link to post Share on other sites
Praxtor 0 Posted November 10, 2008 Hello: Thanks now is working fine: It is the code: Call Compile Format["%1 = Player addaction [name (_Units select _i),'Scripts\Medic\Heal.sqf',(_Units Select _i)];",(TAH Select _i)]; And the Remove action is: Call Compile Format ["Player Removeaction %1",(TAH Select _i)]; Thanks a lot. Share this post Link to post Share on other sites
Taurus 20 Posted November 19, 2008 Just a follow up, could someone please clarify the "Call compile"-concept? What does it do, and why/how does it work? I've tried to read the wiki, but it doesn't cover this approach. Examples of how it could be implemented (except from the scenario described here) is more than appreciated. Thanks in advance. Share this post Link to post Share on other sites
Namikaze 0 Posted November 19, 2008 "call compile format" is actually three different commands working in conjunction. Â When using a "for" loop (or whatever, really) you might want to use the iterator in your code somewhere. Â Let's say you're adding civilians. Â You want each to look a little different so when you can use the iterator to cycle through the different models that are available. Â If you carefully read the following links and the above code samples that people have left, you should be able to get it. Â Links: call code compile format EDIT: An example (excepted from the ones above). <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> for[{_i = 1}, {_i <= 5}, {_i = _i + 1}]do { [] call compile format ['unit_%1 sideChat "Hello world";', _i]; }; That code makes first, unit_1 talk, then unit_2, then unit_3, etc. I hope that makes more sense. Share this post Link to post Share on other sites