Try this instead:

var %nick = $gettok($1,1,40)

By what you are describing, you will need to store the names of the users who are in both locations, and then use that to allow them access to the script commands.

-genius_at_work