Ok, first off, some basics about addaction. Scripts run from the action will have these three parameters:
_this select 0 = unit/object the action was added to
_this select 1 = unit that activated the action
_this select 2 = index of the action
Even though it is always going to be the player that uses this action, you should get into the habit of making your scripts sorta universal, so they
could be used by people other than "guy", if you later wanted to. So it should look more like this:
_man = _this select 1
? _man != _this select 0 : exit .......
_man playmove "CrouchToBinocCrouch"
.......
The part in bold will make sure nobody can use the action except the unit the action was added to (try adding an action to an AI unit and you will see that anyone close can use actions that are added).
The last parameter passed to the script (_this select 2) is what you should use with the 'removeaction' command. So instead of "guy removeaction 0", you should put "guy removeaction (_this select 2)".
---------------------------------------------------------------------------
You should be able to understand the stuff I just said above, and it will help you tons in the future. Now time for the more advanced stuff that will help you with this specific script. You could just use what I told you above, and make 5 different scripts, like you are doing. It will work, but if you want to be more fancy about it, you can do it like this:
INIT.SQS OR THE INIT FIELD OF THE GUYbombs_left = 5; guy addaction addaction [format ["put timebomb (%1 left)", bombs_left], "timebomb.sqs"]
TIMEBOMB.SQS_man = _this select 1
? _man != _this select 0 : exit
_man removeaction (_this select 2)
"timebomb" camcreate [getpos _man select 0, getpos _man select 1, 0.1]
bombs_left = bombs_left - 1
_man playmove "CrouchToBinocCrouch"
hint "Timebomb Set, 20 seconds until explosion"
~10
hint "10 seconds until explosion"
~5
hint "5 seconds until explosion"
~2
hint "3 seconds until explosion"
~1
hint "2 seconds until explosion"
~1
hint "1 seconds until explosion"
~1
hint "timebomb exploded"
? bombs_left > 0 : _man addaction [format ["put timebomb (%1 left)", bombs_left], "timebomb.sqs"]
exit
Now, I've incorporated the basic stuff I covered into the top of the script. But the trick is at the bottom of the script. bombs_left is a global variable. In case you don't know, that means all scripts can see and use it; just like all scripts can see the name of a unit. You can tell because it doesn't have an underscore _ in front of it. You'll see that at the top of the script, this variable is lowered each time the script is run. At the bottom, a new action is only added if this variable is above 0. Now for the tricky part, this line:
_man addaction [
format ["put timebomb (%1 left)", bombs_left], "timebomb.sqs"]
You'll notice that the same script is used each time the action is added again. And you now see why it will only add the action back a limited number of times. But to let the player know how many bombs he has left, the description of the action is changed each time by the script (the part in bold).
Click here for info on the format command, and you will understand why this works.