Many of the questions you ask can be answered by a quick look in the wiki:
http://www.eqemulator.net/wiki/wikka...goryTaskSystem
Here is the example of what you are wanting in this case:
http://www.eqemulator.net/wiki/wikka...kSystemPerlAPI
Code:
sub EVENT_TASK_STAGE_COMPLETE
Exports $task_id and $activity_id.
And more info on the player.pl file (which is where you use this event type):
http://www.eqemulator.net/wiki/wikka...rQuestExamples