the addaction part there is correct, obviously, you'll need a script for it (you could add all sorts of animations and whatnot here if you want). As to how to add the thing once you're close enough, I suggest such a procedure:
make trigger, a/b 0, repeated, type: switch
condition line: aP Distance id_officer<5 && !papersGiven
just change those to whatever the names of the people are, and change the number (in meters) to when you want the action to appear. The papersGiven variable is something you need to define first, for instance in your init.sqs (this is a script which activates when the mission initializes). Just put in papersGiven=false somewhere, and you're fine.
On activation line: ActionId=Player addAction["Give Id", "giveid.sqs"]
On Deactivation: Player removeAction ActionID
the actionID is the "name" of the action, and it gets removed when aP moves more than 5 meters (in my example) from the unit id_officer (this is due to the switch nature of the trigger).
Now, just put in, at the start of your giveid.sqs script, papersGiven=true
Now, as you'll notice, it's impossible for the trigger to activate (condition: not(papersGiven)), the action disappears, and everyone is happy
As to the guard shooting you...well, the easiest is probably the setCaptive command; to approach the base, just make yourself setCaptivated (aP setCaptive TRUE). Now, make a trigger covering the entrance, and make the
condition: ap in thisList && !papersGiven
on activation: aP setCaptive FALSE
the papersGiven was the variable which was set to true when you gave the papers; thus, if it's false and aP is in the trigger area (aP in thisList), the setcaptive is made false, and the guards will open fire. That is, if they're enemies from the start
Otherwise, go with the rating thing. It rather sucks with them screaming "cease fire!" all the while trying to blow your head off, but what they hey...
Problems? Complain, and we'll come rushing
Good luck!
Wolfrug out.