OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Knut Erik 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.
#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?
>:( :( :-\ :'( :-\ :'( :-\ :'( :-\ :-\ :'( :'( :-\ :-\ :-\ :'( :'( :( :(
-
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.
-
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: ;)
-
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.
-
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
-
lol I wish I'd known that
-
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: