My suggestion would be to look at the coding in the online users block and modify a copy of that:
1) To limit users to specific roles
2) To list offline as well as online users
At the worst you will have learned a lot about the way Moodle coding works.
As an alternative to coding you could install the configurable reports block and create an SQL report modifying the queries you can find in fetcher.php in that block.