on *:text:*:*:{
  if (!$chan) close -m $nick
  var %t = $left($1,1),%1 = $right($1,-1)
  if (%t !isalnum) { 
    if ($hget($nick)) {
      if (%1 == browse) {
        if ($len($2) > 3) && ($2 isin Gundams) {
          var %n = 1,%names 
          while ($ini(gundams.ini,%n)) {
            var %price = $chr(36) $+ $bytes($readini(gundams.ini,$v1,price),db)
            var %names = %names $+($v1,( $+ %price $+ ))
            inc %n
          }
          _msg $nick (Store) Gundams: $iif(%names,$v1,N/A)
        }
      }
      if (%1 == buy) {
        if ($ini(gundams.ini,$2)) {
          var %price = $readini(gundams.ini,$2,price)
          if ($u.mon($nick) >= %price) {
            hdec $nick money %price
            add_gundam $nick $2
            _msg $nick (Store) You've bought the $2 $+ ! To set $2 as your current gundam, type $+(,%t,SET $2,) 
          }
          else _msg $nick (Store) You're $chr(36) $+ $calc(%price - $u.mon($nick)) from the $2
        }
        else _msg $nick (Store) Invalid Gundam selection
      }
      if (%1 == set) {
        if ($istok($u.gunds($nick),$2,44)) {
          hadd $nick currentgundam $2
          _msg $nick You're now piloting the $2
        }
        elseif ($2 == output) { 
          if ($istok(msg notice,$3,32)) {
            hadd $nick output $3
            _msg $nick Set output to $3 
          }
          else _msg $nick Output methods are "NOTICE" and "MSG" only.
        }
      }
      if (%1 == stats) _stats $nick $iif($2,$2,$nick)
    }
  }
}

; Statistical info
alias g.power return $readini(gundams.ini,$1,power)
alias g.agil return $readini(gundams.ini,$1,agility)
alias g.armor return $readini(gundams.ini,$1,armor)
alias g.spec return $readini(gundams.ini,$1,specials)
alias g.hp return $readini(gundams.ini,$1,hp)
; End 

alias add_gundam {
  if ($hget($1)) {
    if ($ini(gundams.ini,$2)) {
      var %c = hadd $1 $+($2,.)
      %c $+ power $g.power($2)    
      %c $+ agility $g.agil($2)
      %c $+ armor $g.armor($2)
      %c $+ specials $g.spec($2)
      %c $+ hp $g.hp($2)
      hadd $1 gundams $addtok($u.gunds,$2,44)
      return Successfully added Gundam                
    }
    else return Invalid Gundam
  }
  else return $1 is not registered
}
alias del_gundam {
  if ($hget($1)) {
    if ($istok($u.gunds($1),$2,44)) {
      hdel -w $1 $+($2,.*) 
      hadd $1 gundams $remtok($u.gunds,$2,44)
      return Successfully deleted Gundam
    }
    else return Invalid Gundam
  }
  else return $1 is not registered
}
alias _stats {
  _msg $1 $iif($2 != $1,Name: $2) $iif($u.cgun,Current Gundam: $u.cgund($2)) Level: $u.level($2) Experience: $+($u.exp($2),/,$u.nexp($2)) $&
    Money: $chr(36) $+ $bytes($u.mon($2),db)
}
