Home   Help Search Login Register  

Author Topic: AddAction And Removeaction with array  (Read 1690 times)

0 Members and 1 Guest are viewing this topic.

Offline Praxtor

  • Members
  • *
    • Operflashpoint
AddAction And Removeaction with array
« on: 10 Nov 2008, 10:22:33 »
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

Offline i0n0s

  • Former Staff
  • ****
Re: AddAction And Removeaction with array
« Reply #1 on: 10 Nov 2008, 11:17:49 »
Code: [Select]
(TAH Select _i) = Player addaction [name(_Units select _i),"Scripts\Medic\Heal.sqf",(_Units select _i)]; select returns a read only value. To write a value use set.

About removing the action after calling:
When calling the id will be passed as third parameter.

Offline ModestNovice

  • Members
  • *
Re: AddAction And Removeaction with array
« Reply #2 on: 11 Nov 2008, 07:00:21 »
Also you need a '[' for the last part of the addAction.

Like this:

Code: [Select]
(TAH Select _i) = Player addaction [name(_Units select _i),"Scripts\Medic\Heal.sqf",[(_Units select _i)];
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: AddAction And Removeaction with array
« Reply #3 on: 11 Nov 2008, 15:25:41 »
Hmmmmm, now the line has two opening '[', but only one closing ']'.

 ::)


Planck
I know a little about a lot, and a lot about a little.

Offline ModestNovice

  • Members
  • *
Re: AddAction And Removeaction with array
« Reply #4 on: 11 Nov 2008, 22:45:33 »
Sry, I meant:

Code: [Select]
(TAH Select _i) = Player addaction [name(_Units select _i),"Scripts\Medic\Heal.sqf",[(_Units select _i)]];
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley