What you would want to do, is save nicknames based on address, and when a user joins, just cross reference the address.
I recomend using hash tables for storing the stuff
Other the ntaht, it'll be a normal on join event with an if statement in it.
Feel free to ask more if you are uncertain as to how the actual script should look/work