Home   Help Search Login Register  

Author Topic: Addaction and Removeaction  (Read 771 times)

0 Members and 1 Guest are viewing this topic.

Knut Erik

  • Guest
Addaction and Removeaction
« on: 03 Apr 2003, 17:22:56 »
I have this nice script to take a radio. Then i want to remove the "Take Radio" action when the player is not near. It works, but only onse. Like this:
I go to the radio and then leaves. The action comes and leaves correctly, but when i try it again, the action just comes and never leaves. If i go to the radio several times the action comes again and I've got TWO "take radio" actions in the action menu  :-\ :'(

Here is the script.
Code: [Select]
#loop
@ aP distance radiotown < 5
aP addaction ["Take radio","takeradio.sqs"]
@ aP distance radiotown > 5
aP removeaction 0
goto "loop"

Does anybody here knows what could be wrooong?
 >:( :( :-\ :'( :-\ :'( :-\ :'( :-\ :-\ :'( :'( :-\ :-\ :-\ :'( :'( :( :(

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Addaction and Removeaction
« Reply #1 on: 03 Apr 2003, 17:29:49 »
First time you add action - action id = 0
Second time you add action - action id = 1

So the action id is incrementing, but your removeaction line is stuck at 0.
Plenty of reviewed ArmA missions for you to play

Knut Erik

  • Guest
Re:Addaction and Removeaction
« Reply #2 on: 03 Apr 2003, 17:33:09 »
Whawhaaattt??  ???
What do you mean. (I know i'm a bit thick)
Can you explain a bit more.
Come on. I know you can do it :thumbsup:   ;)

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Addaction and Removeaction
« Reply #3 on: 03 Apr 2003, 17:40:09 »
Apologies for not being clearer.   We know that

aP removeaction 0

means, remove the action with the ID 0.    No problems there.  Now, due to a bug its kinda hard to tell what the ID of an action is, but we do know that the first action to be added to a unit gets the ID 0, the second one gets ID 1 and so on.

So the first time you add the action the action ID is 0 and your removeaction command will work.   The second time the action is added, even though its the same action, the ID is 1.   So your command to removeaction 0 will not do anything because there is no action 0, there is only an action 1.

If you were to add this line to your script, next to the existing removeaction line

aP removeaction 1

you would find that the second time the action would be removed.   But not the third time, for that you would need

aP removeaction 2

and so on.    What we want is a removeallactions command, but I don't think it exists.   Maybe you could try

"aP removeaction _x" forEach [0,1,2,3,4,5,6,7,8,9]

syntax not guaranteed.    Anyway, somebody must know a better way, I'm just making this up.  

Does that help?   The summary is add this line

aP removeaction 1

and see what happens.
Plenty of reviewed ArmA missions for you to play

Offline Artak

  • The old beanbag shaker
  • Former Staff
  • ****
  • You want to talk about it, yes?
    • OFP Team Finlanders
Re:Addaction and Removeaction
« Reply #4 on: 03 Apr 2003, 18:05:44 »
there's a nice tutorial for it too. you can find it on this page here
http://www.ofpec.com/editors/browse.php?category=1_2
Not all is lost.

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Addaction and Removeaction
« Reply #5 on: 03 Apr 2003, 18:51:35 »
lol I wish I'd known that
Plenty of reviewed ArmA missions for you to play

Knut Erik

  • Guest
Re:Addaction and Removeaction
« Reply #6 on: 04 Apr 2003, 10:56:38 »
Thank for all your help guys!
I'll check out the Toturial and hopefully learn a lot...

 :thumbsup:  :thumbsup:  :thumbsup:  :thumbsup:  :thumbsup:  :thumbsup:  :thumbsup:  :thumbsup:  :thumbsup:  :thumbsup:  :thumbsup:  :thumbsup: