Hi

You had two errors.
When working with an alias outsite a event you need to send all the information to that alias.

In this case you have not send the channel. I have created tha variable %Chan and have added to the on text event and addes %Chan to the alias dmsg.

The other small thing was that you have close your alias with a ) and not with the }.

Th rest off the code sounds good... I think it should work fine.

Code:
on *:text:*:#:{
  set %Chan $chan
  if (!stats isin $strip($1-2)) {
    if ($2 == !stats) { 
      var %nick = $iif($3,$3,$1), %ingame = 1
    }
    elseif ($1 == !stats) { 
      var %nick $iif($2,$2,$nick)
    }
    dmsg %nick has killed $calc($hget(playerkills,%nick)) people without dying. 
  }
  elseif (!deaths isin $strip($1-2)) {
    if ($1 == !deaths) { 
      var %nick $iif($2,$2,$nick)
    }
    elseif ($2 == !deaths) { 
      var %nick $iif($3,$3,$1), %ingame 1
    }
    dmsg %nick has died $calc($hget(playerdeaths,%nick)) times.
  }
}

alias dmsg { 
  msg %Chan $iif(%ingame,!fds msg) $1-
  unset %Chan
}