I have written a whole script to do pretty much what you are asking, but I wrote it a very long while ago, so it is a bit grim (naive and over-complex) ;P I'll give you a shorter and simpler version instead, especially since my version was for a whole team running a FIBUA, which isn't quite what you want.
This script counts shots and hits, keeping the targets down once hit, until the player has shot them all or used too much ammo (To keep the target down, you need to animate the target when it is on the way up again, not on the way down):
_targets = _this select 0;
_maxShots = _this select 1;
shotsFired = 0;
numHits = 0;
// Detect when the player has fired a weapon.
_firedEventIndex = player addEventHandler ["FIRED",
{
shotsFired = shotsFired + 1;
}
];
// Detect when a target has been hit.
{
_hitEventIndex = _x addEventHandler ["HIT",
{
_target = _this select 0;
_shooter = _this select 1;
// Only allow the player to score the first time the target is hit.
_target removeEventHandler ["HIT", _target getVariable "targetHitEventIndex"];
// Only add score for the local player.
if (_shooter == player) then
{
numHits = numHits + 1;
};
// Animate on every client though.
if (not (isNull player)) then
{
[_target] spawn
{
_target = _this select 0;
// Wait until the target is completely flat on the ground.
waitUntil {(_target animationPhase "terc") == 1};
// Wait until the target starts moving up.
waitUntil {(_target animationPhase "terc") != 1};
// Push the target back down again.
_target animate ["terc", 1];
};
};
}
];
_x setVariable ["targetHitEventIndex", _hitEventIndex];
} forEach _targets;
// Keep going until used all allowed shots or hit all targets.
waitUntil { (shotsFired == _maxShots) or (numHits == (count _targets)) };
player removeEventHandler ["FIRED", _firedEventIndex];
{
// Make sure that the event handler has been removed.
_x removeEventHandler ["HIT", _x getVariable "targetHitEventIndex"];
// Raise the target again.
_x animate ["terc", 0];
} forEach _targets;
hint format ["You hit %1 targets out of %2 with %3 shots", numHits, count _targets, shotsFired];
From this, you can probably work out how to have a target down at the start of the mission or how to pop all the targets up from a trigger. Having them pop up and down at random makes things a lot more complex though. To achieve this, you could have a _targetsLeft array from which you remove one element at random each time, raising it for a short while and adding a hit event handler then lowering it and removing the hit event handler again).
** EDITED **
I hadn't properly tested it, but the script was longer than I should have written off the top of my head! Fine now.