Some networks allow you to put your nickserv password as the server password, freenode is one of them:
/server irc.freenode.net 6667 PASSWORD -i NICKNAME
The above will auth you with nickserv without a script (and yes, you can add it to your servers list this way too). Other networks might work the same way, otherwise use a similar script to the one provided above.