You might want to use network name for checking instead of server name. To know network name use //echo $network
I believe the code must be like this.
Code:
on *:TEXT:*:#firstchannel:{
  if $network == firstnetwork { scid -at1 relay # $replace($1-,|,-,%,-,$,-) }
}

alias -l relay {
  if $network == secondnetwork && $me ison #secondchannel {
    msg #secondchannel ( $1 ) $2-
  }
}

Last edited by blessing; 14/05/14 11:55 AM.