Using $decode isn't usually a good solution as most people have it disabled. And enabling it just for this isn't really the best idea, imo.
To the OP:
First of all, does your network(s) support ghosting? That would be the best option. Otherwise, you'll need to keep trying to change your nick until your previous nick pings out.