As you can hear by the name, this function adds one to the variable:
AddGlobalVarInt("TasksDone", 1);
You should insert it into the function for each event. For example: "1.Talk to "Martin Smith" - Henry's freind over the phone about his loss and other things."
I'm just speculating now, but let's assume it is triggered by clicking a telephone. Clicking the phone will play a sound/conversation between the main character and Martin. In the same function which plays the sound/executes the "happenings" simply insert the:
AddGlobalVarInt("TasksDone", 1);
That will add "1" to the variable "TasksDone". Just remember to insert it into do-once functions. By that I'm meaning you should
not have it in a function which may be executed several times. Otherwise the player may do the same action 20 times (thus bypassing the demand for completing all of the tasks).
As for "checking" let's assume a second scenario; As the player enters a scriptarea close to the bed he will lie down and sleep if all of the 20 tasks are complete.
Here is the "checking part":
The line which says:
if (GetLocalVarInt("TasksDone") == 20)
Checks if "TasksDone" is equal to 20. If it is equal to 20 the player will "rest". Thus when all tasks are completed the variable "TasksDone" should be equal to 20; causing the player to sleep.
The "else" part in it says that if TasksDone is not equal to 20 it will instead display a message (which you could set to something like "I can't rest until I have finished todays jobs/tasks").