1) If you cant figure that out on your own, maybe scripting isnt for you.

2) Server wide can't be done like this, unless you are in the channel with them. If you are a Server Administrator, or an IRCop then you need to learn how to work with that software to get what you want. If you are not Admin or IRCop then you shouldn't be worried about who is idle on the server.