The docs page http://docs.moodle.org/dev/Plugins provides a list of available plugin types in Moodle. To help with the best type for your case, we would probably need more detailed description of what you are actually trying to achieve.
I saw that page and as I understood from that I think Local Plugins are the best fit but I have no idea how listen for activities to happen!
I Want to create a mechanism to whenever someone registers on a course, system give him a rank (for that course only) based on his activities
for example I want each time he views the course system give him 1 point then when he added a comment system give him another 1 point and ...
At the end each user in that course hould have a number as Rank or Reputation for that user in that course
Beware, local plugins are very tempting to be (ab)used. What you describe sounds more like an Activity module (mod) as it is something that participants in one given course interact with during learning. So I would suggest to give the mod type a try and looked closely at the new Events API that should allow your activity modele become an observer of other events triggered within the course.
Thanks
So you say I should create an activity plugin that listens to course events.
In this case can I store different ranks for different students for this course only?
Should I add a table for my ranks to database or moodle has a mechanism to keep my ranks for each enrolled student?