;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Прописка статусов никам ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
alias propiska {
  if $dialog(propiska) = $null { dialog -m propiska propiska }
}
dialog propiska {
  title "Прописывание на канал"
  size 430 280 248 113
  icon $mircdiricons\access.ico, 0
  box "Прописывание на канал", 1, 5 2 238 105
  text "Ник", 2, 20 25 80 16
  edit "Ник", 3, 65 23 120 20, autohs center
  text "Канал", 4, 20 55 80 16
  edit "Канал", 5, 65 53 120 20, autohs center
  text "Уровень", 6, 20 85 80 16
  edit "Уровень", 7, 65 83 120 20, autohs center
  button ок,100,193 25 45 17, ok
  button закрыть,101,193 55 45 17, ok
}
on *:dialog:propiska:init:*: {
  if %aop.nick != $null { did -o propiska 3 1 %aop.nick }
  if %aop.chan != $null { did -o propiska 5 1 %aop.chan }
  if %aop.level != $null { did -o propiska 7 1 %aop.level }
}
on *:dialog:propiska:sclick:100: {
  /set %aop.nick $did(propiska,3) | /set %aop.chan $did(propiska,5) | /set %aop.level $did(propiska,7) | /cs access %aop.chan add %aop.nick %aop.level | /halt 
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Изменение имени ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
alias fullnamefx {
  if $dialog(fullnamefx) = $null { dialog -m fullnamefx fullnamefx }
}
dialog fullnamefx {
  title "Изменение вашего имени"
  size 470 200 420 240
  option pixels
  icon $mircdirPics\nserv.ico, 0
  text "Здесь вы можете установить своё имя с графическими дополнениями"1, 10 10 300 25
  edit %fullname.edit,2, 60 80 200 20, autohs 
  check "Устанавливать при старте скрипта" 3, 10 50 300 20
  text "Ctrl + K - для смены цвета, далее выберите цифру 0-15. Для перекрытия цвета цифру не выбирайте." 4, 10 120 440 30
  text "Ctrl + U - для подчёркивания текста. Для перекрытия повторите комбинацию." 5, 10 150 440 30
  text "Ctrl + B - для перевода текста в жирный формат. Для перекрытия повторите комбинацию." 6, 10 165 440 30
  text "Ваше имя:" 7, 5 80 54 15
  button "ОК", 8, 60 210 300 26, flat ok
}
on *:dialog:fullnamefx:init:*: {
  if %fullname.st = on { did -c fullnamefx 3 }
}
on *:dialog:fullnamefx:sclick:8: {
  /fullname $did(2).text
  if ($did(fullnamefx,3).state = 1) { %fullname.st = on } | else { %fullname.st = off }
  /set %fullname.edit $did(2).text
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  WINAMP CONTROLLER  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
alias ampsaysong { 
  if (%winamp.saysong.format == $null) { 
    echo -a Ваше сообщение Winamp не введено! Для его настройки нажмите Ctrl+3.
    /halt
  }
  if ($chr(36) $+ WA_NOTRUNNING !isin $ampget(STATE)) { goto ok }
  /halt
  :ok
  set %winamp.channelmodec $dll(libraries\nlinkn.dll,channel,0) 
  set %winamp.channelmode Моно
  if %winamp.channelmodec == 1 { /set %winamp.ChannelMode Моно | goto next }
  if %winamp.channelmodec == 2 { /set %winamp.ChannelMode Стерео | goto next }
  if %winamp.channelmodec == 3 { /set %winamp.ChannelMode Дуал Моно | goto next }
  if %winamp.channelmodec == 4 { /set %winamp.ChannelMode Дуал Стерео | goto next }
  set %winamp.channelmode Стерео 
  :next
  var %intmin $int($calc($ampget(POSSEC)/60))
  var %intsec $int($calc($calc($ampget(POSSEC)) - (%intmin * 60)))
  if %intmin < 10 { set %intmin 0 $+ %intmin }
  if %intsec < 10 { set %intsec 0 $+ %intsec }
  set %winamp.current %intmin $+ : $+ %intsec
  set %winamp.title $ampgettitle 
  set %winamp.genre $iif($ampget(GENRE),$ampget(GENRE),НеиЗвестНый сТилЬ)  
  set %winamp.year $iif($ampget(YEAR),$ampget(YEAR),$asctime(yyyy))  
  set %winamp.file $iif($ampget(TRACKFILENAME),$ampget(TRACKFILENAME),unknown - untitled.mp3)  
  set %winamp.album $iif($ampget(ALBUM),$ampget(ALBUM),Best Hits)
  var %intmin $int($calc($ampget(TRACKSEC)/60))
  var %intsec $int($calc($calc($ampget(TRACKSEC)) - (%intmin * 60)))
  if %intmin < 10 { set %intmin 0 $+ %intmin }
  if %intsec < 10 { set %intsec 0 $+ %intsec }
  set %winamp.length %intmin $+ : $+ %intsec
  set %winamp.bitrate $iif($ampget(BITRATE),$ampget(BITRATE),41)
  set %winamp.samplerate $iif($ampget(SAMPLERATE),$ampget(SAMPLERATE),360)   
  if ($chr(45) isin %winamp.Length) { %winamp.Length = 00:00 } 
  if ($1- == -e) { /echo %skins.prefix $me $winampreplaced | halt }
  if ($status == disconnected) { /notconnected | /halt }
  if (%winamp.msgtype == me) { /me $winampreplaced  }
  if (%winamp.msgtype == say) { /say $winampreplaced  }
  if (%winamp.msgtype == ame) { /ame $winampreplaced  }
  if (%winamp.msgtype == amsg) { /amsg $winampreplaced  }
  if (%winamp.msgtype == echo) { /echo $winampreplaced  }
} 
alias winampreplaced {
  return $replace(%winamp.saysong.format,<NAZV>,%winamp.title,<RAZM>,%winamp.length,<GOD>,%winamp.year,<ZHANR>,%winamp.genre,<FAIL>,$nopath(%winamp.file),<ALBOM>,%winamp.album,<SEJC>,%winamp.current,<BITR>,%winamp.bitrate,<GERC>,%winamp.samplerate,<KANAL>,%winamp.channelmode)
}
alias winampcontrol {
  if $dialog(winampcontrol) = $null { dialog -m winampcontrol winampcontrol }
}
dialog winampcontrol {
  icon icons/winamp.ico
  title "Настройка Winamp"
  size -1 -1 430 260
  box "" ,451, 5 158 365 45
  box "Управление" ,652, 5 205 420 47
  box "" ,653, 375 98 52 107
  box "Формат сообщения названия песни" ,651, 5 10 420 90
  radio "/say", 601, 380 125 40 20, group
  radio "/me", 602, 380 185 40 20
  radio "/amsg", 603, 380 105 50 20
  radio "/ame", 604, 380 165 100 20
  radio "/echo", 605, 380 145 100 20
  edit "Винамп не включен", 502, 7 222 180 23, autohs
  edit %winamp.saysong.format ,500, 15 50 400 20, autohs
  button "Теги по винампу...", 501, 15 25 400 21
  button "" 999, 15 75 400 22, size drop
  check "Отображать сообщения состояния Winamp" 997, 10 140 250 25
  button "Еще стили..." 990, 15 110 350 25
  button "Винамп" 991, 95 170 80 30
  button "Авай" 993, 195 170 80 30
  button "Скрипта" 994, 285 170 80 30
  button "« Prev" 995, 195 220 50 26
  button "Stop" 996, 255 220 50 26
  button "Play" 499, 305 220 50 26
  button "Next »" 998, 365 220 50 26
  text "Стили для:" 127, 15 170 80 30
}
on *:dialog:winampcontrol:init:*: {
  if (%view.winmsg) did -c winampcontrol 997
  /did -m winampcontrol 502 502
  /tip 601 При сообщении песни на канал или в приват будет использоваться обыкновенное сообщение.
  /tip 602 При сообщении песни на канал или в приват будет использоваться действие.
  /tip 603 При сообщении песни на канал или в приват будет использоваться обыкновенное сообщение во всех окнах.
  /tip 604 При сообщении песни на канал или в приват будет использоваться действие во всех окнах.
  /tip 605 При сообщении песни,будет показоватся только для себя.
  /tip 500 Формат сообщения названия песни.
  /tip 502 Сейчас играет:$ampgettitle
  dll libraries\mdx.dll MarkDialog winampcontrol
  did -ra winampcontrol 502 $ampgettitle
  if %winamp.msgtype = say { did -c winampcontrol 601 } 
  if %winamp.msgtype = me { did -c winampcontrol 602 } 
  if %winamp.msgtype = amsg { did -c winampcontrol 603 } 
  if %winamp.msgtype = ame { did -c winampcontrol 604 }
  if %winamp.msgtype = echo { did -c winampcontrol 605 } 
  dll libraries\mdx.dll SetControlMDX winampcontrol 999 window > libraries\dialog.mdx  
  dll libraries\mdx.dll SetFont winampcontrol 500 0 Comic Sans ms 
  dll libraries\mdx.dll SetColor winampcontrol 500 text $rgb(50,50,50) 
  window -h @wp
  did -a winampcontrol 999 grab $window(@wp).hwnd @wp
  clear @wp
  aline @wp $me $replace($did(500).text,4Я калбасюсь под 9||| 2,11,2\12,2\1\12\2,12\\0 <NAZV> 2//12,2/1,2/12/1/ 9||| 4bip's Script,$ampgettitle,<RAZM>,%winamp.Length,<GOD>,%winamp.year,<ZHANR>,%winamp.genre,<FAIL>,$nopath(%winamp.file),<ALBOM>,%winamp.album,<SEJC>,%winamp.Current,<BITR>,%winamp.BitRate,<GERC>,%winamp.SampleRate,<KANAL>,%winamp.ChannelMode)
}
on *:dialog:winampcontrol:sclick:499: { winampplay | did -ra winampcontrol 502 $ampgettitle }
on *:dialog:winampcontrol:sclick:996: { winampstop | did -ra winampcontrol 502 $ampgettitle }
on *:dialog:winampcontrol:sclick:998: { ampnext | did -ra winampcontrol 502 $ampgettitle }
on *:dialog:winampcontrol:sclick:995: { ampprev | did -ra winampcontrol 502 $ampgettitle }
on *:dialog:winampcontrol:sclick:501: { if !$dialog(winamptaghelp) { dialog -m winamptaghelp winamptaghelp } }
on *:dialog:winampcontrol:sclick:601: { /set %winamp.msgtype say }
on *:dialog:winampcontrol:sclick:602: { /set %winamp.msgtype me }
on *:dialog:winampcontrol:sclick:994: { /sex | dialog -c winampcontrol }
on *:dialog:winampcontrol:sclick:993: { /sexaway | dialog -c winampcontrol }
on *:dialog:winampcontrol:sclick:991: { /sexwin | dialog -c winampcontrol }
on *:dialog:winampcontrol:sclick:603: { /set %winamp.msgtype amsg }
on *:dialog:winampcontrol:sclick:604: { /set %winamp.msgtype ame }
on *:dialog:winampcontrol:sclick:605: { /set %winamp.msgtype echo }
on *:dialog:winampcontrol:sclick:992: { /set %winamp.saysong.format 13,14¦0<nazv> 13,14| 14,13¦0 14[0<bitr>Kb14/0s14]014,13±0<gerc>K7H0z 14,13| 13,14¦0DIlna7^13,140<razm>13,1414,13|13,140УжЕ7^013,140 <sejc>14,13¦ 14,13¦0 <albom> 14,13|13,14 14,13¦13,140 ГоD: <god> 14,13| }
on *:dialog:winampcontrol:sclick:602: { if !$dialog(winamptaghelp) { dialog -m winamptaghelp winamptaghelp } }
on *:dialog:winampcontrol:sclick:990: { /run http://www.mirc-love.com/index.php?name=Files&op=cat&id=2 } 
on *:dialog:winampcontrol:sclick:998: { /sexwin | dialog -c winampcontrol }    
on *:dialog:winampcontrol:edit,sclick:*:{
  $iif($did(winampcontrol,997).state,%view.winmsg = 1,set %view.winmsg 0)
}
on *:dialog:winampcontrol:sclick:998: {
  if ($did(winampcontrol,950).state = 1) { %win = on } | else { %win = off }
  /set %winamptitle $did(998).text
  did -c winampcontrol 998
}
on *:dialog:winampcontrol:sclick:10: {
  ampprev
  /did -ra winampcontrol 1 $ampgettitle
}

on *:dialog:winampcontrol:sclick:20: {
  $ampset(STOP)
  winstop
}

on *:dialog:winampcontrol:sclick:30: {
  $ampset(PLAY)
  winplay
}

on *:dialog:winampcontrol:sclick:40: {
  $ampset(PAUSE)
}

on *:dialog:winampcontrol:sclick:50: {
  /ampnext
  /did -ra winampcontrol 1 $ampgettitle
  ampnext
}
dialog winamptaghelp {
  title "Помощь по тегам"
  size -1 -1 220 205
  text "<NAZV>", 1, 5 5 60 20
  text "<RAZM>", 2, 5 25 60 20
  text "<GERC>", 3, 5 45 60 20
  text "<BITR>", 4, 5 65 60 20
  text "<KANAL>", 9, 5 85 60 20
  text "<SEJC>", 20, 5 105 60 20
  text "<ZHANR>", 23, 5 125 60 20
  text "<GOD>", 24, 5 145 60 20
  text "<FAIL>", 25, 5 165 60 20
  text "<ALBOM>", 26, 5 185 60 20
  text "- Название песни", 5, 65 5 160 20
  text "- Длина песни", 6, 65 25 160 20
  text "- Частота в кГерцах", 7, 65 45 160 20
  text "- Качество звука в битах", 8, 65 65 160 20
  text "- Каналы песни", 10, 65 85 160 20
  text "- Текущая позиция", 21, 65 105 160 20
  text "- Жанр", 27, 65 125 160 20
  text "- Год исполнения", 28, 65 145 160 20
  text "- Имя файла", 29, 65 165 160 20
  text "- Название альбома", 30, 65 185 160 20
}
dialog winbuttonhelp {
  title "Клавиши управления"
  size -1 -1 220 135
  text "F3", 1, 5 5 60 20
  text "F4", 2, 5 25 60 20
  text "Ctrl+F1", 3, 5 45 60 20
  text "Ctrl+F2", 4, 5 65 60 20
  text "Shift+F5", 9, 5 85 60 20
  text "Shift+F6", 20, 5 105 60 20
  text "- Предыдущий трек", 5, 65 5 160 20
  text "- Следующий трек", 6, 65 25 160 20
  text "- Перемотка на 5 сек назад", 7, 65 45 160 20
  text "- Перемотка на 5 сек вперёд", 8, 65 65 160 20
  text "- Воспроизведение/Пауза", 10, 65 85 160 20
  text "- Стоп", 21, 65 105 160 20
}
on *:dialog:winampcontrol:close:*: {
  /set %winamp.saysong.format $did(500)
  if ($chr(36) $+ WA_NOTRUNNING !isin $ampget(STATE)) {
    /echo %skinpref Формат сообщения песни:
    /ampsaysong -e
  }
}
alias winampplaystartup {
  if ($chr(36) $+ WA_NOTRUNNING isin $ampget(STATE)) { 
    /dll libraries\wa_link.dll WA_Link_Command START
    if (%winamp.startup.play == on) { $ampset(PLAY) | $ampset(HIDE) }
  }
}
alias ampprev {
  $ampset(START)
  if (%icons != Стандартные ) { toolbar -p play " $+ sys\icons\ $+ %icons $+ \pause.ico $+ " }
  if ($chr(36) $+ WA_NOTRUNNING !isin $ampget(STATE)) {
    $ampset(PREV)
    $ampset(PLAY)
    if (%view.winmsg == 1) {
      /ppop WinAmp Предвидущий трек : $ampgettitle 
    }
  } 
}
alias ampplaypause {
  $ampset(START)
  if ($chr(36) $+ WA_NOTRUNNING !isin $ampget(STATE)) {
    if ($ampget(STATE) == $chr(36) $+ WA_mirc) { $active(#mirc-love) | halt }
    if ($ampget(STATE) == $chr(36) $+ WA_PLAYING) { $ampset(PAUSE) | halt }
    if ($ampget(STATE) == $chr(36) $+ WA_PAUSED) { $ampset(PLAY) | halt }
    if ($ampget(STATE) == $chr(36) $+ WA_STOPPED) { $ampset(PLAY) | halt }
    /ppop WinAmp Пригрование винампа приостановленно....
  }
}
alias ampnext {
  $ampset(START)
  if (%icons != Стандартные ) { toolbar -p play " $+ sys\icons\ $+ %icons $+ \pause.ico $+ " }
  if ($chr(36) $+ WA_NOTRUNNING !isin $ampget(STATE)) {
    $ampset(NEXT)
    $ampset(PLAY)
    if (%view.winmsg == 1) {
      var %intmin $int($calc($ampget(TRACKSEC)/60))
      var %intsec $int($calc($calc($ampget(TRACKSEC)) - (%intmin * 60)))
      if %intmin < 10 { set %intmin 0 $+ %intmin }
      if %intsec < 10 { set %intsec 0 $+ %intsec }
      set %winamp.length %intmin $+ : $+ %intsec
      /ppop WinAmp Следуйщий трек: $ampgettitle 
    } 
  } 
}
alias -1 {
}
alias -2 {
}
alias ampget {
  return $dll(libraries\wa_link.dll,WA_Link_Raw_Stats,$1-)
}
alias ampset {
  return $dll(libraries\wa_link.dll,WA_Link_Command,$1-)
}
alias ampseekb {
  if ($chr(36) $+ WA_NOTRUNNING !isin $ampget(STATE)) {
    $ampset(REW5) 
    if ($swamp(WinAmpGet, STATE) == PLAYING) {
      var %intmin $int($calc($ampget(POSSEC)/60))
      var %intsec $int($calc($calc($ampget(POSSEC)) - (%intmin * 60)))
      if %intmin < 10 { set %intmin 0 $+ %intmin }
      if %intsec < 10 { set %intsec 0 $+ %intsec }
      set %winamp.current %intmin $+ : $+ %intsec
      var %intmin $int($calc($ampget(TRACKSEC)/60))
      var %intsec $int($calc($calc($ampget(TRACKSEC)) - (%intmin * 60)))
      if %intmin < 10 { set %intmin 0 $+ %intmin }
      if %intsec < 10 { set %intsec 0 $+ %intsec }
      set %winamp.length %intmin $+ : $+ %intsec
      var %tek.pozb Тек. позиция: %winamp.current $+ / $+ %winamp.length %skinpref
    }
    if (%view.winmsg == 1) { /echo -a %skinpref Winamp: Перемотка на 5 секунд назад %skinpref %tek.pozb }
  }
}
alias ampseekf { 
  if ($chr(36) $+ WA_NOTRUNNING !isin $ampget(STATE)) {
    $ampset(FFW5)
    if ($swamp(WinAmpGet, STATE) == PLAYING) {
      var %intmin $int($calc($ampget(POSSEC)/60))
      var %intsec $int($calc($calc($ampget(POSSEC)) - (%intmin * 60)))
      if %intmin < 10 { set %intmin 0 $+ %intmin }
      if %intsec < 10 { set %intsec 0 $+ %intsec }
      set %winamp.current %intmin $+ : $+ %intsec
      var %intmin $int($calc($ampget(TRACKSEC)/60))
      var %intsec $int($calc($calc($ampget(TRACKSEC)) - (%intmin * 60)))
      if %intmin < 10 { set %intmin 0 $+ %intmin }
      if %intsec < 10 { set %intsec 0 $+ %intsec }
      set %winamp.length %intmin $+ : $+ %intsec
      var %tek.pozf Тек. позиция: %winamp.current $+ / $+ %winamp.length %skinpref
    }
    if (%view.winmsg == 1) { /echo -a %skinpref Winamp: Перемотка на 5 секунд вперёд %skinpref %tek.pozf }
  }
}
alias playtrack {
  if ($walink(WA_Link_Raw_Stats,STATE) == $!WA_NOTRUNNING) { walink WA_Link_Command START }
  if ($swamp(WinAmpGet,RUNNING)) {
    if ($swamp(WinAmpGet, STATE) == PLAYING) {
      swamp WinAmpCmd PAUSE | if (%view.winmsg == 1) { ppop Воспризведение приостановлено }
      if (%icons != Стандартные ) { toolbar -p play " $+ sys\icons\ $+ %icons $+ \play.ico $+ " }
    }
    elseif ($swamp(WinAmpGet, STATE) == PAUSED) {
      swamp WinAmpCmd PLAY | if (%view.winmsg == 1) { ppop Воспроизведение, Текущий трек: $ampgettitle }
      if (%icons != Стандартные ) { toolbar -p play " $+ sys\icons\ $+ %icons $+ \pause.ico $+ " }
    }
    else {
      var %intmin $int($calc($ampget(POSSEC)/60))
      swamp WinAmpCmd PLAY | if (%view.winmsg == 1) { ppop Винамп включен..: $ampgettitle }
      if (%icons != Стандартные ) { toolbar -p play " $+ sys\icons\ $+ %icons $+ \pause.ico $+ " }
    }
  }
  elseif ($swamp(WinAmpGet, INSTALLED) == $false) {
    echo 4 -a Winamp не установлен. Скачать можно тут: www.winamp.com
  }
}
alias ampopen {
  if ($chr(36) $+ WA_NOTRUNNING !isin $ampget(STATE)) {
    /showmirc -m
    $ampset(HIDE) $ampset(RESTORE) $ampset(OPEN)
    /showmirc -xsp
  }
}
alias ampgettitle {
  if $ampget(STATE) == $chr(36) $+ WA_NOTRUNNING { return Винамп не включен | /halt }  
  if $ampget(STATE) != $chr(36) $+ WA_PLAYING { return Винамп не включен | /halt }  
  return $dll(libraries\winamptomirc.dll,GetTitle,_)
}
alias ampgettime {
  var %intmin $int($calc($ampget(TRACKSEC)/60))
  var %intsec $int($calc($calc($ampget(TRACKSEC)) - (%intmin * 60)))
  if %intmin < 10 { set %intmin 0 $+ %intmin }
  if %intsec < 10 { set %intsec 0 $+ %intsec }
  var %rettime %intmin $+ : $+ %intsec
  if (*-* iswm %rettime) { var %rettime 00:00 }
  return %rettime
}
alias swamp {
  if ($isid) return $dll(libraries\swamp.dll,$1,$2-)
  else dll libraries\swamp.dll $1-
}
alias walink {
  if ($isid) return $dll(sys\walink.dll,$1,$2-)
  else dll sys\walink.dll $1-
}
alias ampget {
  return $dll(sys\walink.dll,WA_Link_Raw_Stats,$1-)
}
alias winamptitle {
  if $dialog(winamptitle) = $null { dialog -m winamptitle winamptitle }
}
dialog winamptitle {
  icon icons/winamp.ico
  title "Настройка Winamp"
  size -1 -1 430 32
  button "сказать" ,12, 365 3 60 26, 
  edit $ampgettitle ,10, 5 3 350 26, 
}
on *:dialog:winamptitle:sclick:12: { /ampsaysong }   
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; AWAY Система ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dialog awaywarn {
  icon $mircdiricons\away.ico, 0
  title "Вы в авай"
  option dbu
  size 80 95 80 38
  box "",9, 1 0 78 22
  button "Вернуться",10, 1 24 78 12, cancel
  button "Hide",12, 100 100 5 5, ok
  text "В данный момент Вы находитесь в режиме AWAY",11, 3 5 74 16, center
}
on *:dialog:awaywarn:sclick:10:{ /goneaway }
on *:dialog:awaywarn:init:0:{ 
  mdx MarkDialog $dname $dialog($dname).hwnd
  mdx SetDialog $dname style 0 title
  mdx MarkDialog $dname
}
alias awayer {
  if (!%awayprefix) { set %awayprefix ^away }
  if (!%awaymsgrepittime) { set %awaymsgrepittime 30 }
  if (!%awayautotime) { set %awayautotime 30 }
  if (!%awaynickchangemode) { set %awaynickchangemode pref }
  if (!%awaygonemsgmode) { set %awaygonemsgmode ones }
  if (!%awayautoreson) { set %awayautoreson Долгое отсутствие }
  if $dialog(awayer) = $null { dialog -m awayer awayer }
}
dialog awayer {
  icon $mircdiricons\away.ico, 0
  title "Away система"
  size -1 -1 253 220
  option dbu
  text "Причины отсутствия:", 2, 5 6 55 8
  combo 3, 5 15 140 50, size
  button "Добавить", 4, 5 65 69 10, flat
  button "Удалить", 5, 76 65 69 10, flat
  check "В режиме Away менять ник", 6, 153 14 80 10
  box "Смена ника", 1, 148 6 100 69
  text "или ставить приставку к нику", 8, 163 23 83 8
  radio "Приставка к нику", 9, 163 33 69 10, disable group
  radio "Менять ник", 10, 163 53 50 10, disable
  button "Установить по умолчанию" 998, 140 184 80 10
  button "Ок", 11, 2 206 249 10, flat ok
  text "YourNick", 12, 173 45 22 8, disable
  edit %awayprefix, 13, 196 43 50 10, disable autohs
  edit %awaynick, 14, 173 63 73 10, disable autohs
  box "Опции", 7, 5 76 140 49
  check "Сообщать о режиме Away", 15, 10 83 78 10
  check "Сообщать когда вернулся", 16, 10 112 80 10
  radio "Один раз в момент включения", 17, 18 92 89 10, disable group
  radio "Каждые", 18, 18 102 32 10, disable
  box "Авто Away", 19, 148 76 100 49
  check "Включать режим Away", 20, 153 83 71 10
  text "после", 21, 153 95 17 8
  edit %awayautotime, 22, 170 93 14 10, disable autohs limit 2 center
  text "минут простоя", 23, 186 95 40 8
  text "Причина", 24, 153 105 25 8, disable
  edit %awayautoreson, 25, 153 113 93 10, disable autohs
  box "Away система", 26, 2 0 249 202
  edit %awaymsgrepittime, 27, 51 102 14 10, disable center
  text "минут", 28, 67 104 25 8, disable
  box "Оформление away", 29, 5 126 243 72
  edit %awaydisign1, 30, 7 134 189 10, limit 150 autohs
  edit %awaydisign2, 31, 197 134 49 10, limit 150 autohs
  button "", 40, 0 0 0 0, cancel
  edit %awaydisignr1, 32, 7 170 189 10, limit 150 autohs
  edit %awaydisignr2, 33, 197 170 49 10, limit 150 autohs
  text "! ! ! П Р Е Д П Р О С М О Т Р ! ! !", 34, 7 153 238 8, disable center
  box "", 44, 105 76 40 49
  check "", 36, 123 88 6 10, disable
  text "Сообщать на все сервера", 37, 109 100 34 14, center
}
;=============================
on *:dialog:awayer:init:0:{
  awayONwindow2 
  refreshawayTEXT2
  did -b awayer 4,5
  readawayreasons
  if (%awaynickchange) { 
    did -c awayer 6
    if (%awaynickchangemode == pref) { did -e awayer 9,10,11,12,13 }
    else { did -e awayer 9,10,11,12,14 } 
  }
  if (%awaynickchangemode == pref) { did -c awayer 9 | did -b awayer 14 } 
  if (%awaynickchangemode == nick) { did -c awayer 10 | did -b awayer 13 }
  if (%awaygonemsg) { did -c awayer 15 | did -e awayer 17,18,27,28,36,37 } 
  if (%awaygonemsgmode == ones) { did -c awayer 17 | did -b awayer 27 } 
  if (%awaygonemsgmode == mult) { did -c awayer 18 }
  if (%awaybackmsg) { did -c awayer 16 } 
  if (%awayautomod) { did -c awayer 20 } 
  if (%awayautomod) { did -e awayer 22,24,25 }
  if (%awaymultiserv) { did -c $dname 36 } 
}
;=============================
on *:dialog:awayer:sclick:*:{
  if ($did == 11) {
    if ($did($dname,13)) { set %awayprefix $did(13) }
    if ($did($dname,14)) { set %awaynick $did(14) }
    if ($did($dname,27)) { set %awaymsgrepittime $did(27) }
    if ($did($dname,22)) { set %awayautotime $did(22) }
    if ($did($dname,25)) { set %awayautoreson $did(25) }
    set %awaydisign1 $did(30)
    set %awaydisign2 $did(31)
    set %awaydisignr1 $did(32)
    set %awaydisignr2 $did(33)
    awaywindowOFF
  }
  if ($did == 3) { did -e awayer 5 | did -b awayer 4 }
  if (($did == 199) || ($did == 40)) { awaywindowOFF }
  if ($did == 4) {
    write $shortfn($mircdir) $+ sys\txt\AwayReasons.txt $did(3) 
    did -r awayer 3 
    readawayreasons 
    did -b awayer 4,5 
  }
  if ($did == 5) {
    write -dw" $+ $did(3) $+ " $shortfn($mircdir) $+ sys\txt\AwayReasons.txt | did -r awayer 3 | readawayreasons | did -b awayer 4,5
  }
  if ($did(6).state == 1) { 
    set %awaynickchange on
    if (%awaynickchangemode == pref) { did -e awayer 13,12 | did -b awayer 14 } 
    if (%awaynickchangemode == nick) { did -e awayer 14 | did -b awayer 13,12 } 
    did -e awayer 9,10
  }
  else { 
    unset %awaynickchange
    did -b awayer 9,10,12,13,14
  } 
  if ($did == 9) {
    set %awaynickchangemode pref
    did -e awayer 13,12 | did -b awayer 14
  }
  if ($did == 10) {
    set %awaynickchangemode nick
    did -e awayer 14 | did -b awayer 13,12
  }
  if ($did(15).state == 1) { 
    set %awaygonemsg on
    did -e awayer 17,18,28,36,37
    if (%awaygonemsgmode == mult) { did -e awayer 27 } 
  }
  else { 
    unset %awaygonemsg
    did -b awayer 17,18,27,28,36,37 
  }
  if ($did(36).state == 1) { 
    set %awaymultiserv on
  }
  else { 
    unset %awaymultiserv on
  }
  if ($did == 17) { 
    set %awaygonemsgmode ones
    did -b awayer 27 
  }
  if ($did == 998) {
    /sexaway
    /dialog -c awayer
  }
  if ($did == 18) {
    set %awaygonemsgmode mult
    did -e awayer 27 
  }
  if ($did(16).state == 1) { set %awaybackmsg on } 
  else { unset %awaybackmsg } 
  if ($did(20).state == 1) { 
    set %awayautomod on
    did -e awayer 22,24,25
    if ($server != $null) { .timerautoaway 0 5 autoawaycheck } 
  }
  else { unset %awayautomod | did -b awayer 22,24,25 | .timerautoaway* off }
}
;=============================
on *:dialog:awayer:edit:3:{
  did -e awayer 4
  did -b awayer 5
  refreshawayTEXT2
}
on *:dialog:awayer:dclick:3:{
  refreshawayTEXT2
}
on *:dialog:awayer:edit:*:{
  refreshawayTEXT2
}
;*/Away система/*
alias awayReasons { return $read -l $+ $1 $mircdirsys\txt\AwayReasons.txt }
alias readawayreasons { 
  var %awayresonind = $lines($mircdirsys\txt\AwayReasons.txt) + 1 
  :next 
  dec %awayresonind 1 
  if (%awayresonind <= 0) { return } 
  if ($read -l $+ %awayresonind $mircdirsys\txt\AwayReasons.txt == $null) { goto next } 
  else { did -i awayer 3 1 $read -l $+ %awayresonind $mircdirsys\txt\AwayReasons.txt 
  goto next } 
}
alias goneaway {
  if ($away == $false) && ($server) {
    if (!%awaymultiserv) {
      if (%awaynickchange == on) { set %currentnick $me | if (%awaynickchangemode == pref) { nick $me $+ %awayprefix | set %nocurrentnick $me $+ %awayprefix } | if (%awaynickchangemode == nick) { nick %awaynick | set %nocurrentnick %awaynick } }
      if (%awaygonemsg == on) { 
        if (%itsautoaway == yes) { 
          unset %itsautoaway 
          if (%awaygonemsgmode == ones) { 
            ame %awaydisign1 $+ $1- $+ $+ %awaydisign2
          }
          if (%awaygonemsgmode == mult) { 
            ame %awaydisign1 $+ $1- $+ $+ %awaydisign2
            .timerawaymsg 0 $calc(%awaymsgrepittime * 60) awaymsgrep $1- | timerautoaway off
          }
        }
        else {
          if (%awaygonemsgmode == ones) {
            ame %awaydisign1 $+ $1- $+ $+ %awaydisign2
          }
          if (%awaygonemsgmode == mult) {
            ame %awaydisign1 $+ $1- $+ $+ %awaydisign2
            .timerawaymsg 0 $calc(%awaymsgrepittime * 60) awaymsgrep $1- 
          }
        }
      }
      set %since $ctime | .away $1- | if (!$dialog(awaywarn)) { dialog -mn awaywarn awaywarn }
    }
    if (%awaymultiserv) {
      if (%awaynickchange == on) { 
        set %currentnick $me 
        if (%awaynickchangemode == pref) { 
          /scid -a nick $me $+ %awayprefix 
          set %nocurrentnick $me $+ %awayprefix 
        } 
        if (%awaynickchangemode == nick) { 
          /scid -a nick %awaynick 
          set %nocurrentnick %awaynick 
        } 
      }
      if (%awaygonemsg == on) { 
        if (%itsautoaway == yes) { 
          unset %itsautoaway 
          if (%awaygonemsgmode == ones) { 
            /scid -a ame %awaydisign1 $+ $1- $+  $+ %awaydisign2
          }
          if (%awaygonemsgmode == mult) { 
            /scid -a ame %awaydisign1 $+ $1- $+  $+ %awaydisign2
            .timerawaymsg 0 $calc(%awaymsgrepittime * 60) /scid -a awaymsgrep $1- | timerautoaway off
          }
        }
        else {
          if (%awaygonemsgmode == ones) {
            /scid -a ame %awaydisign1 $+ $1- $+  $+ %awaydisign2
          }
          if (%awaygonemsgmode == mult) {
            /scid -a ame %awaydisign1 $+ $1- $+  $+ %awaydisign2
            .timerawaymsg 0 $calc(%awaymsgrepittime * 60) /scid -a awaymsgrep $1- 
          }
        }
      }
      set %since $ctime | /scid -a .away $1- | if (!$dialog(awaywarn)) { dialog -mn awaywarn awaywarn }
    }
  }
  else {
    if (!%awaymultiserv) {
      .timerawaymsg off | .timerautoaway off
      if (%awaybackmsg == on) { 
        ame %awaydisignr1 $duration($calc($ctime - %since)) $+ %awaydisignr2
        unset %since
      }
      if (%awaynickchange == on) { nick %currentnick | unset %currentnick | unset %nocurrentnick } | unset %since | .away | if (%awayautomod == on) { .timerautoawayRE 1 $calc(%awayautotime * 60) .timerautoaway 0 5 autoawaycheck }
    }
    if (%awaymultiserv) {
      .timerawaymsg off | .timerautoaway off
      if (%awaybackmsg == on) { 
        /scid -a ame %awaydisignr1 $duration($calc($ctime - %since)) $+ %awaydisignr2
        unset %since
      }
      if (%awaynickchange == on) { /scid -a nick %currentnick | unset %currentnick | unset %nocurrentnick } | unset %since | /scid -a .away | if (%awayautomod == on) { .timerautoawayRE 1 $calc(%awayautotime * 60) .timerautoaway 0 5 autoawaycheck }
    }
    dialog -x awaywarn awaywarn
  }
}
alias awaymsgrep {
  ame %awaydisign1 $+ $1- $+  $+ %awaydisign2
}
alias autoawaycheck { if ($away == $false) { if ($idle >= $calc(%awayautotime * 60)) { set %itsautoaway yes | goneaway %awayautoreson } } }
alias awayONwindow2 {
  window -c @awayTEXTwindow
  window -hkdo +dL @awayTEXTwindow $calc($dialog(awayer).x + 18) $calc($dialog(awayer).y + 323) 476 40
  window -a @awayTEXTwindow
  .timerawayTEXTwindowposition -mo 0 250 awayrefreshposition2 
}
alias refreshawayTEXT2 {
  clear @awayTEXTwindow
  if (!$did($dname,3)) { echo @awayTEXTwindow $timestamp $me $did(awayer,30).text Причина эвэй $+ $did(awayer,31).text }
  else { echo @awayTEXTwindow $timestamp $me $did(awayer,30).text  $+ $did($dname,3) $+  $+ $did(awayer,31).text }
  echo @awayTEXTwindow $timestamp $me $did(awayer,32).text 1secs $did(awayer,33).text
}
alias awayrefreshposition2 {  window $iif($dialog(awayer).active,-o,-u) @awayTEXTwindow $calc($dialog(awayer).x + 18) $calc($dialog(awayer).y + 323) 476 40 }
alias awaywindowOFF { window -c @awayTEXTwindow | .timerawayTEXTwindowposition off }
alias menuwindowOFF { window -c @menuwindow | .timermenuwindowposition off }
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MEMOSERV;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
alias  memoservcenter { 
  if $dialog(memoservcenter) = $null { dialog -m memoservcenter memoservcenter }
}
dialog memoservcenter {
  title "                     Сервис MemoServ "
  option dbu
  size -1 -1 230 215
  icon 55, 180 149 29 26 , pics\mail.bmp
  box "Читать сообщения",21, 5 2 220 124
  edit "" 22, 10 50 155 72, multi, vsbar, read, sort
  button "Список Memo",23, 170 62 49 11, flat
  button "Читать Memo",24, 170 86 49 11, flat
  button "Очистить окно",25, 170 74 49 11, flat
  button "Удалить письмо",26, 170 98 49 11, flat
  button "Удалить все",28, 170 110 49 11, flat
  box "Отправить сообщение",30, 5 128 220 82
  radio "Для ника", 32, 30 136 36 8, tab1 , group flat
  edit "",31, 67 135 53 10, autohs
  radio "Для канала", 199, 125 136 40 8, flat
  edit "#",200, 167 135 53 10, autohs
  radio "Для ника", 201, 50 36 36 8, tab1 , group flat
  radio "Для канала", 203, 90 36 40 8, flat
  combo 204, 135 35 53 60, drop, edit, autohs
  icon 205, 20 33 25 24 , pics\memox.ico
  text "Текст:",37, 10 136 20 8
  edit "",38, 10 148 155 45, multi, autovs, vsbar
  button "Отправить Memo",39, 170 179 49 12, flat
  edit "",47, 10 195 155 11, read, autovs, center
  text "Лимит записок:", 46, 10 10 60 10
  edit "", 48, 10 20  11 11
  list 49, 54 20 13 13, edit
  button "OK", 50, 24 20 27 11, flat
  text "Опция:", 40, 69 10 30 10
  combo 41, 69 20 28 45, drop
  text "Номер:", 42, 174 49 30 10
  edit "", 43, 198 48  15 11, autohs
  list 44, 131 20 12 12, edit
  button "Читать",45, 100 20 28 11, flat
  text "Уведомления о записках:", 51, 146 10 69 10
  combo 52, 146 20 28 45, drop
  list 53, 206 20 14 16, edit
  button "Ok",54, 177 20 26 11, flat
  button "Закрыть",10, 170 194 49 12, cancel, flat
}
on 1:dialog:memoservcenter:init:0:{ 
  mdx MarkDialog $dname $dialog($dname).hwnd
  mdx SetDialog $dname style 0 title
  mdx MarkDialog $dname
  mdx SetBorderStyle 44,49,53
  mdx SetControlMDX $dname 44,49,53 toolbar flat nodivider > libraries\bars.mdx
  mdx SetControlMDX $dname 44,49,53 statusbar > libraries\bars.mdx
  did -i $dname 44,49,53 1 bmpsize 16 16
  did -i $dname 44,49,53 1 setimage +nh icon small 22, $+ pics\phoenity.icl
  did -a $dname 44,49,53 +a 1 $chr(9) $+ Подсказка
  didtok $dname 41 32 NEW LAST
  did -c $dname 41 1
  didtok $dname 52 32 ON LOGON NEW OFF
  did -c $dname 52 1
  set %memosend.nick.chan 1
  set %memoread.nick.chan 1
  if (%memosend.nick.chan == 1) { did -c memoservcenter 32 | did -b memoservcenter 200 }
  if (%memosend.nick.chan == 2) { did -c memoservcenter 199 | did -b memoservcenter 31 }
  if (%memoread.nick.chan == 1) { did -c memoservcenter 201 | did -b memoservcenter 204 }
  if (%memoread.nick.chan == 2) { did -c memoservcenter 203 | did -b memoservcenter 202 }
  chanlistins 204 mychan.txt memoservcenter
}
on 1:dialog:memoservcenter:sclick:*:{
  if ($did == 32) { set %memosend.nick.chan 1 | did -b memoservcenter 200 | did -e memoservcenter 31 } 
  if ($did == 199) { set %memosend.nick.chan 2 | did -b memoservcenter 31 | did -e memoservcenter 200 | did -r memoservcenter 31 }
  if ($did == 201) { set %memoread.nick.chan 1 | did -b memoservcenter 204 } 
  if ($did == 203) { set %memoread.nick.chan 2 | did -e memoservcenter 204 }
  if ($did == 44) { memoserv.read.me.help }
  if ($did == 22) { did -e memoservcenter 24,26 } 
  if ($did == 23) { 
    if (%memoread.nick.chan == 1) {
    if ($server == $null) { scheck } | did -r $dname 22 | .enable #MemoList | %memo.identify list }
    if (%memoread.nick.chan == 2) {
      if ($left($did(204),1) == $chr(35)) {
      if ($server == $null) { scheck } | did -r $dname 22 | .enable #MemoList | %memo.identify list $did(204) }
    }
  }
  if ($did == 24) { 
    if (%memoread.nick.chan == 1) {
      if ($did(43)) {
        if ($server == $null) { scheck } | did -r $dname 22 | .enable #MemoRead | %memo.identify READ $did(43) 
      }
    }
    if (%memoread.nick.chan == 2) {
      if ($did(43) && $left($did(204),1) == $chr(35)) {
        if ($server == $null) { scheck } | did -r $dname 22 | .enable #MemoRead | %memo.identify READ $did(204) $did(43) 
      }
    }
  }
  if ($did == 25) { did -r memoservcenter 22 } 
  if ($did == 26) { 
    if (%memoread.nick.chan == 1) {
      if ($did(43)) {
        if ($server == $null) { scheck } | did -r $dname 22 | .enable #MemoRead | %memo.identify del $did(43) 
      }
    } 
    if (%memoread.nick.chan == 2) {
      if ($did(43) && $left($did(204),1) == $chr(35)) {
        if ($server == $null) { scheck } | did -r $dname 22 | .enable #MemoRead | %memo.identify del $did(204) $did(43) 
      } 
    }
  }
  if ($did == 28) { 
    if (%memoread.nick.chan == 1) {
      if ($server == $null) { scheck } | did -r $dname 22 | .enable #MemoRead | %memo.identify del all 
    }
    if (%memoread.nick.chan == 2) {
      if ($left($did(204),1) == $chr(35)) {
        if ($server == $null) { scheck } | did -r $dname 22 | .enable #MemoRead | %memo.identify del $did(204) all 
      }
    }
  }
  if ($did == 45) { if ($server == $null) { scheck } | did -r $dname 22 | .enable #MemoRead | %memo.identify READ $did(41) }
  if ($did == 39) {
    set %memomsglines $did(38).lines 
    set %memomsgind 1 
    %memomsg = $did(38,1)
    :next 
    inc %memomsgind 1 
    if (%memomsgind > %memomsglines) { goto sendmsg } 
    else { set %memomsg %memomsg $did(38,%memomsgind) | goto next }
    :sendmsg 
    if (%memosend.nick.chan == 1) { 
      if ($did(31) && $did(38)) {
        if ($server == $null) { scheck } | .enable #MemoSend | %memo.identify SEND $did(31) %memomsg | if (%gtzfails == on) { /dll libraries\game_tools.dll splay %failed } 
      }
    }
    if (%memosend.nick.chan == 2) {
      if ($did(38) && $left($did(200),1) == $chr(35)) { 
        if ($server == $null) { scheck } | .enable #MemoSend | %memo.identify SEND $did(200) %memomsg | if (%gtzfails == on) { /dll libraries\game_tools.dll splay %failed }
      } 
      unset %memomsglines 
      unset %memomsgind 
      halt 
    }
  }
  if ($did == 50) {
    if ($did(48)) {
      if ($server == $null) { scheck } | did -r $dname 22 | .enable #MemoRead | %memo.identify SET LIMIT $did(48)
    }
  }
  if ($did == 49) { memoserv.set.limit.my.help }
  if ($did == 53) && ($did(52).sel == 1) { set %memoserv.set.notify.mode 1 | memoserv.set.notify.help }
  if ($did == 53) && ($did(52).sel == 2) { set %memoserv.set.notify.mode 2 | memoserv.set.notify.help }
  if ($did == 53) && ($did(52).sel == 3) { set %memoserv.set.notify.mode 3 | memoserv.set.notify.help }
  if ($did == 53) && ($did(52).sel == 4) { set %memoserv.set.notify.mode 4 | memoserv.set.notify.help }
  if ($did == 54) { if ($server == $null) { scheck } | did -r $dname 22 | .enable #MemoRead | %memo.identify SET NOTIFY $did(52) }
  if ($did == 10) { .disable #Memo* } 
}
#MemoList off
on ^*:notice:*:*:{ if ($nick == memoserv) { did -i memoservcenter 22 1 $strip($1-) } .timer 1 1 .disable #MemoList }
#MemoList end
#MemoRead off
on ^*:notice:*:*:{ if ($nick == memoserv) { did -i memoservcenter 22 1 $strip($1-) } .timer 1 1 .disable #MemoRead }
#MemoRead end
#MemoSend off
on ^*:notice:*:*:{ if ($nick == memoserv) { did -i memoservcenter 47 1 $strip($1-) } .timer 1 1 .disable #MemoSend }
#MemoSend end
dialog newmemo {
  title " -=( Новое письмо )=- "
  option dbu
  size -1 -1 81 60
  text "",10, 5 6 70 8, center
  text "",11, 5 18 70 8, center
  button "Читать сейчас",12, 5 30 71 12, ok, flat
  button "Читать позже",13, 5 42 71 12, cancel, flat
  box "",14, 3 2 75 55
}
on *:dialog:newmemo:init:*:{
  mdx MarkDialog $dname $dialog($dname).hwnd
  mdx SetDialog $dname style 0 title
}
on 1:dialog:newmemo:sclick:12:{
  if ($dialog(memoservcenter) != memoservcenter) { dialog -m memoservcenter memoservcenter }
  if ($dialog(memoservcenter) == memoservcenter) { did -r memoservcenter 22 1 }
  else { did -c memoservcenter 1 }
  .did -t memoservcenter 23
  .enable #MemoList | %memo.identify list
  .enable #MemoRead | %memo.identify read 1
}
alias memoserv.set.notify.help dialog -m memoserv.set.notify.help memoserv.set.notify.help
dialog memoserv.set.notify.help {
  title " -=( Уведомление )=- "
  size -1 -1 145 53
  option dbu
  text "Вы будете уведомлены о записках когда подключитесь к серверу, при выходе из режима AWAY, и сразу же когда придет новая записка.", 1, 27 7 110 40, center
  text "Вы будете уведомлены о записках только когда подключитесь к серверу или при выходе из режима AWAY.", 2, 27 7 110 40, center
  text "Вы будете уведомлены о записке только в тот момент когда кто-то ее пошлет вам.", 3, 27 9 110 40, center
  text "Вы не будете уведомлены о новых записках.", 4, 27 10 110 40, center
  button "OK", 5, 55 36 43 10, ok, flat
  box "",6,2 0 141 51
  icon 7, 6 6 22 22, pics\memox.ico
}
on *:dialog:memoserv.set.notify.help:*:*: {
  if ($devent == init) {
    mdx MarkDialog $dname $dialog($dname).hwnd
    mdx SetDialog $dname style 0 title
    if (%memoserv.set.notify.mode == 1) { did -v $dname 1 | did -h $dname 2 | did -h $dname 3 | did -h $dname 4 }
    if (%memoserv.set.notify.mode == 2) { did -h $dname 1 | did -v $dname 2 | did -h $dname 3 | did -h $dname 4 }
    if (%memoserv.set.notify.mode == 3) { did -h $dname 1 | did -h $dname 2 | did -v $dname 3 | did -h $dname 4 }
    if (%memoserv.set.notify.mode == 4) { did -h $dname 1 | did -h $dname 2 | did -h $dname 3 | did -v $dname 4 }
  }
  if ($devent == sclick) {
    if ($did == 5) { s.cl }
  }
}
alias post.new.n {
  if (!$dialog(post.new.n)) dialog -ma post.new.n post.new.n
  else dialog -v post.new.n
}
dialog post.new.n {
  title " -=( Письмо )=- "
  size -1 -1 128 48
  option dbu
  text %post.new.n, 1, 33 7 57 8
  button "Прочитать", 2, 41 31 43 10, default, ok, flat
  icon 3, 6 6 22 22, pics\memox.ico
  box "",4,2 0 124 45
}
on *:dialog:post.new.n:init:*:{
  mdx MarkDialog $dname $dialog($dname).hwnd
  mdx SetDialog $dname style 0 title
}
on *:dialog:post.new.n:sclick:2: {
  unset %post.new.n
  set %new.post 1
  if ($dialog(memoservcenter) != memoservcenter) { dialog -m memoservcenter memoservcenter }
  else { did -c memoservcenter 1 }
  .did -t memoservcenter 23
  .enable #MemoList | %memo.identify list
  .enable #MemoRead | %memo.identify read 1
}
on *:dialog:post.new.n:close:*: unset %post.new.n
dialog memsenderr {
  title " -=( Письмо )=- "
  size -1 -1 150 41
  option dbu
  text "Пожалуйста, подождите 3 секунды перед тем как снова использовать команду SEND.", 1, 27 7 117 43, center
  button "OK", 2, 55 24 43 10, default, ok, flat
  icon 3, 6 6 22 22, pics\err.ico
  box "",13,2 0 146 39
}
on *:dialog:memsenderr:init:*:{
  mdx MarkDialog $dname $dialog($dname).hwnd
  mdx SetDialog $dname style 0 title
}
alias error { 
  if ($dialog(error) == error) { DialogError } | else { dialog -ma error error } 
}
alias memoserv.set.limit.my.help dialog -m memoserv.set.limit.my.help memoserv.set.limit.my.help
dialog memoserv.set.limit.my.help {
  title " -=( Помощь )=- "
  size -1 -1 162 54
  option dbu
  text "Устанавливает максимальное количество записок которые вы сможете принимать. Если вы установите ''0'', то никто не сможет послать вам записку. МАКСИМУМ записок - 20.",2,25 5 126 40,center 
  icon 4,7 7 16 16,pics\memox.ico,noborder
  button "Ok",1,62 36 43 10,ok, flat
  box "",6,2 0 158 52
}
on *:dialog:memoserv.set.limit.my.help:init:*:{
  mdx MarkDialog $dname $dialog($dname).hwnd
  mdx SetDialog $dname style 0 title
}
alias memoserv.read.me.help dialog -m memoserv.read.me.help memoserv.read.me.help
dialog memoserv.read.me.help {
  title " -=( Помощь )=- "
  size -1 -1 163 58
  option dbu
  text "Показывает сообщение с указанным номером из Вашего списка сообщений. Если указано NEW, будут показаны только новые сообщения. Если же указано LAST, будут показаны недавно полученные сообщения.",2,27 5 126 40,center 
  icon 4,7 7 16 16,pics\memox.ico,noborder
  button "Ok",1,62 41 43 10,ok, flat
  box "",6,2 0 159 56
}
on *:dialog:memoserv.read.me.help:init:*:{
  mdx MarkDialog $dname $dialog($dname).hwnd
  mdx SetDialog $dname style 0 title
}
