Something along the lines of this, of course you would need to edit it for your own purposes.
_unit = _this select 0
_player = _this select 1
?runonce: goto "whenadd"
actionnumber = 0
this means at 5m the addaction will come on, and when you leave 5m, it will come off
#whenadd
?(_player distance _unit < 5): goto "action"
~0.3
goto "action"
#action
runonce=true
action = _player AddAction ["Do Thingy","thingy.sqs"]
;here I am IDing the action, to a name which is action, so when you use the action in the game OFP will recognise you just used 'action'
~0.3
goto "start"
#start
?nameofthisscript: goto "whathappens"
?(_player distance _unit) < 5: goto "start"
_player RemoveAction (action)
actionnumber = (actionnumber + 1)
goto "action"
#whathappens
titletext["Yes! We got it","plain",2]
;or whateva u want to happen here
goto "nomore"
#nomore
nameofurscript=false
_player removeaction action
actionnumber = (actionnumber + 1)
exit