on *:udpread:mta.*:var %a,%b | !sockread &a | !dll " $+ $scriptdirmta.dll" data $right($sockname,1) $bvar(&a,1,20)
alias -l mta.gt { var %a = $hget(mta.gt $+ $1,h),%b = $hget(mta.gt $+ $1,m) | !inc %b | if (%b > 59) { %b = 0 | !inc %a | if (%a > 23) %a = 0 } | !did -a mta $1 $+ 29 $+(%a,:,$iif(%b < 10,0),%b) | !hadd mta.gt $+ $1 h %a | !hadd mta.gt $+ $1 m %b }
alias mta.log { var %a = $1 $+ 02,%b = $did(mta,%a).lines,%c = $iif($readini($scriptdirmta.ini,0,timel),$asctime($readini($scriptdirmta.ini,0,times))) $2- | !did -a mta %a $iif($did(mta,%a,%b),$crlf $+ %c,%c) | if (%b > 150) !did -d mta %a 1 | if ($readini($scriptdirmta.ini,$1,log)) !write $+(",$scriptdirlogs\,$asctime(dd-mm-yy),@,$sock(mta. $+ $1).saddr,;,$did(mta,$1 $+ 10),.log") %c }
/*
//////////////////////////////////////////////////////////
/////////////////        WARNING:         ////////////////
//////////////////////////////////////////////////////////
// Editing this script will give an failed CRC check    //
// If it gives a failed CRC check you must reinstall it //
//////////////////////////////////////////////////////////
*/
alias mta.active !return $dialog(mta).tab
alias mta.say !dll " $+ $scriptdirmta.dll" say $1- 
alias mta.getbans !dll " $+ $scriptdirmta.dll" getbans $1
alias mta.dir !return $scriptdir
alias mta.name !return $iif($readini($scriptdir $+ $1.ini,n,ID $+ $2,name) != $null,$v1,Unknown)
alias mta.score !return $readini($scriptdir $+ $1.ini,ID $+ $2,score)
alias mta.kills !return $readini($scriptdir $+ $1.ini,ID $+ $2,kills)
alias mta.ping !return $readini($scriptdir $+ $1.ini,ID $+ $2,ping)
alias mta.deaths !return $readini($scriptdir $+ $1.ini,ID $+ $2,deaths)
alias mta.bans {
  var %a = $scriptdirmta.bans.ini,%b = $did(mta,$1 $+ 09),%c = $ini(%a,%b,$2)
  !return %c $iif($2 != 0,$readini(%a,%b,%c))
}
alias mta.idle {
  var %a = $calc(($ticks -$readini($scriptdir $+ $1.ini,ID $+ $2,idle))/1000)
  if ($prop == time) !return $duration(%a)
  !return %a
}
alias mta.online {
  var %a = $calc(($ticks -$readini($scriptdir $+ $1.ini,ID $+ $2,online))/1000) 
  if ($prop == time) !return $duration(%a)
  !return %a
}
alias mta.status {
  if ($prop == text) !return $gettok(Unknown;Out game;In game;Unknown;Spectator,$calc($readini($scriptdir $+ $1.ini,ID $+ $2,status)+1),59)
  !return $readini($scriptdir $+ $1.ini,ID $+ $2,status)
}
alias mta.mode !return $did(mta,$1 $+ 22)
alias mta.submode !return $did(mta,$1 $+ 25)
alias mta.sname !return $did(mta,$1 $+ 43)
alias mta.server {
  if ($prop == ip) !return $sock(mta. $+ $1).saddr
  if ($prop == port) !return $sock(mta. $+ $1).sport
  if ($prop == cport) !return $did(mta,$1 $+ 41)
  if ($prop == sent) !return $sock(mta. $+ $1).sent
  if ($prop == rcvd) !return $sock(mta. $+ $1).rcvd
  if ($prop == time) !return $sock(mta. $+ $1).to
  !return $+($sock(mta. $+ $1).saddr,:,$sock(mta. $+ $1).sport)
}
alias mta.admin+ !return $iif($readini($scriptdirmta.ini,$1,admin+),$true,$false)
alias mta.scripts !return $iif($readini($scriptdirmta.ini,$1,scripts) == 0,$false,$true)
alias mta.money !return $calc($readini($scriptdir $+ $1.ini,ID $+ $2,money))
alias mta.game !return $did(mta,$1 $+ 33)
alias mta.time !return $did(mta,$1 $+ 29)
alias mta.weather !return $did(mta,$1 $+ 35)
alias mta.weapon !return $readini($scriptdirmta.data.ini,WEAPON $+ $iif($did(mta,$1 $+ 33) == GTA:3,1,2),$2)
alias mta.players !return $ini($scriptdir $+ $1.ini,0)
alias mta.motd !return $readini($scriptdirmta.ini,$1,motd)
alias mta.maxplayers !return $readini($scriptdirmta.ini,$1,max)
alias mta.skin {
  if (!$readini($scriptdirmta.ini,$1,admin+)) !return Disabled
  var %a = $readini($scriptdir $+ $1.ini,ID $+ $2,skin),%b
  if ($did(mta,$1 $+ 33) == GTA:3) %b = 1
  elseif ($did(mta,$1 $+ 22) == Deathmatch) %b = 2
  else %b = 3
  if ($prop == name) !return $iif($readini($scriptdirmta.data.ini,SKIN $+ %b,%a),$v1,Unknown)
  !return $iif(%a,$v1,0)
}
alias mta.ip {
  if ($readini($scriptdir $+ $1.ini,ID $+ $2,ip)) !return $v1
  !dll " $+ $scriptdirmta.dll" getip $1-2
  !return Unknown
}
alias mta.vehicle {
  if (!$readini($scriptdirmta.ini,$1,admin+)) !return Disabled
  var %a,%b,%c
  if ($prop == id) {
    if ($2 == 0) !return Foot
    if ($did(mta,$1 $+ 22) == Portland) %a = 1
    elseif ($did(mta,$1 $+ 22) == Staunton) %a = 2
    elseif ($did(mta,$1 $+ 22) == Shoreside Vale) %a = 3
    elseif ($did(mta,$1 $+ 22) == Deathmatch) %a = 4
    elseif ($did(mta,$1 $+ 22) == Stunt) %a = 5
    %a = $readini($scriptdirmta.data.ini,VEHICLE $+ %a,$2)
  }
  elseif ($prop == list) {
    %a = 32
    while (%a >= 0) {
      if ($dll($scriptdirmta.dll,vehicle,$1 %a) == $2) %c = %a
      elseif ($v1 == $calc(100+$2)) %b = %b %a
      !dec %a
    }
    !return $iif(%c == $null,-1,%c) %b
  }
  elseif ($prop == name) { 
    %a = $dll($scriptdirmta.dll,vehicle,$1-2)
    if (%a == Unknown) !return Unknown
    if (%a > 100) %a = %a - 100
    if ($prop == name) {
      if (%a == 0) !return Foot
      if ($did(mta,$1 $+ 22) == Portland) %b = 1
      elseif ($did(mta,$1 $+ 22) == Staunton) %b = 2
      elseif ($did(mta,$1 $+ 22) == Shoreside Vale) %b = 3
      elseif ($did(mta,$1 $+ 22) == Deathmatch) %b = 4
      elseif ($did(mta,$1 $+ 22) == Stunt) %b = 5
      %a = $readini($scriptdirmta.data.ini,VEHICLE $+ %b,%a)
    }
  }
  else %a = $iif($dll($scriptdirmta.dll,vehicle,$1-2) == Unknown,0,$v1)
  !return %a
}
alias mta.passenger !return $iif(($dll($scriptdirmta.dll,vehicle,$1-2) isnum) && ($v1 > 100),$true,$false)
alias mta.location {
  if (!$readini($scriptdirmta.ini,$1,admin+)) !return Disabled
  !return $dll($scriptdirmta.dll,location,$1-3)
}
alias mta.health {
  if (!$readini($scriptdirmta.ini,$1,admin+)) !return Disabled
  !return $dll($scriptdirmta.dll,health,$1-2 $prop)
}
alias mta.getid {
  var %a = 0
  while (%a <= $readini($scriptdirmta.ini,$1,max))  {
    if ($+(*,$2,*) iswm $readini($scriptdir $+ $1.ini,n,ID $+ %a,name)) !return %a
    !inc %a
  }
  !return -1
}
alias mta.area {
  if (!$readini($scriptdirmta.ini,$1,admin+)) !return Disabled
  var %a,%b = 1,%c = $dll($scriptdirmta.dll,location,$1-2 x),%d = $dll($scriptdirmta.dll,location,$1-2 y),%e
  if (%c == Unknown) !return Unknown
  if ($did(mta,$1 $+ 33) == GTA:3) %a = AREA1
  else %a = AREA2
  while (%b <= $ini($scriptdirmta.data.ini,%a,0)) {
    %e = $ini($scriptdirmta.data.ini,%a,%b)
    if ($inpoly(%c,%d, [ %e ] )) !return $readini($scriptdirmta.data.ini,%a,%e)
    !inc %b
  }
  !return $iif($did(mta,$1 $+ 33) == GTA:3,Liberty-City,Vice-City)
}
alias mta.tsay {
  var %a = 1,%b = 0
  while (%a <= $timer(0)) {
    if (mta.say* iswm $timer(%a).com) {
      !inc %b
    }
    !inc %a
  }
  !timer 1 %b mta.say $1-
}
alias mta.tmsg mta.tsay $1 /msg $chr(35) $+ $2-
alias mta.resetscores !dll " $+ $scriptdirmta.dll" resetscores $1
alias mta.resetmoney !dll " $+ $scriptdirmta.dll" resetmoney $1
alias mta.settime !dll " $+ $scriptdirmta.dll" settime $1-2
alias mta.setweather if ($did(mta,$1 $+ 33) != GTA:3) !dll " $+ $scriptdirmta.dll" setweather $1-2
alias mta.setpassword !dll " $+ $scriptdirmta.dll" setpassword $1-
alias mta.setmotd !dll " $+ $scriptdirmta.dll" setmotd $1-
alias mta.slap mta.say $1 /slap $iif($2 isnum,$mta.name($1,$2) $3-,$2-)
alias mta.msg mta.say $1 /msg $chr(35) $+ $2-
alias mta.me mta.say $1 /me $2-
alias mta.kick !dll " $+ $scriptdirmta.dll" kick $1-2
alias mta.ban !dll " $+ $scriptdirmta.dll" ban $1-
alias mta.addban !dll " $+ $scriptdirmta.dll" addban $1-
alias mta.shutdown !dll " $+ $scriptdirmta.dll" shutdown $1
alias mta.motd !dll " $+ $scriptdirmta.dll" motd $1
alias mta.unban !dll " $+ $scriptdirmta.dll" unban $1-2
alias mta.close {
  var %a = 1,%b = !writeini -n " $+ $scriptdirmta.ini"
  if ($dialog(mta)) {
    %b 0 accept 1
    %b 0 focus $dialog(mta).tab
    while (%a < 9) {
      if ($did(mta,%a $+ 09)) %b %a host $did(mta,%a $+ 09)
      if ($did(mta,%a $+ 10)) %b %a port $did(mta,%a $+ 10)
      if ($did(mta,%a $+ 41)) %b %a cport $did(mta,%a $+ 41)
      if ($did(mta,%a $+ 11)) %b %a pass $did(mta,%a $+ 11)
      if ($did(mta,%a $+ 12)) %b %a nick $did(mta,%a $+ 12)
      if ($did(mta,%a $+ 23)) %b %a note $did(mta,%a $+ 23)
      if ($did(mta,%a $+ 08) != Connect) mta.dis %a Quit.
      !inc %a
    }
    !dialog -x mta
  }
  !dll -u mta.dll
  !.signal -n mta.quit
}
on *:DNS: {
  if ($dialog(mta)) {
    var %a = 1
    while (%a < 9) {
      if ($dns(0).addr == $did(mta,%a $+ 09)) {
        if ($dns(0).ip) {
          if (!$readini($scriptdirmta.ini,0,dns)) mta.log %a * DNS: Resoved $+(",$did(mta,%a $+ 09),") to $+(",$dns(0).ip,".)
          !did -e mta %a $+ 08
          mta.con3 %a $dns(0).ip
        }
        else {
          mta.log %a * DNS: Unable to resolve $+(",$did(mta,%a $+ 09),".)
          !did -e mta %a $+ 08
          !did -f mta %a $+ 09
        }
        !break
      }
      !inc %a
    }
  }
}
alias mta.con {
  if ($1 == $null) !echo 2 -es * /mta.con: insufficient parameters
  elseif ($sock(mta. $+ $1)) !echo 2 -es * /mta.con: already connected
  else {
    if (!$dialog(mta)) mta
    if ($did(mta,$1 $+ 12) == $null) {
      mta.log $1 * Connect: Nick missing.
      !did -f mta $1 $+ 12
    }
    elseif ($did(mta,$1 $+ 10) == $null) {
      mta.log $1 * Connect: Port missing.
      !did -f mta $1 $+ 10
    }
    elseif ($did(mta,$1 $+ 10) < 1) || ($did(mta,$1 $+ 10) > 65536) || ($did(mta,$1 $+ 10) !isnum) {
      mta.log $1 * Connect: Invalid admin port.
      !did -fc mta $1 $+ 10 1 1 $did(mta,$1 $+ 10).len
    }
    elseif ($did(mta,$1 $+ 41) < 1) || ($did(mta,$1 $+ 41) > 65536) || ($did(mta,$1 $+ 41) !isnum) {
      mta.log $1 * Connect: Invalid client port.
      !did -fc mta $1 $+ 41 1 1 $did(mta,$1 $+ 41).len
    }
    elseif (localhost == $did(mta,$1 $+ 09)) {
      mta.con3 $1 $ip
    }
    elseif (. !isin $did(mta,$1 $+ 09)) {
      mta.log $1 * Connect: Invalid Host/IP.
      !did -f mta $1 $+ 09
    }
    elseif (!$mta.checkip($did(mta,$1 $+ 09))) {
      if (!$readini($scriptdirmta.ini,0,dns)) mta.log $1 * DNS: Resolving $+(",$did(mta,$1 $+ 09),"...)
      !did -b mta $1 $+ 08
      !.dns $did(mta,$1 $+ 09)
    }
    else mta.con3 $1 $did(mta,$1 $+ 09)
  }
}
alias mta.dis {
  if ($1 == $null) !echo 2 -es * /mta.dis: insufficient parameters
  elseif (!$dialog(mta)) || ($did(mta,$1 $+ 08) == Connect) !echo 2 -es * /mta.dis: not connected
  elseif ($timer(mta.rc $+ $1)) {
    !.timermta.rc $+ $1 off
    !remini " $+ $scriptdirmta.ini" $1 to
    mta.log $1 * Auto reconnect aborted.
    !did -a mta $1 $+ 08 Connect
    !did -e mta $+($1,09,$chr(44),$1,10,$chr(44),$1,11,$chr(44),$1,12,$chr(44),$1,41)
  }
  else {
    var %a = mta. $+ $1,%b
    !dll " $+ $scriptdirmta.dll" part $1
    !.timermta.to $+ $1 off
    !.timermta.gt $+ $1 off
    !hfree -w mta.gt $+ $1
    !.remove $+(",$scriptdir,$1.ini")
    !did -r mta $+($1,01,$chr(44),$1,21,$chr(44),$1,22,$chr(44),$1,27,$chr(44),$1,29,$chr(44),$1,33,$chr(44),$1,35,$chr(44),$1,25,$chr(44),$1,43)
    !did -b mta $+($1,15,$chr(44),$1,16,$chr(44),$1,30,$chr(44),$1,31,$chr(44),$1,36,$chr(44),$1,37,$chr(44),$1,38) $+ ,30,31,33,34,35
    if ($window(@Map)) && ($hget(mta.map,s) == $1) !window -c @Map
    if ($dialog(mta.options2)) && ($right($dialog(mta.options2).title,1) == $1) !did -b mta.options2 8,7,10,17,18,19,20,21
    if ($dialog(mta.banslist)) && ($gettok($did(mta.banslist,6),2,32) == $1) !did -b mta.banslist 2,3,8,7
    mta.log $1 * Disconnected: $iif($2-,$2-,Script)
    if ($sock(%a)) mta.log $1 * Send: $bytes($sock(%a).sent,3).suf $chr(124) Recieved: $bytes($sock(%a).rcvd,3).suf $chr(124) Time: $duration($sock(%a).to)
    !sockclose %a
    !did -a mta $1 Server $1
    if ($readini($scriptdirmta.ini,0,to)) && ($2- == Timed out.) {
      %b = $calc($readini($scriptdirmta.ini,$1,to)+1)
      !writeini -n " $+ $scriptdirmta.ini" $1 to %b
      if (%b < 6) {
        mta.log $1 * Auto reconnect in 5 seconds.
        !.timermta.rc $+ $1 1 5 mta.con $1
        if ($readini($scriptdirmta.ini,$1,scripts) != 0) !.signal -n mta.disconnect $1-
        !halt
      }
    }
    !remini " $+ $scriptdirmta.ini" $1 to
    !did -a mta $1 $+ 08 Connect
    !did -e mta $+($1,09,$chr(44),$1,10,$chr(44),$1,11,$chr(44),$1,12,$chr(44),$1,41)
    if ($readini($scriptdirmta.ini,$1,scripts) != 0) !.signal -n mta.disconnect $1-
  }
}
alias mta {
  if (!$readini($scriptdirmta.ini,0,accept)) && (!$input(Do you accept the License Agreement described in 'manual.txt'?,uyqd,MTA:mA)) !halt
  elseif ($version > 6.15) || ($input(You have not mIRC v6.16 or higher this could give problems. Continue?,uywd,MTA:mA)) {
    if (!$exists($scriptdirmta.dll)) !halt $input(ERROR: File 'mta.dll' not found! $lf $+ Make sure it's in the same folder as 'mta.mrc'.,uohd,MTA:mA)
    elseif (!$exists($scriptdirmta.data.ini)) !halt $input(ERROR: File 'mta.data.ini' not found! $lf $+ Make sure it's in the same folder as 'mta.mrc'.,uohd,MTA:mA)
    elseif (!$exists($scriptdirmta.ico)) !halt $input(ERROR: File 'mta.ico' not found! $lf $+ Make sure it's in the same folder as 'mta.mrc'.,uohd,MTA:mA)
    elseif (!$exists($scriptdirmap_vc.bmp)) !halt $input(ERROR: File 'map_vc.bmp' not found! $lf $+ Make sure it's in the same folder as 'mta.mrc'.,uohd,MTA:mA)
    elseif (!$exists($scriptdirmap_3.bmp)) !halt $input(ERROR: File 'map_3.bmp' not found! $lf $+ Make sure it's in the same folder as 'mta.mrc'.,uohd,MTA:mA)
    elseif ($lock(dll)) !halt $input(ERROR: '/dll' command disabled! $lf $+ Make sure it's not disabled in the 'Lock'-menu.,uohd,MTA:mA)
    else {
      if (!$dialog(mta)) {
        !.events on
        !sockclose mta.*
        !dialog $+(-m,$iif($readini($scriptdirmta.ini,0,top),o),$iif($readini($scriptdirmta.ini,0,desktop) != 0,d)) mta mta
        if ($readini($scriptdirmta.ini,0,focus)) !did -c mta $v1
        if ($readini($scriptdirmta.ini,0,update) != 0) mta.update
        if ($readini($scriptdirmta.ini,0,black) != 0) mta.black
        mta.motd3
        !mkdir " $+ $scriptdirlogs"
        var %a = 1
        while (%a < 9) {
          if ($readini($scriptdirmta.ini,%a,conn)) mta.con %a
          !inc %a
        }
        !.signal -n mta.start
      }
      else !dialog -v mta
    }
  }
}
alias -l mta.refresh {
  if ($2 != $null) {
    mta.log $1 * Server: Refresh $2- $+ .
    !sockclose mta.refresh $+ $1
  }
  elseif (!$timer(mta.refresh. $+ $1)) {
    mta.log $1 * Server: Refreshing...
    !.timermta.refresh. $+ $1 1 10 mta.refresh $1 timed out
    !dll " $+ $scriptdirmta.dll" refresh $1
  }
}
alias -l mta.refresh2 {
  !dll " $+ $scriptdirmta.dll" getip $1 $2
  var %a = !writeini -n $+(",$scriptdir,$1.ini") ID $+ $2
  %a deaths $calc($readini($scriptdir $+ $1.ini,ID $+ $2,deaths))
  %a kills $calc($readini($scriptdir $+ $1.ini,ID $+ $2,kills))
  %a online $ticks
  %a idle $ticks
  %a status $calc($readini($scriptdir $+ $1.ini,ID $+ $2,status)) 
  mta.log $1 * $readini($scriptdir $+ $1.ini,n,ID $+ $2,name) joins. (Recoverd)
  mta.punk $1 $2
  if ($readini($scriptdirmta.ini,$1,scripts) != 0) !.signal -n mta.join $1 $2 Recoverd
}
on *:udpread:mtarefresh.*:!sockread &a | !dll " $+ $scriptdirmta.dll" refresh2 $right($sockname,1) $bvar(&a,1,20)
alias mta.submode2 {
  var %a = $gettok(Normal;Unknown;Van Heist;GTA;Speed;Ransack;Scramble start;Scramble,$calc(1+$3),59)
  if (%a != $did(mta,$1 $+ 25)) {
    !did -ra mta $1 $+ 25 %a
    if (%a != Normal) {
      mta.log $1 * Submode: Changed to $+(",%a,".)
      if ($readini($scriptdirmta.ini,$1,scripts) != 0) !.signal -n mta.submode $1 $2
    }
  }
}
alias -l mta.punk {
  var %a = $mta.name($1,$2)
  if ($readini($scriptdirmta.ini,$1,punk)) {
    if ($read($scriptdirmta.blacklist.ini,w,$mta.ip($1,$2))) && ($readini($scriptdirmta.ini,0,black) != 0) {
      mta.say $1 $+(",%a,") Reason: PunkCatcher (Blacklisted)
      mta.ban $1 $2 PunkCatcher (Blacklisted)
    }
    else $+(!.timermta.punk.,$1,.,$2) 1 20 mta.punk2 $1 $2
  }
}
alias -l mta.punk2 {
  if ($dialog(mta)) && ($ini($scriptdir $+ $1.ini,ID $+ $2)) {
    if ($readini($scriptdir $+ $1.ini,ID $+ $2,ping) == $null) {
      mta.say $1 $+(",$mta.name($1,$2),") Reason: PunkCatcher (MTA bot)
      mta.ban $1- PunkCatcher (MTA bot)
    }
  }
}
alias -l mta.spawn {
  var %a = !writeini -n $+(",$scriptdir,$1.ini") ID $+ $2 
  %a idle $ticks
  %a skin $3
  %a status 1
  if ($readini($scriptdirmta.ini,$1,scripts) != 0) !.signal -n mta.spawn $1-
}
alias -l mta.con2 {
  if ($did(mta,$1 $+ 35) == $null) !did -a mta $1 $+ 35 ?
  if ($did(mta,$1 $+ 33) == GTA:3) !did -a mta $1 $+ 35 Disabled
  !did -e mta $+($1,15,$chr(44),$1,16,$chr(44),$1,30,$chr(44),$1,31,$chr(44),$1,36,$chr(44),$1,37,$chr(44),$1,38,$chr(44),$1,43) $+ ,30,31,33,34,35
  !did -a mta $1 $+ 27 ?
  !writeini -n " $+ $scriptdirmta.ini" $1 ticks $calc($ticks -1000) 
  !remini " $+ $scriptdirmta.ini" $1 to
  mta.list $1
  mta.log $1 * Connected!
  mta.log $1 * Game: $did(mta,$1 $+ 33) $chr(124) Mode: $did(mta,$1 $+ 22) $chr(124) Submode: $did(mta,$1 $+ 25) $chr(124)Players: $did(mta,$1 $+ 21)
  !did -ra mta $1 $+ 08 Disconnect
  mta.motd2 $1
  if ($dialog(mta.options2)) && ($right($dialog(mta.options2).title,1) == $1) {
    !did -e mta.options2 8,7,10,17,18,19
    if ($did(mta,$1 $+ 33) != GTA:3) !did -e mta.options2 20,21
  }
  if ($dialog(mta.banslist)) && ($gettok($did(mta.banslist,6),2,32) == $1) !did -e mta.banslist 2,3,8,7
  if ($readini($scriptdirmta.ini,$1,scripts) != 0) !.signal -n mta.connect $1
}
alias -l mta.con3 {
  !.remove $+(",$scriptdir,$1.ini")
  !did -a mta $1 Server $1 *
  !did -a mta $1 $+ 08 Cancel
  !did -b mta $+($1,09,$chr(44),$1,10,$chr(44),$1,11,$chr(44),$1,12,$chr(44),$1,41)
  if (!$hget(mta.gt $+ $1)) !hmake mta.gt $+ $1 2
  if ($readini($scriptdirmta.ini,0,clear) != 0) !did -r mta $1 $+ 02
  mta.log $1 * $iif($readini($scriptdirmta.ini,$1,to),Connect retry $chr(35) $+ $v1,Connecting to) $+($2,:,$did(mta,$1 $+ 10),...) ( $+ $iif($readini($scriptdirmta.ini,$1,admin+),Admin+,Normal) $+ )
  !.timermta.to $+ $1 1 10 mta.dis $1 Timed out.
  !dll " $+ $scriptdirmta.dll" join $1 $2 $did(mta,$1 $+ 10)
}
alias -l mta.part2 {
  !remini $+(",$scriptdir,$1.ini") ID $+ $2
  mta.list $1
}
alias -l mta.list {
  var %a = 0,%b,%c = $scriptdir $+ $1.ini,%d = $gettok($did(mta,$1 $+ 01).seltext,1,32),%e = $iif($did(mta,$1 $+ 22) == Stunt,money,score)
  while (%a < 33) {
    if ($ini(%c,ID $+ %a)) %b = %b $+ %a $readini($scriptdir $+ $1.ini,ID $+ %a,%e) $mta.name($1,%a) $+ $chr(124)
    !inc %a
  }
  !did -r mta $1 $+ 01
  !didtok mta $1 $+ 01 124 %b
  if (%d != $null) !did -c mta $1 $+ 01 $didwm(mta,$1 $+ 01,%d *)
  !did -a mta $1 $+ 21 $ini($scriptdir $+ $1.ini,0) / $readini($scriptdirmta.ini,$1,max)
}
alias -l mta.dex {
  var %a = 1,%b
  while (%a <= $len($1-)) {
    %b = %b $asc($mid($1-,%a,1))
    !inc %a
  }
  !return %b
}
alias -l mta.checkip {
  !tokenize 46 $1
  !return $iif(($1 < 256) && ($1 >= 0) && ($2 < 256) && ($2 >= 0) && ($3 < 256) && ($3 >= 0) && ($4 < 256) && ($4 >= 0) && ($5 == $null),1,0)
}
dialog -l mta {
  title "Multi Theft Auto mIRC Admin v3.24 by Aeron"
  size -1 -1 354 202
  option dbu
  icon $scriptdirmta.ico, 0
  tab "Server 1", 1, -1 -3 356 195
  list 101, 2 22 58 168, tab 1 size vsbar
  edit "", 102, 62 14 212 164, tab 1 read multi autovs vsbar
  combo 103, 62 180 182 50, tab 1 size edit drop
  text "Host / IP:", 104, 274 14 29 8, tab 1 right
  text "Admin port:", 105, 274 24 29 8, tab 1 right
  text "Password:", 106, 274 44 29 8, tab 1 right
  text "Nickname:", 107, 274 54 29 8, tab 1 right
  button "Connect", 108, 276 74 38 10, tab 1
  edit "", 109, 303 14 50 10, tab 1 autohs
  edit "", 110, 303 24 50 10, tab 1
  edit "", 111, 303 44 50 10, tab 1 pass autohs
  edit "", 112, 303 54 50 10, tab 1 autohs
  text "Notes:", 113, 274 64 29 8, tab 1 right
  button "Send", 114, 246 180 19 10, tab 1
  button "Kick", 115, 276 84 38 10, disable tab 1
  button "Ban", 116, 276 94 38 10, disable tab 1
  text "Copyright  2005 by Aeron", 117, 276 183 77 8, disable tab 1 center
  text "Players:", 119, 276 151 37 8, tab 1 right
  text "Mode:", 120, 276 137 37 8, tab 1 right
  text "", 121, 314 151 39 8, tab 1
  text "", 122, 314 137 39 8, tab 1
  edit "", 123, 303 64 50 10, tab 1 autohs
  button "Bans list", 124, 315 74 38 10, tab 1
  text "Ping flux:", 126, 276 175 37 8, tab 1 right
  text "", 127, 314 175 39 8, tab 1
  text "Game time:", 128, 276 159 37 8, tab 1 right
  text "", 129, 314 159 39 8, tab 1
  button "!", 130, 266 180 7 10, disable tab 1
  button "Private chat", 131, 315 94 38 10, disable tab 1
  text "Game:", 132, 276 129 37 8, tab 1 right
  text "", 133, 314 129 39 8, tab 1
  text "Weather:", 134, 276 167 37 8, tab 1 right
  text "", 135, 314 167 39 8, tab 1
  button "Map", 136, 315 84 38 10, disable tab 1
  button "Statistics", 137, 315 104 38 10, disable tab 1
  button "Slap", 138, 276 104 38 10, disable tab 1
  text "ID-Score/Money-Name", 139, 2 14 57 8, tab 1 center
  text "Client port:", 140, 274 34 29 8, tab 1 right
  edit "", 141, 303 34 50 10, tab 1
  text "Submode:", 118, 276 144 37 8, tab 1 right
  text "", 125, 314 144 39 8, tab 1
  text "Server:", 142, 276 114 77 8, tab 1 center
  text "", 143, 276 122 77 8, tab 1
  tab "Server 2", 2, -1 -3 356 195
  list 201, 2 22 58 168, tab 2 size vsbar
  edit "", 202, 62 14 212 164, tab 2 read multi autovs vsbar
  combo 203, 62 180 182 50, tab 2 size edit drop
  text "Host / IP:", 204, 274 14 29 8, tab 2 right
  text "Admin port:", 205, 274 24 29 8, tab 2 right
  text "Password:", 206, 274 44 29 8, tab 2 right
  text "Nickname:", 207, 274 54 29 8, tab 2 right
  button "Connect", 208, 276 74 38 10, tab 2
  edit "", 209, 303 14 50 10, tab 2 autohs
  edit "", 210, 303 24 50 10, tab 2
  edit "", 211, 303 44 50 10, tab 2 pass autohs
  edit "", 212, 303 54 50 10, tab 2 autohs
  text "Notes:", 213, 274 64 29 8, tab 2 right
  button "Send", 214, 246 180 19 10, tab 2
  button "Kick", 215, 276 84 38 10, disable tab 2
  button "Ban", 216, 276 94 38 10, disable tab 2
  text "Copyright  2005 by Aeron", 217, 276 183 77 8, disable tab 2 center
  text "Players:", 219, 276 151 37 8, tab 2 right
  text "Mode:", 220, 276 137 37 8, tab 2 right
  text "", 221, 314 151 39 8, tab 2
  text "", 222, 314 137 39 8, tab 2
  edit "", 223, 303 64 50 10, tab 2 autohs
  button "Bans list", 224, 315 74 38 10, tab 2
  text "Ping flux:", 226, 276 175 37 8, tab 2 right
  text "", 227, 314 175 39 8, tab 2
  text "Game time:", 228, 276 159 37 8, tab 2 right
  text "", 229, 314 159 39 8, tab 2
  button "!", 230, 266 180 7 10, disable tab 2
  button "Private chat", 231, 315 94 38 10, disable tab 2
  text "Game:", 232, 276 129 37 8, tab 2 right
  text "", 233, 314 129 39 8, tab 2
  text "Weather:", 234, 276 167 37 8, tab 2 right
  text "", 235, 314 167 39 8, tab 2
  button "Map", 236, 315 84 38 10, disable tab 2
  button "Statistics", 237, 315 104 38 10, disable tab 2
  button "Slap", 238, 276 104 38 10, disable tab 2
  text "ID-Score/Money-Name", 239, 2 14 57 8, tab 2 center
  text "Client port:", 240, 274 34 29 8, tab 2 right
  edit "", 241, 303 34 50 10, tab 2
  text "Submode:", 218, 276 144 37 8, tab 2 right
  text "", 225, 314 144 39 8, tab 2
  text "Server:", 242, 276 114 77 8, tab 2 center
  text "", 243, 276 122 77 8, tab 2
  tab "Server 3", 3, -1 -3 356 195
  list 301, 2 22 58 168, tab 3 size vsbar
  edit "", 302, 62 14 212 164, tab 3 read multi autovs vsbar
  combo 303, 62 180 182 50, tab 3 size edit drop
  text "Host / IP:", 304, 274 14 29 8, tab 3 right
  text "Admin port:", 305, 274 24 29 8, tab 3 right
  text "Password:", 306, 274 44 29 8, tab 3 right
  text "Nickname:", 307, 274 54 29 8, tab 3 right
  button "Connect", 308, 276 74 38 10, tab 3
  edit "", 309, 303 14 50 10, tab 3 autohs
  edit "", 310, 303 24 50 10, tab 3
  edit "", 311, 303 44 50 10, tab 3 pass autohs
  edit "", 312, 303 54 50 10, tab 3 autohs
  text "Notes:", 313, 274 64 29 8, tab 3 right
  button "Send", 314, 246 180 19 10, tab 3
  button "Kick", 315, 276 84 38 10, disable tab 3
  button "Ban", 316, 276 94 38 10, disable tab 3
  text "Copyright  2005 by Aeron", 317, 276 183 77 8, disable tab 3 center
  text "Players:", 319, 276 151 37 8, tab 3 right
  text "Mode:", 320, 276 137 37 8, tab 3 right
  text "", 321, 314 151 39 8, tab 3
  text "", 322, 314 137 39 8, tab 3
  edit "", 323, 303 64 50 10, tab 3 autohs
  button "Bans list", 324, 315 74 38 10, tab 3
  text "Ping flux:", 326, 276 175 37 8, tab 3 right
  text "", 327, 314 175 39 8, tab 3
  text "Game time:", 328, 276 159 37 8, tab 3 right
  text "", 329, 314 159 39 8, tab 3
  button "!", 330, 266 180 7 10, disable tab 3
  button "Private chat", 331, 315 94 38 10, disable tab 3
  text "Game:", 332, 276 129 37 8, tab 3 right
  text "", 333, 314 129 39 8, tab 3
  text "Weather:", 334, 276 167 37 8, tab 3 right
  text "", 335, 314 167 39 8, tab 3
  button "Map", 336, 315 84 38 10, disable tab 3
  button "Statistics", 337, 315 104 38 10, disable tab 3
  button "Slap", 338, 276 104 38 10, disable tab 3
  text "ID-Score/Money-Name", 339, 2 14 57 8, tab 3 center
  text "Client port:", 340, 274 34 29 8, tab 3 right
  edit "", 341, 303 34 50 10, tab 3
  text "Submode:", 318, 276 144 37 8, tab 3 right
  text "", 325, 314 144 39 8, tab 3
  text "Server:", 342, 276 114 77 8, tab 3 center
  text "", 343, 276 122 77 8, tab 3
  tab "Server 4", 4, -1 -3 356 195
  list 401, 2 22 58 168, tab 4 size vsbar
  edit "", 402, 62 14 212 164, tab 4 read multi autovs vsbar
  combo 403, 62 180 182 50, tab 4 size edit drop
  text "Host / IP:", 404, 274 14 29 8, tab 4 right
  text "Admin port:", 405, 274 24 29 8, tab 4 right
  text "Password:", 406, 274 44 29 8, tab 4 right
  text "Nickname:", 407, 274 54 29 8, tab 4 right
  button "Connect", 408, 276 74 38 10, tab 4
  edit "", 409, 303 14 50 10, tab 4 autohs
  edit "", 410, 303 24 50 10, tab 4
  edit "", 411, 303 44 50 10, tab 4 pass autohs
  edit "", 412, 303 54 50 10, tab 4 autohs
  text "Notes:", 413, 274 64 29 8, tab 4 right
  button "Send", 414, 246 180 19 10, tab 4
  button "Kick", 415, 276 84 38 10, disable tab 4
  button "Ban", 416, 276 94 38 10, disable tab 4
  text "Copyright  2005 by Aeron", 417, 276 183 77 8, disable tab 4 center
  text "Players:", 419, 276 151 37 8, tab 4 right
  text "Mode:", 420, 276 137 37 8, tab 4 right
  text "", 421, 314 151 39 8, tab 4
  text "", 422, 314 137 39 8, tab 4
  edit "", 423, 303 64 50 10, tab 4 autohs
  button "Bans list", 424, 315 74 38 10, tab 4
  text "Ping flux:", 426, 276 175 37 8, tab 4 right
  text "", 427, 314 175 39 8, tab 4
  text "Game time:", 428, 276 159 37 8, tab 4 right
  text "", 429, 314 159 39 8, tab 4
  button "!", 430, 266 180 7 10, disable tab 4
  button "Private chat", 431, 315 94 38 10, disable tab 4
  text "Game:", 432, 276 129 37 8, tab 4 right
  text "", 433, 314 129 39 8, tab 4
  text "Weather:", 434, 276 167 37 8, tab 4 right
  text "", 435, 314 167 39 8, tab 4
  button "Map", 436, 315 84 38 10, disable tab 4
  button "Statistics", 437, 315 104 38 10, disable tab 4
  button "Slap", 438, 276 104 38 10, disable tab 4
  text "ID-Score/Money-Name", 439, 2 14 57 8, tab 4 center
  text "Client port:", 440, 274 34 29 8, tab 4 right
  edit "", 441, 303 34 50 10, tab 4
  text "Submode:", 418, 276 144 37 8, tab 4 right
  text "", 425, 314 144 39 8, tab 4
  text "Server:", 442, 276 114 77 8, tab 4 center
  text "", 443, 276 122 77 8, tab 4
  tab "Server 5", 5, -1 -3 356 195
  list 501, 2 22 58 168, tab 5 size vsbar
  edit "", 502, 62 14 212 164, tab 5 read multi autovs vsbar
  combo 503, 62 180 182 50, tab 5 size edit drop
  text "Host / IP:", 504, 274 14 29 8, tab 5 right
  text "Admin port:", 505, 274 24 29 8, tab 5 right
  text "Password:", 506, 274 44 29 8, tab 5 right
  text "Nickname:", 507, 274 54 29 8, tab 5 right
  button "Connect", 508, 276 74 38 10, tab 5
  edit "", 509, 303 14 50 10, tab 5 autohs
  edit "", 510, 303 24 50 10, tab 5
  edit "", 511, 303 44 50 10, tab 5 pass autohs
  edit "", 512, 303 54 50 10, tab 5 autohs
  text "Notes:", 513, 274 64 29 8, tab 5 right
  button "Send", 514, 246 180 19 10, tab 5
  button "Kick", 515, 276 84 38 10, disable tab 5
  button "Ban", 516, 276 94 38 10, disable tab 5
  text "Copyright  2005 by Aeron", 517, 276 183 77 8, disable tab 5 center
  text "Players:", 519, 276 151 37 8, tab 5 right
  text "Mode:", 520, 276 137 37 8, tab 5 right
  text "", 521, 314 151 39 8, tab 5
  text "", 522, 314 137 39 8, tab 5
  edit "", 523, 303 64 50 10, tab 5 autohs
  button "Bans list", 524, 315 74 38 10, tab 5
  text "Ping flux:", 526, 276 175 37 8, tab 5 right
  text "", 527, 314 175 39 8, tab 5
  text "Game time:", 528, 276 159 37 8, tab 5 right
  text "", 529, 314 159 39 8, tab 5
  button "!", 530, 266 180 7 10, disable tab 5
  button "Private chat", 531, 315 94 38 10, disable tab 5
  text "Game:", 532, 276 129 37 8, tab 5 right
  text "", 533, 314 129 39 8, tab 5
  text "Weather:", 534, 276 167 37 8, tab 5 right
  text "", 535, 314 167 39 8, tab 5
  button "Map", 536, 315 84 38 10, disable tab 5
  button "Statistics", 537, 315 104 38 10, disable tab 5
  button "Slap", 538, 276 104 38 10, disable tab 5
  text "ID-Score/Money-Name", 539, 2 14 57 8, tab 5 center
  text "Client port:", 540, 274 34 29 8, tab 5 right
  edit "", 541, 303 34 50 10, tab 5
  text "Submode:", 518, 276 144 37 8, tab 5 right
  text "", 525, 314 144 39 8, tab 5
  text "Server:", 542, 276 114 77 8, tab 5 center
  text "", 543, 276 122 77 8, tab 5
  tab "Server 6", 6, -1 -3 356 195
  list 601, 2 22 58 168, tab 6 size vsbar
  edit "", 602, 62 14 212 164, tab 6 read multi autovs vsbar
  combo 603, 62 180 182 50, tab 6 size edit drop
  text "Host / IP:", 604, 274 14 29 8, tab 6 right
  text "Admin port:", 605, 274 24 29 8, tab 6 right
  text "Password:", 606, 274 44 29 8, tab 6 right
  text "Nickname:", 607, 274 54 29 8, tab 6 right
  button "Connect", 608, 276 74 38 10, tab 6
  edit "", 609, 303 14 50 10, tab 6 autohs
  edit "", 610, 303 24 50 10, tab 6
  edit "", 611, 303 44 50 10, tab 6 pass autohs
  edit "", 612, 303 54 50 10, tab 6 autohs
  text "Notes:", 613, 274 64 29 8, tab 6 right
  button "Send", 614, 246 180 19 10, tab 6
  button "Kick", 615, 276 84 38 10, disable tab 6
  button "Ban", 616, 276 94 38 10, disable tab 6
  text "Copyright  2005 by Aeron", 617, 276 183 77 8, disable tab 6 center
  text "Players:", 619, 276 151 37 8, tab 6 right
  text "Mode:", 620, 276 137 37 8, tab 6 right
  text "", 621, 314 151 39 8, tab 6
  text "", 622, 314 137 39 8, tab 6
  edit "", 623, 303 64 50 10, tab 6 autohs
  button "Bans list", 624, 315 74 38 10, tab 6
  text "Ping flux:", 626, 276 175 37 8, tab 6 right
  text "", 627, 314 175 39 8, tab 6
  text "Game time:", 628, 276 159 37 8, tab 6 right
  text "", 629, 314 159 39 8, tab 6
  button "!", 630, 266 180 7 10, disable tab 6
  button "Private chat", 631, 315 94 38 10, disable tab 6
  text "Game:", 632, 276 129 37 8, tab 6 right
  text "", 633, 314 129 39 8, tab 6
  text "Weather:", 634, 276 167 37 8, tab 6 right
  text "", 635, 314 167 39 8, tab 6
  button "Map", 636, 315 84 38 10, disable tab 6
  button "Statistics", 637, 315 104 38 10, disable tab 6
  button "Slap", 638, 276 104 38 10, disable tab 6
  text "ID-Score/Money-Name", 639, 2 14 57 8, tab 6 center
  text "Client port:", 640, 274 34 29 8, tab 6 right
  edit "", 641, 303 34 50 10, tab 6
  text "Submode:", 618, 276 144 37 8, tab 6 right
  text "", 625, 314 144 39 8, tab 6
  text "Server:", 642, 276 114 77 8, tab 6 center
  text "", 643, 276 122 77 8, tab 6
  tab "Server 7", 7, -1 -3 356 195
  list 701, 2 22 58 168, tab 7 size vsbar
  edit "", 702, 62 14 212 164, tab 7 read multi autovs vsbar
  combo 703, 62 180 182 50, tab 7 size edit drop
  text "Host / IP:", 704, 274 14 29 8, tab 7 right
  text "Admin port:", 705, 274 24 29 8, tab 7 right
  text "Password:", 706, 274 44 29 8, tab 7 right
  text "Nickname:", 707, 274 54 29 8, tab 7 right
  button "Connect", 708, 276 74 38 10, tab 7
  edit "", 709, 303 14 50 10, tab 7 autohs
  edit "", 710, 303 24 50 10, tab 7
  edit "", 711, 303 44 50 10, tab 7 pass autohs
  edit "", 712, 303 54 50 10, tab 7 autohs
  text "Notes:", 713, 274 64 29 8, tab 7 right
  button "Send", 714, 246 180 19 10, tab 7
  button "Kick", 715, 276 84 38 10, disable tab 7
  button "Ban", 716, 276 94 38 10, disable tab 7
  text "Copyright  2005 by Aeron", 717, 276 183 77 8, disable tab 7 center
  text "Players:", 719, 276 151 37 8, tab 7 right
  text "Mode:", 720, 276 137 37 8, tab 7 right
  text "", 721, 314 151 39 8, tab 7
  text "", 722, 314 137 39 8, tab 7
  edit "", 723, 303 64 50 10, tab 7 autohs
  button "Bans list", 724, 315 74 38 10, tab 7
  text "Ping flux:", 726, 276 175 37 8, tab 7 right
  text "", 727, 314 175 39 8, tab 7
  text "Game time:", 728, 276 159 37 8, tab 7 right
  text "", 729, 314 159 39 8, tab 7
  button "!", 730, 266 180 7 10, disable tab 7
  button "Private chat", 731, 315 94 38 10, disable tab 7
  text "Game:", 732, 276 129 37 8, tab 7 right
  text "", 733, 314 129 39 8, tab 7
  text "Weather:", 734, 276 167 37 8, tab 7 right
  text "", 735, 314 167 39 8, tab 7
  button "Map", 736, 315 84 38 10, disable tab 7
  button "Statistics", 737, 315 104 38 10, disable tab 7
  button "Slap", 738, 276 104 38 10, disable tab 7
  text "ID-Score/Money-Name", 739, 2 14 57 8, tab 7 center
  text "Client port:", 740, 274 34 29 8, tab 7 right
  edit "", 741, 303 34 50 10, tab 7
  text "Submode:", 718, 276 144 37 8, tab 7 right
  text "", 725, 314 144 39 8, tab 7
  text "Server:", 742, 276 114 77 8, tab 7 center
  text "", 743, 276 122 77 8, tab 7
  tab "Server 8", 8, -1 -3 356 195
  list 801, 2 22 58 168, tab 8 size vsbar
  edit "", 802, 62 14 212 164, tab 8 read multi autovs vsbar
  combo 803, 62 180 182 50, tab 8 size edit drop
  text "Host / IP:", 804, 274 14 29 8, tab 8 right
  text "Admin port:", 805, 274 24 29 8, tab 8 right
  text "Password:", 806, 274 44 29 8, tab 8 right
  text "Nickname:", 807, 274 54 29 8, tab 8 right
  button "Connect", 808, 276 74 38 10, tab 8
  edit "", 809, 303 14 50 10, tab 8 autohs
  edit "", 810, 303 24 50 10, tab 8
  edit "", 811, 303 44 50 10, tab 8 pass autohs
  edit "", 812, 303 54 50 10, tab 8 autohs
  text "Notes:", 813, 274 64 29 8, tab 8 right
  button "Send", 814, 246 180 19 10, tab 8
  button "Kick", 815, 276 84 38 10, disable tab 8
  button "Ban", 816, 276 94 38 10, disable tab 8
  text "Copyright  2005 by Aeron", 817, 276 183 77 8, disable tab 8 center
  text "Players:", 819, 276 151 37 8, tab 8 right
  text "Mode:", 820, 276 137 37 8, tab 8 right
  text "", 821, 314 151 39 8, tab 8
  text "", 822, 314 137 39 8, tab 8
  edit "", 823, 303 64 50 10, tab 8 autohs
  button "Bans list", 824, 315 74 38 10, tab 8
  text "Ping flux:", 826, 276 175 37 8, tab 8 right
  text "", 827, 314 175 39 8, tab 8
  text "Game time:", 828, 276 159 37 8, tab 8 right
  text "", 829, 314 159 39 8, tab 8
  button "!", 830, 266 180 7 10, disable tab 8
  button "Private chat", 831, 315 94 38 10, disable tab 8
  text "Game:", 832, 276 129 37 8, tab 8 right
  text "", 833, 314 129 39 8, tab 8
  text "Weather:", 834, 276 167 37 8, tab 8 right
  text "", 835, 314 167 39 8, tab 8
  button "Map", 836, 315 84 38 10, disable tab 8
  button "Statistics", 837, 315 104 38 10, disable tab 8
  button "Slap", 838, 276 104 38 10, disable tab 8
  text "ID-Score/Money-Name", 839, 2 14 57 8, tab 8 center
  text "Client port:", 840, 274 34 29 8, tab 8 right
  edit "", 841, 303 34 50 10, tab 8
  text "Submode:", 818, 276 144 37 8, tab 8 right
  text "", 825, 314 144 39 8, tab 8
  text "Server:", 842, 276 114 77 8, tab 8 center
  text "", 843, 276 122 77 8, tab 8
  menu "&General", 9
  item "&Options...", 10, 9
  item "&Scripts...", 11, 9
  item "S&erver setup...", 12, 9
  item break, 36, 9
  item "&Check updates", 36, 9
  item "&View MTA-MOTD", 18, 9
  item break, 20, 9
  item "&Exit", 21, 9
  menu "&Server", 17
  item "&Options...", 19, 17
  item "&Bans list...", 38, 17
  item "&Map...", 39, 17
  item break, 37, 17
  item "&Join game", 13, 17
  item "&View MOTD", 16, 17
  menu "&Player", 29
  item "&Private chat...", 30, 29
  item "S&tatistics...", 31, 29
  item break, 32, 29
  item "&Slap", 33, 29
  item "&Kick", 34, 29
  item "&Ban", 35, 29
  menu "&Help", 14
  item "&Scripting", 22, 14
  item "&Manual", 23, 14
  item "&Forum", 24, 14
  item break, 28, 14
  item "MTA:mA &website", 25, 14
  item "MTA w&ebsite", 26, 14
  item "&Email", 28, 14
  item break, 27, 14
  item "&About MTA:mA...", 15, 14
}
on *:DIALOG:mta:edit:*:if (*03 iswm $did) !did -t mta $left($did,1) $+ 14
on *:DIALOG:mta:init:0:{
  if ($readini($scriptdirmta.ini,0,pos)) && ($readini($scriptdirmta.ini,0,Pmta)) !dialog -s mta $v1 $dialog(mta).cw $dialog(mta).ch
  var %a = 1
  while (%a < 9) {
    !did -a mta %a $+ 09 $readini($scriptdirmta.ini,%a,host)
    !did -a mta %a $+ 10 $readini($scriptdirmta.ini,%a,port)
    !did -a mta %a $+ 41 $readini($scriptdirmta.ini,%a,cport)
    !did -a mta %a $+ 11 $readini($scriptdirmta.ini,%a,pass)
    !did -a mta %a $+ 12 $readini($scriptdirmta.ini,%a,nick)
    !did -a mta %a $+ 23 $readini($scriptdirmta.ini,%a,note)
    !inc %a
  }
  !did -b mta 30,31,33,34,35
}
on *:DIALOG:mta:close:0: {
  if ($dialog(mta).x != -32000) !writeini -n " $+ $scriptdirmta.ini" 0 Pmta $dialog(mta).x $dialog(mta).y
  mta.close
}
on *:DIALOG:mta:menu:*:{
  var %a = $dialog(mta).tab
  if ((10 == $did) && (!$dialog(mta.options))) !dialog -ma mta.options mta.options
  elseif ((19 == $did) && (!$dialog(mta.options2))) !dialog -ma mta.options2 mta.options2
  elseif (11 == $did) && (!$dialog(mta.scripts)) !dialog -ma mta.scripts mta.scripts
  elseif (12 == $did) && (!$dialog(mta.server)) {
    if (!$exists($readini($scriptdirmta.ini,0,sdir) $+ MTAServer.exe)) %b = $input(Dir to 'MTAServer.exe' invalid!,uowd,MTA:mA)
    else !dialog -ma mta.server mta.server
  }
  elseif (13 == $did) && ($input(Are you sure to join this game?,uyqd,MTA:mA)) {
    if (!$exists($readini($scriptdirmta.ini,0,cdir) $+ MTAPH.exe)) %b = $input(Dir to 'MTAPH.exe' invalid!,uowd,MTA:mA)
    else !run -p $+(",$readini($scriptdirmta.ini,0,cdir) $+ MTAPH.exe,") $+(+,$did(mta,$dialog(mta).tab $+ 09),:,$did(mta,$dialog(mta).tab $+ 41))
  }
  elseif (15 == $did) !halt $input($+($dialog(mta).title,$crlf,$crlf,Special thanks:,$crlf,MTA Team,$crlf,[FMJ]Oli,$crlf,Regulars of #mta),uotd,MTA:mA)
  elseif (16 == $did) {
    %a = $+($scriptdir,$dialog(mta).tab,.rtf)
    if ($exists(%a)) !run %a
    else !halt $input(ERROR: No MOTD file for server $dialog(mta).tab $+ .,uohd,MTA:mA)
  }
  elseif (18 == $did) {
    if ($exists($scriptdir0.rtf)) !run $scriptdir0.rtf
    else !halt $input(ERROR: No MTA-MOTD file.,uohd,MTA:mA)
  }
  elseif (21 == $did) !dialog -c mta
  elseif (22 == $did) !run " $+ $scriptdirscripting.html"
  elseif (23 == $did) !run " $+ $scriptdirmanual.txt"
  elseif (24 == $did) !run http://forum.mtavc.com/viewforum.php?f=30
  elseif (25 == $did) !run http://home.deds.nl/~aeron/
  elseif (26 == $did) !run http://www.mtavc.com
  elseif (28 == $did) !run mailto:mtama_help@hotmail.com
  elseif (30 == $did) {
    %b = $+(mta.pm.,%a,.,$gettok($did(mta,%a $+ 01).seltext,1,32))
    if (!$did(mta,%a $+ 01).seltext) %b = $input(No nickname selected!,uowd,MTA:mA)
    elseif (!$dialog(%b)) !dialog -ma %b mta.pm
  }
  elseif (31 == $did)  && (!$dialog(mta.statistics)) {
    if (!$did(mta,%a $+ 01).seltext) %b = $input(No nickname selected!,uowd,MTA:mA)
    else {
      !dialog -ma mta.statistics mta.statistics
      !.timermta.statistics 0 1 mta.statistics
    }
  }
  elseif (33 == $did) {
    if (!$did(mta,%a $+ 01).seltext) %b = $input(No nickname selected!,uowd,MTA:mA)
    else !dll " $+ $scriptdirmta.dll" say %a /slap $mta.name(%a,$gettok($did(mta,%a $+ 01).seltext,1,32))
  }
  elseif (34 == $did) {
    if (!$did(mta,%a $+ 01).seltext) %b = $input(No nickname selected!,uowd,MTA:mA)
    else !dll " $+ $scriptdirmta.dll" kick %a $gettok($did(mta,%a $+ 01).seltext,1,32)
  }
  elseif (35 == $did) {
    if (!$did(mta,%a $+ 01).seltext) %b = $input(No nickname selected!,uowd,MTA:mA)
    elseif ($input(Are you sure to ban $gettok($did(mta,%a $+ 01).seltext,3-,32) ?,uyqd,MTA:mA)) !dll " $+ $scriptdirmta.dll" ban %a $gettok($did(mta,%a $+ 01).seltext,1,32)
  }
  elseif (36 == $did) {
    mta.update
    mta.black
  }
  elseif (38 == $did) && (!$dialog(mta.banslist)) !dialog -ma mta.banslist mta.banslist
  elseif (39 == $did) {
    if (!$hget(mta.map)) !hmake mta.map 5
    !hadd mta.map x 0
    !hadd mta.map y 0
    !hadd mta.map p 560
    !hadd mta.map z 0
    !hadd mta.map s %a
    if ($window(@Map)) {
      !window -a @Map
      mta.map %a
      !.timermta.map 0 1 mta.map
    }
    else {
      !window -aBdhk0pf $+ $iif($readini($scriptdirmta.ini,0,top),o) $+ $iif((!$readini($scriptdirmta.ini,0,pos)) || (!$readini($scriptdirmta.ini,0,Pmta.map)),C) +nt @Map $iif($readini($scriptdirmta.ini,0,Pmta.map),$v1,1 1) 560 560 " $+ $scriptdirmta.ico"
      mta.map %a
      !.timermta.map 0 1 mta.map
    }
  }
}
on *:DIALOG:mta:sclick:*:{
  var %a = $left($did,1),%b
  if (*01 iswm $did) && ($dialog(mta.banslist)) {
    %b = $gettok($did(mta,%a $+ 01).seltext,1,32)
    !did -o mta.banslist 1 0 $mta.ip(%a,%b) $mta.name(%a,%b)
  }
  elseif (*08 iswm $did) {
    if ($did(mta,%a $+ 08) == Connect) mta.con %a
    else mta.dis %a User.
  }
  elseif (*14 iswm $did) && ($did(mta,%a $+ 03)) {
    !tokenize 32 $did(mta,%a $+ 03)
    if (/* iswm $did(mta,%a $+ 03)) {
      if ($1 == /me) mta.say %a $1-
      elseif ($1 == /slap) mta.say %a /slap $iif($2 isnum,$mta.name(%a,$2),$2) $3-
      elseif ($1 == /msg) mta.say %a /msg $iif($2 isnum,$mta.name(%a,$2),$2) $3-
      elseif ($1 == /close) { mta.close | !halt }
      elseif ($1 == /update) mta.update
      elseif ($1 == /con) mta.con %a
      elseif ($1 == /dis) mta.dis %a
      elseif ($1 == /clear) !did -ra mta %a $+ 02 * Cleared.
      elseif ($1 == /black) mta.black
      else mta.log %a * $+(',$1,') unknown command.
    }
    elseif ($did(mta,%a $+ 08) == Connect) mta.log %a * You are not connected.
    else mta.say %a $iif($readini($scriptdirmta.ini,0,nick),$did(mta,%a $+ 12) $+ :) $1-
    !did -i mta %a $+ 03 1 $did(mta,%a $+ 03)
    !did -d mta %a $+ 03 0
  }
  elseif (*15 iswm $did) {
    if (!$did(mta,%a $+ 01).seltext) %b = $input(No nickname selected!,uowd,MTA:mA)
    else !dll " $+ $scriptdirmta.dll" kick %a $gettok($did(mta,%a $+ 01).seltext,1,32)
  }
  elseif (*16 iswm $did) {
    if (!$did(mta,%a $+ 01).seltext) %b = $input(No nickname selected!,uowd,MTA:mA)
    elseif ($input(Are you sure to ban $gettok($did(mta,%a $+ 01).seltext,3-,32) ?,uyqd,MTA:mA)) !dll " $+ $scriptdirmta.dll" ban %a $gettok($did(mta,%a $+ 01).seltext,1,32)
  }
  elseif (*24 iswm $did) && (!$dialog(mta.banslist)) !dialog -ma mta.banslist mta.banslist
  elseif (*30 iswm $did) {
    mta.say %a /me $did(mta,%a $+ 03)
    !did -i mta %a $+ 03 1 /me $did(mta,%a $+ 03)
    !did -d mta %a $+ 03 0
  }
  elseif (*31 iswm $did) {
    %b = $+(mta.pm.,%a,.,$gettok($did(mta,%a $+ 01).seltext,1,32))
    if (!$did(mta,%a $+ 01).seltext) %b = $input(No nickname selected!,uowd,MTA:mA)
    elseif (!$dialog(%b)) !dialog -ma %b mta.pm
  }
  elseif (*36 iswm $did) {
    if (!$hget(mta.map)) !hmake mta.map 5
    !hadd mta.map x 0
    !hadd mta.map y 0
    !hadd mta.map p 560
    !hadd mta.map z 0
    !hadd mta.map s %a
    if ($window(@Map)) {
      !window -a @Map
      mta.map %a
      !.timermta.map 0 1 mta.map
    }
    else {
      !window -aBdhk0pf $+ $iif($readini($scriptdirmta.ini,0,top),o) $+ $iif((!$readini($scriptdirmta.ini,0,pos)) || (!$readini($scriptdirmta.ini,0,Pmta.map)),C) +nt @Map $iif($readini($scriptdirmta.ini,0,Pmta.map),$v1,1 1) 560 560 " $+ $scriptdirmta.ico"
      mta.map %a
      !.timermta.map 0 1 mta.map
    }
  }
  elseif (*37 iswm $did) && (!$dialog(mta.statistics)) {
    if (!$did(mta,%a $+ 01).seltext) %b = $input(No nickname selected!,uowd,MTA:mA)
    else {
      !dialog -ma mta.statistics mta.statistics
      !.timermta.statistics 0 1 mta.statistics
    }
  }
  elseif (*38 iswm $did) {
    if (!$did(mta,%a $+ 01).seltext) %b = $input(No nickname selected!,uowd,MTA:mA)
    else !dll " $+ $scriptdirmta.dll" say %a /slap $mta.name(%a,$gettok($did(mta,%a $+ 01).seltext,1,32))
  }
}
on *:DIALOG:mta:dclick:*: {
  if (*01 iswm $did) && (!$dialog(mta.statistics)) {
    !dialog -ma mta.statistics mta.statistics
    !.timermta.statistics 0 1 mta.statistics
  }
}
alias -l map.zoom {
  if ($1 == in) && ($hget(mta.map,z) != 3) {
    !hadd mta.map x $calc($hget(mta.map,x) + $round($calc($2 /2^ $hget(mta.map,z)),0) - $hget(mta.map,p) /4)
    !hadd mta.map y $calc($hget(mta.map,y) + $round($calc($3 /2^ $hget(mta.map,z)),0) - $hget(mta.map,p) /4)
    !hadd mta.map p $calc($hget(mta.map,p) /2)
    !hadd mta.map z $calc($hget(mta.map,z) +1)
  }
  elseif ($1 == out) && ($hget(mta.map,z) != 0) {
    !hadd mta.map x $calc($hget(mta.map,x) + $round($calc($2 /2^ $hget(mta.map,z)),0) - $hget(mta.map,p))
    !hadd mta.map y $calc($hget(mta.map,y) + $round($calc($3 /2^ $hget(mta.map,z)),0) - $hget(mta.map,p))
    !hadd mta.map p $calc($hget(mta.map,p) *2)
    !hadd mta.map z $calc($hget(mta.map,z) -1)
  }
  elseif ($1 == reset) {
    !hadd mta.map x 0
    !hadd mta.map y 0
    !hadd mta.map p 560
    !hadd mta.map z 0
  }
  elseif ($1 == left) !hadd mta.map x $calc($hget(mta.map,x) -10)
  elseif ($1 == right) !hadd mta.map x $calc($hget(mta.map,x) +10)
  elseif ($1 == up) !hadd mta.map y $calc($hget(mta.map,y) -10)
  elseif ($1 == down) !hadd mta.map y $calc($hget(mta.map,y) +10)
  if ($hget(mta.map,x) < 0) !hadd mta.map x 0
  if ($hget(mta.map,y) < 0) !hadd mta.map y 0
  if ($calc($hget(mta.map,x) + $hget(mta.map,p)) > 560) !hadd mta.map x $calc(560- $hget(mta.map,p))
  if ($calc($hget(mta.map,y) + $hget(mta.map,p)) > 560) !hadd mta.map y $calc(560- $hget(mta.map,p))
  mta.map
}
alias -l mta.map {
  if ($window(@Map)) {
    !titlebar @Map - Server: $hget(mta.map,s) - Zoom: $calc(2^ $hget(mta.map,z)) $+ x
    !drawpic -mnsc @Map 0 0 560 560 $hget(mta.map,x) $hget(mta.map,y) $hget(mta.map,p) $hget(mta.map,p) $+(",$scriptdir,$iif($did(mta,$hget(mta.map,s) $+ 33) == GTA:3,map_3.bmp,map_vc.bmp),")
    var %a = 0,%b,%c,%d,%e,%f,%g = $did(mta,$hget(mta.map,s) $+ 22)
    if (%g == Deathmatch) {
      %e = 11 12 13 50
      %f = 8421376 128 16711935 32768 65535 16776960
    }
    elseif (%g == Stunt) {
      %e = 51 52 53 54 55
      %f = 65535 8421376 128 16711935 32768 65535 16776960
    }
    elseif (%g == Portland) {
      %e = 12 35 41
    }
    elseif (%g == Shoreside Vale) {
      %e = 36 37 42
      %f = 32768 8388736 128 8388608
    }
    while (%a < 32) {
      if (. isin $dll($scriptdirmta.dll,location,$hget(mta.map,s) %a)) && ($ini($+($scriptdir,$hget(mta.map,s),.ini),ID $+ %a)) {
        %d = 12
        if ($dll($scriptdirmta.dll,vehicle,$hget(mta.map,s) %a)) %d = 6
        if ($findtok(%e,$v1,32)) %d = 10
        if (!$dll($scriptdirmta.dll,health,$hget(mta.map,s) %a)) %d = 7
        if ($gettok($did(mta,$hget(mta.map,s) $+ 01).seltext,1,32) == %a) %d = 9
        %b = $calc((($dll($scriptdirmta.dll,location,$hget(mta.map,s) %a x)+$iif($did(mta,$hget(mta.map,s) $+ 33) == GTA:3,1950,2350))*0.1433333333 - $hget(mta.map,x))*2^ $hget(mta.map,z) +3)
        %c = $calc((((0-$dll($scriptdirmta.dll,location,$hget(mta.map,s) %a y))+1950)*0.1433333333 - $hget(mta.map,y))*2^ $hget(mta.map,z) +3)
        !drawtext -n @Map %d Arial 10 %b %c $mta.name($hget(mta.map,s),%a)
        !drawdot -nr @Map $iif($gettok(%f,$readini($+($scriptdir,$hget(mta.map,s),.ini),ID $+ %a,skin),32) == $null,255,$v1) 3 %b %c
      }
      !inc %a
    }
    !drawpic @Map
  }
  else !.timermta.map off
}
menu @Map {
  sclick:map.zoom in $mouse.x $mouse.y
  rclick:map.zoom out $mouse.x $mouse.y
  dclick:map.zoom reset
}
on *:KEYDOWN:@Map:37:map.zoom left
on *:KEYDOWN:@Map:38:map.zoom up
on *:KEYDOWN:@Map:39:map.zoom right
on *:KEYDOWN:@Map:40:map.zoom down
on *:CLOSE:@Map:{
  !hfree mta.map
  if ($window(@Map).x != -32000) !writeini -n " $+ $scriptdirmta.ini" 0 Pmta.map $window(@Map).x $window(@Map).y
}
dialog -l mta.options {
  title "Options"
  size -1 -1 172 116
  option dbu
  icon $scriptdirmta.ico, 0
  button "Close", 5, 128 102 43 12, ok
  check "Auto startup with mIRC", 6, 2 0 84 10
  check "Check for updates on start up", 9, 2 10 84 10
  check "Auto reconnect on timeout", 11, 2 20 84 10
  check "Clear screen on connect", 12, 2 30 84 10
  check "Show IP's on join / part", 13, 88 0 84 10
  check "Timestamps", 14, 88 10 84 10
  text "Timestamp format:", 15, 0 102 47 8, right
  edit "", 16, 48 102 78 10
  check "Include nickname in messages", 27, 88 20 84 10
  check "Always on top", 28, 88 30 84 10
  check "Remember window positions", 32, 88 40 84 10
  check "Show on desktop", 35, 88 50 84 10
  check "Silent DNS", 36, 2 40 84 10
  check "Auto open PM-dialogs on PM", 37, 2 50 84 10
  check "Auto join on server start", 38, 88 60 84 10
  text "MTA PH dir:", 39, 0 80 47 8, right
  text "MTA Server dir:", 40, 0 90 47 8, right
  button "Browse", 41, 48 80 123 10
  button "Browse", 42, 48 90 123 10
  check "Enable PunkCatcher's Blacklist", 43, 2 60 84 10
  check "Include admin type in '!info'", 44, 88 70 84 10
  check "Notify random weather change", 1, 2 70 84 10
}
on *:DIALOG:mta.options:sclick:*:{
  if ($did == 41) && ($sdir($did(mta.options,41),Select MTA PH dir)) !did -a mta.options 41 $v1
  elseif ($did == 42) && ($sdir($did(mta.options,42),Select MTA Server dir)) !did -a mta.options 42 $v1
}
on *:DIALOG:mta.options:init:0:{
  if ($readini($scriptdirmta.ini,0,pos)) && ($readini($scriptdirmta.ini,0,Pmta.options)) !dialog -s mta.options $v1 $dialog(mta.options).cw $dialog(mta.options).ch
  !did -c mta.options 9,12,35,37,43,44,1
  if ($readini($scriptdirmta.ini,0,auto)) !did -c mta.options 6
  if ($readini($scriptdirmta.ini,0,update) == 0) !did -u mta.options 9
  if ($readini($scriptdirmta.ini,0,to)) !did -c mta.options 11
  if ($readini($scriptdirmta.ini,0,clear) == 0) !did -u mta.options 12
  if ($readini($scriptdirmta.ini,0,ip)) !did -c mta.options 13
  if ($readini($scriptdirmta.ini,0,timel)) !did -c mta.options 14
  if ($readini($scriptdirmta.ini,0,nick)) !did -c mta.options 27
  if ($readini($scriptdirmta.ini,0,top)) !did -c mta.options 28
  if ($readini($scriptdirmta.ini,0,pos)) !did -c mta.options 32
  if ($readini($scriptdirmta.ini,0,desktop) == 0) !did -u mta.options 35
  if ($readini($scriptdirmta.ini,0,dns)) !did -c mta.options 36
  if ($readini($scriptdirmta.ini,0,pm) == 0) !did -u mta.options 37
  if ($readini($scriptdirmta.ini,0,server)) !did -c mta.options 38
  if ($readini($scriptdirmta.ini,0,cdir) != $null) !did -a mta.options 41 $v1
  if ($readini($scriptdirmta.ini,0,sdir) != $null) !did -a mta.options 42 $v1
  if ($readini($scriptdirmta.ini,0,black) == 0) !did -u mta.options 43
  if ($readini($scriptdirmta.ini,0,type) == 0) !did -u mta.options 44
  if ($readini($scriptdirmta.ini,0,weather) == 0) !did -u mta.options 1
  !did -a mta.options 16 $iif($readini($scriptdirmta.ini,0,times),$v1,$timestampfmt)
}
on *:DIALOG:mta.options:close:0:{
  !writeini -n " $+ $scriptdirmta.ini" 0 Pmta.options $dialog(mta.options).x $dialog(mta.options).y
  var %a = !writeini -n " $+ $scriptdirmta.ini"
  %a 0 auto $did(mta.options,6).state
  %a 0 update $did(mta.options,9).state
  %a 0 to $did(mta.options,11).state
  %a 0 clear $did(mta.options,12).state
  %a 0 ip $did(mta.options,13).state
  %a 0 timel $did(mta.options,14).state
  %a 0 times $$did(mta.options,16)
  %a 0 nick $did(mta.options,27).state
  %a 0 top $did(mta.options,28).state
  %a 0 pos $did(mta.options,32).state
  %a 0 desktop $did(mta.options,35).state
  %a 0 dns $did(mta.options,36).state
  %a 0 pm $did(mta.options,37).state
  %a 0 server $did(mta.options,38).state
  %a 0 cdir $did(mta.options,41)
  %a 0 sdir $did(mta.options,42)
  %a 0 black $did(mta.options,43).state
  %a 0 type $did(mta.options,44).state
  %a 0 weather $did(mta.options,1).state
  !dialog $iif($did(mta.options,28).state,-o,-n) mta
  if ($window(@Map)) !window $iif($did(mta.options,28).state,-o,-u) @Map
}
dialog -l mta.options2 {
  title ""
  size -1 -1 98 92
  option dbu
  icon $scriptdirmta.ico, 0
  check "Enable logging", 1, 2 0 46 10
  check "Auto connect", 2, 50 10 44 10
  button "Close", 5, 50 78 47 12, ok
  button "Refresh MOTD", 8, 2 42 47 12
  button "Set password", 10, 2 54 47 12
  button "Shutdown", 7, 50 54 47 12
  button "Reset scores", 17, 2 30 47 12
  button "Set game time", 18, 50 42 47 12
  button "Reset money", 19, 50 30 47 12
  combo 20, 2 67 47 50, size drop
  button "Set weather", 21, 50 66 47 12
  check "Admin+", 22, 50 0 42 10
  check "Enable scripts", 23, 2 10 42 10
  check "PunkCatcher v0.7", 33, 2 20 90 10
  button "Set MOTD", 3, 2 78 47 12, disable
}
on *:DIALOG:mta.options2:sclick:*:{
  var %a = $right($dialog(mta.options2).title,1),%b
  if ($did == 3) {
    %b = $input(Enter new MOTD:,uoqe,MTA:mA)
    if (%b != $null) {
      !dll " $+ $scriptdirmta.dll" setmotd %a %b
      mta.log %a * MOTD: Set to $+(",%b,".)
    }
  }
  elseif ($did == 7) && ($input(Are you sure to shutdown server $chr(35) $+ %a ?,uyqd,MTA:mA)) !dll " $+ $scriptdirmta.dll" shutdown %a
  elseif ($did == 8) !dll " $+ $scriptdirmta.dll" motd %a
  elseif ($did == 10) {
    %b = $input(Enter new password (Leave empty for removal):,uoqe,MTA:mA)
    if ($len(%b) > 32) %b = $input(Invalid password! Maximum length is 32.,uowd,MTA:mA)
    else !dll " $+ $scriptdirmta.dll" setpassword %a %b
  }
  elseif ($did == 17) && ($input(Are you sure to reset the scores of server $chr(35) $+ %a ?,uyqd,MTA:mA)) !dll " $+ $scriptdirmta.dll" resetscores %a
  elseif ($did == 18) mta.settime %a $$input(Give up a time in format "hh:mm",uoqe,MTA:mA,$mta.time(%a))  
  elseif ($did == 19) && ($input(Are you sure to reset the money of players from server $chr(35) $+ %a ?,uyqd,MTA:mA)) !dll " $+ $scriptdirmta.dll" resetmoney %a
  elseif ($did == 21) !dll " $+ $scriptdirmta.dll" setweather %a $calc($didwm(mta.options2,20,$did(mta.options2,20,0),1)-1)
}
on *:DIALOG:mta.options2:init:0:{
  if ($readini($scriptdirmta.ini,0,pos)) && ($readini($scriptdirmta.ini,0,Pmta.options2)) !dialog -s mta.options2 $v1 $dialog(mta.options2).cw $dialog(mta.options2).ch
  var %a = $dialog(mta).tab
  !dialog -t mta.options2 Options - Server: %a
  !didtok mta.options2 20 59 Sun;Cloud;Rain;Fog
  !did -c mta.options2 20 $findtok(Sun;Cloud;Rain;Fog,$did(mta,%a $+ 35),1,59)
  !did -c mta.options2 23
  if ($did(mta,%a $+ 33) == GTA:3) !did -b mta.options2 20,21
  if ($did(mta,%a $+ 08) != Disconnect) !did -b mta.options2 8,7,10,17,18,19,20,21
  if ($readini($scriptdirmta.ini,%a,log)) !did -c mta.options2 1
  if ($readini($scriptdirmta.ini,%a,conn)) !did -c mta.options2 2
  if ($readini($scriptdirmta.ini,%a,admin+)) !did -c mta.options2 22
  if ($readini($scriptdirmta.ini,%a,scripts) == 0) !did -u mta.options2 23
  if ($readini($scriptdirmta.ini,%a,punk)) !did -c mta.options2 33
}
on *:DIALOG:mta.options2:close:0:{
  !writeini -n " $+ $scriptdirmta.ini" 0 Pmta.options2 $dialog(mta.options2).x $dialog(mta.options2).y
  var %a = !writeini -n " $+ $scriptdirmta.ini",%b = $right($dialog(mta.options2).title,1)
  %a %b log $did(mta.options2,1).state
  %a %b conn $did(mta.options2,2).state
  %a %b admin+ $did(mta.options2,22).state
  %a %b scripts $did(mta.options2,23).state
  %a %b punk $did(mta.options2,33).state
}
dialog -l mta.scripts {
  title "Scripts"
  size -1 -1 80 42
  option dbu
  icon $scriptdirmta.ico, 0
  combo 1, 24 2 54 50, size hsbar drop
  button "Close", 2, 41 28 38 12, ok
  text "Loaded:", 3, 2 4 21 8, right
  button "Load", 4, 2 14 25 12
  button "Unload", 5, 54 14 25 12
  button "Event check", 6, 2 28 38 12
  button "Reload", 7, 28 14 25 12
}
on *:DIALOG:mta.scripts:close:0:{
  !writeini -n " $+ $scriptdirmta.ini" 0 Pmta.scripts $dialog(mta.scripts).x $dialog(mta.scripts).y
  var %a = $mta.event
}
on *:DIALOG:mta.scripts:init:0:{
  if ($readini($scriptdirmta.ini,0,pos)) && ($readini($scriptdirmta.ini,0,Pmta.scripts)) !dialog -s mta.scripts $v1 $dialog(mta.scripts).cw $dialog(mta.scripts).ch
  var %a = 2
  while (%a <= $script(0)) {
    !did -a mta.scripts 1 $nopath($script(%a))
    !inc %a
  }
  !did -c mta.scripts 1 1
}
on *:DIALOG:mta.scripts:sclick:4:{
  var %a = $sfile(*.mrc,MTA:mA)
  if (%a) {
    if ($script($nopath(%a)) != %a) {
      !.load -rs $+(",%a,")
      mta.log $dialog(mta).tab * Scripts: $+(",%a,") loaded.
      !did -a mta.scripts 1 $nopath(%a)
      !did -c mta.scripts 1 $did(mta.scripts,1).lines
    }
    else %a = $input($+(',%a,') is already loaded.,uodw,MTA:mA)
  }
}
on *:DIALOG:mta.scripts:sclick:5:{
  var %a = $did(mta.scripts,1).seltext
  if (!%a) %a = $input(No script selected!,uowd,MTA:mA)
  else {
    mta.log $dialog(mta).tab * Scripts: $+(",$script(%a),") unloaded.
    !.unload -rs $+(",$script(%a),")
    if ($didwm(mta.scripts,1,%a,1)) !did -d mta.scripts 1 $v1
    !did -d mta.scripts 1 0
    !did -c mta.scripts 1 1
  }
}
on *:DIALOG:mta.scripts:sclick:6:if (!$mta.event) var %a = $input(No double events found.,uowd,MTA:mA)
alias mta.event {
  var %a
  var %a = 2,%b,%c,%d,%e,%f = $false
  while (%a <= $script(0)) {
    %b = $script(%a)
    %c = 0
    %d = $null
    while ($read(%b,s,on,$calc(1+%c))) {
      %c = $readn
      %e = $gettok($v1,1,32)
      %e = $left(%e,$pos(%e,:,$count(%e,:)))
      if (%e isin %d) %f = $input(Double event 'on %e $+ ' found at line %c in script $+(',%b,'.),uowd,MTA:mA)
      else %d = %d %e
    }
    !inc %a
  }
  !return %f
}
on *:DIALOG:mta.scripts:sclick:7:{
  var %a = $did(mta.scripts,1).seltext
  if (!%a) %a = $input(No script selected!,uowd,MTA:mA)
  else {
    mta.log $dialog(mta).tab * Scripts: $+(",$script(%a),") reloaded.
    !.reload -rs $+(",$script(%a),")
  }
}
dialog -l mta.statistics {
  title "Statistics"
  size -1 -1 82 180
  option dbu
  icon $scriptdirmta.ico, 0
  text "Name:", 1, 0 2 35 8, right
  text "", 2, 36 2 45 8
  text "ID:", 3, 0 10 35 8, right
  text "", 4, 36 10 45 8
  text "Ping:", 5, 0 18 35 8, right
  text "", 6, 36 18 45 8
  text "Score:", 7, 0 26 35 8, right
  text "", 8, 36 26 45 8
  text "Deaths:", 9, 4 128 31 8, right
  text "", 10, 36 128 43 8
  text "Online:", 11, 4 136 31 8, right
  text "", 12, 36 136 43 8
  text "Idle:", 13, 4 144 31 8, right
  text "", 14, 36 144 43 8
  text "Status:", 15, 4 152 31 8, right
  text "", 16, 36 152 43 8
  text "IP:", 17, 0 34 35 8, right
  text "", 18, 36 34 45 8
  button "Close", 19, 23 166 37 12, ok
  box "Since MTA:mA is connected", 20, 2 112 78 52
  text "Passenger:", 21, 0 74 35 8, right
  text "", 22, 36 74 45 8
  text "Vehicle:", 23, 0 58 35 8, right
  text "", 24, 36 58 45 8
  text "Area:", 25, 0 90 35 8, right
  text "", 26, 36 90 45 20
  text "Money:", 27, 0 42 35 8, right
  text "", 28, 36 42 45 8
  text "Health:", 29, 0 50 35 8, right
  text "", 30, 36 50 45 8
  text "Skin:", 31, 0 82 35 8, right
  text "", 32, 36 82 45 8
  text "Vehicle health:", 33, 0 66 35 8, right
  text "", 34, 36 66 45 8
  text "Kills:", 35, 4 120 31 8, right
  text "", 36, 36 120 43 8
}
alias -l mta.statistics {
  if ($dialog(mta.statistics)) {
    var %a = $dialog(mta).tab,%b = $gettok($did(mta,%a $+ 01).seltext,1,32),%c = !did -a mta.statistics
    if (%b == $null) !halt
    %c 2 $mta.name(%a,%b)
    %c 4 %b
    %c 6 $readini($+($scriptdir,%a,.ini),ID $+ %b,ping)
    %c 8 $readini($+($scriptdir,%a,.ini),ID $+ %b,score)
    %c 10 $readini($+($scriptdir,%a,.ini),ID $+ %b,deaths)
    %c 12 $duration($calc(($ticks -$readini($+($scriptdir,%a,.ini),ID $+ %b,online))/1000))
    %c 14 $duration($calc(($ticks -$readini($+($scriptdir,%a,.ini),ID $+ %b,idle))/1000))
    %c 16 $gettok(Unknown;Out game;In game;Unknown;Spectator,$calc($readini($+($scriptdir,%a,.ini),ID $+ %b,status)+1),59)
    %c 18 $mta.ip(%a,%b)
    %c 22 $iif($mta.passenger(%a,%b),Yes,No)
    %c 24 $mta.vehicle(%a,%b).name
    %c 26 $mta.area(%a,%b)
    %c 28 $ $+ $readini($+($scriptdir,%a,.ini),ID $+ %b,money)
    %c 30 $iif($mta.health(%a,%b) isnum,$v1 $+ $chr(37),$v1)
    %c 32 $mta.skin(%a,%b).name
    %c 34 $iif($mta.health(%a,%b).vehicle isnum,$v1 $+ $chr(37),$v1)
    %c 36 $readini($+($scriptdir,%a,.ini),ID $+ %b,kills)
  }
  else !.timermta.statistics off
}
on *:DIALOG:mta.statistics:close:0:!writeini -n " $+ $scriptdirmta.ini" 0 Pmta.statistics $dialog(mta.statistics).x $dialog(mta.statistics).y
on *:DIALOG:mta.statistics:init:0:{
  if ($readini($scriptdirmta.ini,0,pos)) && ($readini($scriptdirmta.ini,0,Pmta.statistics)) !dialog -s mta.statistics $v1 $dialog(mta.statistics).cw $dialog(mta.statistics).ch
  mta.statistics
}
alias -l mta.banslist {
  var %a = $did(mta,$1 $+ 09),%b = $scriptdirmta.bans.ini,%c = $ini(%b,%a,0)
  !did -r mta.banslist 1
  while (%c > 0) {
    !did -a mta.banslist 1 $ini(%b,%a,%c) $readini(%b,%a,$ini(%b,%a,%c))
    !dec %c
  }
}
dialog mta.banslist {
  title "Bans list"
  size -1 -1 212 80
  option dbu
  icon $scriptdirmta.ico, 0
  button "Add", 2, 174 2 37 12
  button "Delete", 3, 174 14 37 12
  button "Close", 5, 174 66 37 12, ok
  text "", 6, 1 4 111 8
  button "Clear", 8, 174 52 37 12
  combo 1, 1 14 172 66, size edit vsbar
  button "Apply", 4, 174 26 37 12
  button "Update", 7, 174 40 37 12
}
on *:DIALOG:mta.banslist:close:0:!writeini -n " $+ $scriptdirmta.ini" 0 Pmta.banslist $dialog(mta.banslist).x $dialog(mta.banslist).y
on *:DIALOG:mta.banslist:init:0:{
  if ($readini($scriptdirmta.ini,0,pos)) && ($readini($scriptdirmta.ini,0,Pmta.banslist)) !dialog -s mta.banslist $v1 $dialog(mta.banslist).cw $dialog(mta.banslist).ch
  var %a = $dialog(mta).tab,%b = $gettok($did(mta,%a $+ 01).seltext,1,32)
  if ($did(mta,%a $+ 08) != Disconnect) !did -b mta.banslist 2,3,7,8
  if (%b != $null) !did -o mta.banslist 1 0 $mta.ip(%a,%b) $mta.name(%a,%b)
  !did -a mta.banslist 6 Server: %a
  mta.banslist %a
}
on *:DIALOG:mta.banslist:sclick:2:{
  var %a = $gettok($did(mta.banslist,6),2,32),%b = $gettok($did(mta.banslist,1,0),1,32)
  if ($mta.checkip(%b)) !dll " $+ $scriptdirmta.dll" addban %a %b $gettok($did(mta.banslist,1,0),2-,32)
  else %a = $input(Invalid IP!,uowd,MTA:mA)
}
on *:DIALOG:mta.banslist:sclick:3:{
  var %a = $gettok($did(mta.banslist,6),2,32),%b = $gettok($did(mta.banslist,1,0),1,32)
  if ($mta.checkip(%b)) !dll " $+ $scriptdirmta.dll" unban %a %b
  else %a = $input(Invalid IP!,uowd,MTA:mA)
}
on *:DIALOG:mta.banslist:sclick:4:{
  var %a = $gettok($did(mta.banslist,6),2,32),%b = $gettok($did(mta.banslist,1,0),1,32),%c = $didwm(mta.banslist,1,%b *,1)
  if (%b == $null) || (%c == 0) %a = $input(Ban not found!,uowd,MTA:mA)
  else {
    !did -o mta.banslist 1 %c $did(mta.banslist,1,0)
    !writeini -n " $+ $scriptdirmta.bans.ini" $sock(mta. $+ %a).saddr $did(mta.banslist,1,0)
  }
}
on *:DIALOG:mta.banslist:sclick:7:{
  !dll " $+ $scriptdirmta.dll" getbans $gettok($did(mta.banslist,6),2,32)
}
on *:DIALOG:mta.banslist:sclick:8:{
  if ($input(Are you sure to clear the bans?,uyqd,MTA:mA)) {
    var %a = $gettok($did(mta.banslist,6),2,32),%b = $scriptdirmta.bans.ini,%c = $did(mta,%a $+ 09),%d = $ini(%b,%c,0)
    while (%d > 0)  {
      !dll " $+ $scriptdirmta.dll" unban %a $ini(%b,%c,%d)
      !dec %d
    }
    !did -r mta.banslist 1
    !remini $+(",%b,") %c
  }
  mta.log %a * Bans list: Cleared.
}
alias mta.black {
  if (!$sock(mta.black)) {
    mta.log $dialog(mta).tab * Blacklist: Checking for updates...
    !sockclose mta.black
    !sockopen mta.black home.deds.nl 80
  }
}
on *:sockopen:mta.black: {
  if (!$sockerr) !sockwrite -n mta.black GET /~aeron/files/mta.blacklist.ini $+(HTTP/1.1,$crlf,Host: home.deds.nl,$crlf,Connection: Close,$crlf,$crlf)
  elseif ($dialog(mta)) mta.log $dialog(mta).tab * Blacklist: Connection problems.
}
on *:sockread:mta.black:{ 
  !sockread &a
  while ($sockbr != 0) {
    !bwrite mta.blacklist.tmp -1 &a
    !sockread &a
  }
}
on *:sockclose:mta.black:{ 
  if ($dialog(mta)) {
    !bread mta.blacklist.tmp 1 $file(mta.blacklist.tmp).size &a
    !bcopy -c &a 1 &a $calc($bfind(&a,1,10 13 10)+3) -1
    !.remove mta.blacklist.tmp
    !bwrite mta.blacklist.tmp 0 &a
    if ($read(mta.blacklist.tmp,1) != [Blacklist]) mta.log $dialog(mta).tab * Blacklist: Invalid blacklist file.
    elseif ($crc(mta.blacklist.tmp) == $crc($scriptdirmta.blacklist.ini)) mta.log $dialog(mta).tab * Blacklist: No updates.
    else {
      !.copy -o mta.blacklist.tmp " $+ $scriptdirmta.blacklist.ini"
      mta.log $dialog(mta).tab * Blacklist: Updated.
    }
    !.remove mta.blacklist.tmp
  }
}
alias mta.update {
  if (!$sock(mta.update)) {
    var %a = $findfile($mircdir,*.tmp,0,1,!.remove " $+ $1-")
    mta.log $dialog(mta).tab * Updater: Checking for updates...
    !sockclose mta.update
    !sockopen mta.update home.deds.nl 80
  }
}
dialog -l mta.update {
  title "Updater"
  size -1 -1 94 98
  option dbu
  icon $scriptdirmta.ico, 0
  button "Yes", 1, 8 84 37 12
  button "No", 2, 52 84 37 12, ok
  edit "", 3, 2 2 90 54, multi return vsbar
  text "Status:", 4, 2 58 19 8
  text "", 5, 22 58 69 14
  box "", 6, 2 70 90 11
  text "", 7, 4 74 86 5
}
on *:sockopen:mta.update: {
  if (!$sockerr) !sockwrite -n mta.update GET /~aeron/files/mta.tmp $+(HTTP/1.1,$crlf,Host: home.deds.nl,$crlf,Connection: Close,$crlf,$crlf)
  elseif ($dialog(mta)) mta.log $dialog(mta).tab * Updater: Connection problems.
}
on *:sockread:mta.update:{ 
  !sockread &a
  while ($sockbr != 0) {
    !bwrite mta.tmp -1 &a
    !sockread &a
  }
}
on *:sockclose:mta.update:{ 
  if ($dialog(mta)) && (!$dialog(mta.update)) {
    !bread mta.tmp 1 $file(mta.tmp).size &a
    !bcopy -c &a 1 &a $calc($bfind(&a,1,10 13 10)+3) -1
    !.remove mta.tmp
    !bwrite mta.tmp 0 &a
    var %a = $read(mta.tmp,2)
    if (%a !isnum) {
      !.remove mta.tmp
      mta.log $dialog(mta).tab * Updater: Invalid update file.
    }
    elseif ($right($gettok($dialog(mta).title,6,32),-1) < %a) {
      mta.log $dialog(mta).tab * Updater: Version %a available.
      !dialog -v mta
      !dialog -ma mta.update mta.update
      !did -m mta.update 3
      !did -a mta.update 5 Download version %a $+ ?
      !loadbuf -o mta.update 3 mta.tmp
    }
    else {
      !.remove mta.tmp
      mta.log $dialog(mta).tab * Updater: No updates.
    }
  }
}
on *:sockopen:mta.dl:{
  if ($sockerr == 0) {
    !tokenize 32 $read(mta.tmp,$sock(mta.dl).mark)
    if ($1 == Fixes:) {
      !did -a mta.update 5 Finished.
      !did -ea mta.update 1 Install
    }
    else {
      !did -a mta.update 5 Downloading " $+ $1"
      !did -r mta.update 7
      !sockwrite -n mta.dl GET /~aeron/files/ $+ $1 $+(HTTP/1.1,$crlf,Host: home.deds.nl,$crlf,Connection: Close,$crlf,$crlf)
    }
  }
  else {
    !did -a mta.update 5 Connection error.
    !did -a mta.update 2 Close
  }
}
on *:sockread:mta.dl:{ 
  !tokenize 32 $read(mta.tmp,$sock(mta.dl).mark)
  !sockread -f &a
  while ($sockbr != 0) {
    !did -a mta.update 7 $str(l,$calc(86/ $2 * $sock(mta.dl).rcvd))
    !bwrite $1.tmp -1 &a
    !sockread -f &a
  }
}
on *:sockclose:mta.dl:{
  !tokenize 32 $read(mta.tmp,$sock(mta.dl).mark)
  !bread $1.tmp 1 $file($1.tmp).size &a
  !bcopy -c &a 1 &a $calc($bfind(&a,1,10 13 10)+3) -1
  !.remove $1.tmp
  !bwrite $1.tmp 0 &a
  if ($crc($1.tmp) != $3) {
    !did -a mta.update 5 CRC mismatch on " $+ $1"
    !did -a mta.update 2 Close
  }
  else !.timer 1 0 mta.dl $calc(1+$sock(mta.dl).mark)
}
alias mta.dl {
  !sockopen mta.dl home.deds.nl 80
  !sockmark mta.dl $1
}
on *:DIALOG:mta.update:close:0:!sockclose mta.dl $findfile($mircdir,*.tmp,0,1,!.remove " $+ $1-")
on *:DIALOG:mta.update:sclick:1:{
  if (Yes == $did(mta.update,1)) {
    !did -a mta.update 5 Connecting...
    !did -b mta.update 1
    !did -a mta.update 2 Cancel
    !sockclose mta.dl
    mta.dl 4
  }
  if (Install == $did(mta.update,1)) {
    !did -a mta.update 5 Installing...
    !dll -u mta.dll
    var %a = 4
    while ($read(mta.tmp,%a) != Fixes:) {
      !tokenize 32 $read(mta.tmp,%a)
      !.copy -o $1.tmp $+(",$scriptdir,$1")
      !inc %a
    }
    mta.close
    !.load -rs $+(",$script,")
  }
}
alias mta.pmlog {
  var %a = $+(mta.pm.,$1,.,$2),%b = $mta.name($1,$2)
  if ($3 == admin) {
    if (!$dialog(%a)) && ($readini($scriptdirmta.ini,0,pm) != 0) {
      !dialog -v mta
      !dialog -ma %a mta.pm
      !dialog -t %a %b
    }
    if ($dialog(%a)) !did -a %a 2 $iif($did(%a,2,$did(%a,2).lines),$crlf $+ %b $+ : $4-,%b $+ : $4-)
  }
}
dialog -l mta.pm {
  title $gettok($did(mta,$dialog(mta).tab $+ 01).seltext,3-,32)
  size -1 -1 108 82
  option dbu
  icon $scriptdirmta.ico, 0
  combo 1, 2 70 84 50, size drop edit
  edit "", 2, 2 2 104 66, read multi return autovs vsbar
  button "Send", 3, 88 70 19 10
}
on *:DIALOG:mta.pm*:edit:1:!did -t $dname 3
on *:DIALOG:mta.pm*:init:0:if ($readini($scriptdirmta.ini,0,pos)) && ($readini($scriptdirmta.ini,0,Pmta.pm)) !dialog -s $dname $v1 $dialog($dname).cw $dialog($dname).ch
on *:DIALOG:mta.pm*:close:0:!writeini -n " $+ $scriptdirmta.ini" 0 Pmta.pm $dialog($dname).x $dialog($dname).y
on *:DIALOG:mta.pm*:sclick:3:{
  var %a = $did($dname,1,0),%b 
  if (%a) {
    %b = $iif($readini($scriptdirmta.ini,0,nick),$did(mta,$gettok($dname,3,46) $+ 12) $+ :) %a
    mta.say $gettok($dname,3,46) /msg $chr(35) $+ $gettok($dname,4,46) %b
    !did -a $dname 2 $iif($did($dname,2,$did($dname,2).lines),$+($crlf,<,%b,>),$+(<,%b,>))
    !did -i $dname 1 1 %a
  }
  !did -d $dname 1 0
}
dialog mta.server {
  title "Server"
  size -1 -1 218 168
  option dbu
  icon $scriptdirmta.ico, 0
  text "* Server name:", 1, 2 4 55 8, right
  edit "", 2, 58 2 50 10, autohs
  text "Game IP address:", 3, 2 14 55 8, right
  edit "", 4, 58 12 50 10
  text "Admin IP address:", 5, 2 24 55 8, right
  edit "", 6, 58 22 50 10
  text "* Game port:", 7, 2 34 55 8, right
  edit "", 8, 58 32 50 10
  text "* Maximum players:", 9, 2 44 55 8, right
  edit "", 10, 58 42 50 10
  text "* Game map:", 11, 2 54 55 8, right
  combo 12, 58 52 50 50, size drop
  text "MOTD URL:", 13, 2 104 55 8, right
  edit "", 14, 58 102 50 10, autohs
  text "* Game hour:", 15, 2 64 55 8, right
  edit "", 16, 58 62 50 10
  text "* Game Minutes:", 17, 2 74 55 8, right
  edit "", 18, 58 72 50 10
  text "Random weather:", 19, 2 84 55 8, right
  check "Enabled", 20, 58 82 50 10
  text "MOTD:", 21, 2 94 55 8, right
  check "Enabled", 22, 58 92 50 10
  text "All Seeing Eye:", 23, 2 114 55 8, right
  check "Enabled", 24, 58 112 50 10
  text "Log file:", 25, 2 124 55 8, right
  button "Browse", 26, 58 122 50 10
  text "* Banned file:", 27, 2 134 55 8, right
  button "Browse", 28, 58 132 50 10
  text "Log chat:", 29, 2 144 55 8, right
  check "Enabled", 30, 58 142 50 10
  text "Logging:", 31, 110 4 55 8, right
  check "Enabled", 32, 166 2 50 10
  text "Server password:", 33, 110 14 55 8, right
  check "Enabled", 34, 166 12 50 10
  text "Server password:", 35, 110 24 55 8, right
  edit "", 36, 166 22 50 10
  text "Admin server:", 37, 110 34 55 8, right
  check "Enabled", 38, 166 32 50 10
  text "Admin+ server:", 39, 110 44 55 8, right
  check "Enabled", 40, 166 42 50 10
  text "Admin password:", 41, 110 64 55 8, right
  edit "", 42, 166 62 50 10
  text "Admin+ password:", 43, 110 74 55 8, right
  edit "", 44, 166 72 50 10
  text "Admin shutdown:", 45, 110 84 55 8, right
  check "Enabled", 46, 166 82 50 10
  text "Max lines per second:", 47, 110 94 55 8, right
  edit "", 48, 166 92 50 10
  text "Ban on chat flood:", 49, 110 104 55 8, right
  check "Enabled", 50, 166 102 50 10
  text "Send limit:", 51, 110 114 55 8, right
  check "Enabled", 52, 166 112 50 10
  text "Send limit:", 53, 110 124 55 8, right
  edit "", 54, 166 122 50 10
  text "Log packet drop:", 55, 110 144 55 8, right
  check "Enabled", 56, 166 142 50 10
  button "Close", 57, 182 154 35 12, ok
  button "MOTD", 58, 146 154 35 12
  text "* = required", 59, 2 156 33 8
  button "Banned file", 60, 110 154 35 12
  button "Start", 61, 38 154 35 12
  text "Admin port:", 62, 110 54 55 8, right
  edit "", 63, 166 52 50 10
  text "Send limit max:", 64, 110 134 55 8, right
  edit "", 65, 166 132 50 10
  button "Log file", 66, 74 154 35 12
}
on *:DIALOG:mta.server:init:0:{
  if ($readini($scriptdirmta.ini,0,pos)) && ($readini($scriptdirmta.ini,0,Pmta.server)) !dialog -s mta.server $v1 $dialog(mta.server).cw $dialog(mta.server).ch
  !didtok mta.server 12 44 GTA:VC Deathmatch,GTA:VC Stunt,GTA:3 Portland,GTA:3 Shoreside Vale,GTA:3 Staunton
  var %a = $readini($scriptdirmta.ini,0,sdir) $+ mtaserver.conf
  !did -a mta.server 2 $remove($read(%a,s,ServerName),")
  !did -a mta.server 4 $remove($read(%a,s,GameIPAddress),")
  !did -a mta.server 6 $remove($read(%a,s,AdminIPAddress),")
  !did -a mta.server 8 $read(%a,s,ServerPort)
  !did -a mta.server 10 $read(%a,s,MaxPlayers)
  !did -c mta.server 12 $read(%a,s,GameMap)
  !did -a mta.server 14 $remove($read(%a,s,MOTDURL),")
  !did -a mta.server 16 $read(%a,s,GameHour)
  !did -a mta.server 18 $read(%a,s,GameMins)
  if ($read(%a,s,RandomWeather)) !did -c mta.server 20
  if ($read(%a,s,MOTDEnabled)) !did -c mta.server 22
  if ($read(%a,s,ASE)) !did -c mta.server 24
  !did -a mta.server 26 $remove($read(%a,s,LogFile),")
  !did -a mta.server 28 $remove($read(%a,s,BannedFile),")
  if ($read(%a,s,DoNotOutputChatToLog)) !did -c mta.server 30
  if ($read(%a,s,StatLogging)) !did -c mta.server 32
  if ($read(%a,s,ServerPasswordEnabled)) !did -c mta.server 34
  !did -a mta.server 36 $remove($read(%a,s,ServerPassword),")
  if ($read(%a,s,AdminServer)) !did -c mta.server 38
  if ($read(%a,s,AdminPlus)) !did -c mta.server 40
  !did -a mta.server 63 $read(%a,s,AdminPort)
  !did -a mta.server 42 $remove($read(%a,s,AdminPassword),")
  !did -a mta.server 44 $remove($read(%a,s,AdminPlusPassword),")
  if ($read(%a,s,AdminAllowShutdown)) !did -c mta.server 46
  !did -a mta.server 48 $read(%a,s,ChatFloodMaxCount)
  if ($read(%a,s,BanOnChatFlood)) !did -c mta.server 50
  if ($read(%a,s,ServerSendLimitEnabled)) !did -c mta.server 52
  !did -a mta.server 54 $read(%a,s,ServerSendLimit)
  !did -a mta.server 65 $read(%a,s,ServerSendLimitMaxAllowed)
  if ($read(%a,s,ServerSendLimitLogDropped)) !did -c mta.server 56
}
on *:DIALOG:mta.server:sclick:26:!did -a mta.server 26 $$input(Enter name for Log file:,uoqe,MTA:mA,$did(mta.server,26))
on *:DIALOG:mta.server:sclick:28:!did -a mta.server 28 $$input(Enter name for Banned file:,uoqe,MTA:mA,$did(mta.server,28))
on *:DIALOG:mta.server:sclick:58:!run notepad $+(",$readini($scriptdirmta.ini,0,sdir),motd.txt")
on *:DIALOG:mta.server:sclick:60:!run notepad $+(",$readini($scriptdirmta.ini,0,sdir),$did(mta.server,28),")
on *:DIALOG:mta.server:sclick:61:{
  !dialog -c mta.server
  !run -p $+(",$readini($scriptdirmta.ini,0,sdir),MTAServer.exe")
  if ($readini($scriptdirmta.ini,0,server)) {
    if (!$exists($readini($scriptdirmta.ini,0,cdir) $+ MTAPH.exe)) %b = $input(Dir to 'MTAPH.exe' invalid!,uowd,MTA:mA)
    else !run -p $+(",$readini($scriptdirmta.ini,0,cdir) $+ MTAPH.exe,") +localhost: $+ $did(mta.server,8)
  }
}
on *:DIALOG:mta.server:sclick:66:!run notepad $+(",$readini($scriptdirmta.ini,0,sdir),$did(mta.server,26),")
on *:DIALOG:mta.server:close:0:{
  mta.save
  !writeini -n " $+ $scriptdirmta.ini" 0 Pmta.server $dialog(mta.server).x $dialog(mta.server).y
}
alias -l mta.save {
  mta.log $dialog(mta).tab * Server setup: Saving config file...
  var %a = $+(",$readini($scriptdirmta.ini,0,sdir),mtaserver.conf,")
  !write -sServerName %a ServerName $+(",$did(mta.server,2),")
  !write -sGameIPAddress %a GameIPAddress $+(",$did(mta.server,4),")
  !write -sAdminIPAddress %a AdminIPAddress $+(",$did(mta.server,6),")
  !write -sServerPort %a ServerPort $did(mta.server,8)
  !write -sMaxPlayers %a MaxPlayers $did(mta.server,10)
  !write -sGameMap %a GameMap $did(mta.server,12).sel
  !write -sMOTDURL %a MOTDURL $+(",$did(mta.server,14),")
  !write -sGameHour %a GameHour $did(mta.server,16)
  !write -sGameMins %a GameMins $did(mta.server,18)
  !write -sRandomWeather %a RandomWeather $did(mta.server,20).state
  !write -sMOTDEnabled %a MOTDEnabled $did(mta.server,22).state
  !write -sASE %a ASE $did(mta.server,24).state
  !write -sLogFile %a LogFile $+(",$did(mta.server,26),")
  !write -sBannedFile %a BannedFile $+(",$did(mta.server,28),")
  !write -sDoNotOutputChatToLog %a DoNotOutputChatToLog $did(mta.server,30).state
  !write -sStatLogging %a StatLogging $did(mta.server,32).state
  !write -sServerPasswordEnabled %a ServerPasswordEnabled $did(mta.server,34).state
  !write -sServerPassword %a ServerPassword $+(",$did(mta.server,36),")
  !write -sAdminServer %a AdminServer $did(mta.server,38).state
  !write -sAdminPlus %a AdminPlus $did(mta.server,40).state
  !write -sAdminPort %a AdminPort $did(mta.server,63)
  !write -sAdminPassword %a AdminPassword $+(",$did(mta.server,42),")
  !write -sAdminPlusPassword %a AdminPlusPassword $+(",$did(mta.server,44),")
  !write -sAdminAllowShutdown %a AdminAllowShutdown $did(mta.server,46).state
  !write -sChatFloodMaxCount %a ChatFloodMaxCount $did(mta.server,48)
  !write -sBanOnChatFlood %a BanOnChatFlood $did(mta.server,50).state
  !write -sServerSendLimitEnabled %a ServerSendLimitEnabled $did(mta.server,52).state
  !write -sServerSendLimit %a ServerSendLimit $did(mta.server,54)
  !write -sServerSendLimitMaxAllowed %a ServerSendLimitMaxAllowed $did(mta.server,65)
  !write -sServerSendLimitLogDropped %a ServerSendLimitLogDropped $did(mta.server,56).state
  mta.log $dialog(mta).tab * Server setup: Config file saved.
}
alias mta.motd2 {
  if (!$sock(mta.motd. $+ $1)) {
    var %a = $readini($scriptdirmta.ini,$right($sockname,1),motd)
    if (%a) {
      mta.log $1 * MOTD: Checking for changes...
      !sockclose mta.motd. $+ $1
      !sockopen mta.motd. $+ $1 $mid(%a,8,$calc($pos(%a,/,3)-8)) 80
    }
  }
}
on *:sockopen:mta.motd.*: {
  var %a = $readini($scriptdirmta.ini,$right($sockname,1),motd)
  if (!$sockerr) !sockwrite -n $sockname GET $mid(%a,$pos(%a,/,3),255) $+(HTTP/1.1,$crlf,Host: $mid(%a,8,$calc($pos(%a,/,3)-8)),$crlf,Connection: Close,$crlf,$crlf)
  elseif ($dialog(mta)) mta.log $right($sockname,1) * MOTD: Connection problems.
}
on *:sockread:mta.motd.*:{ 
  !sockread &a
  while ($sockbr != 0) {
    !bwrite $right($sockname,1) $+ .tmp -1 &a
    !sockread &a
  }
}
on *:sockclose:mta.motd.*:{ 
  if ($dialog(mta)) {
    var %a = $right($sockname,1)
    !bread %a $+ .tmp 1 $file(%a $+ .tmp).size &a
    !bcopy -c &a 1 &a $calc($bfind(&a,1,10 13 10)+3) -1
    !.remove %a $+ .tmp
    !bwrite %a $+ .tmp 0 &a
    if ($crc(%a $+ .tmp) == $crc($+($scriptdir,%a,.rtf))) mta.log %a * MOTD: No changes.
    else {
      !.copy -o %a $+ .tmp $+(",$scriptdir,%a,.rtf") 
      mta.log %a * MOTD: Updated.
    }
    !.remove %a $+ .tmp
  }
}
alias mta.motd3 {
  if (!$sock(mta.motd)) {
    mta.log $dialog(mta).tab * MTA-MOTD: Checking for changes...
    !sockclose mta.motd
    !sockopen mta.motd www.mtavc.com 80
  }
}
on *:sockopen:mta.motd: {
  if (!$sockerr) !sockwrite -n $sockname GET /clientwelcomes/clientwelcome050.rtf $+(HTTP/1.1,$crlf,Host: www.mtavc.com,$crlf,Connection: Close,$crlf,$crlf)
  elseif ($dialog(mta)) mta.log $dialog(mta).tab * MTA-MOTD: Connection problems.
}
on *:sockread:mta.motd:{ 
  !sockread &a
  while ($sockbr != 0) {
    !bwrite 0.tmp -1 &a
    !sockread &a
  }
}
on *:sockclose:mta.motd:{ 
  if ($dialog(mta)) {
    !bread 0.tmp 1 $file(0.tmp).size &a
    !bcopy -c &a 1 &a $calc($bfind(&a,1,10 13 10)+3) -1
    !.remove 0.tmp
    !bwrite 0.tmp 0 &a
    if ($crc(0.tmp) == $crc($scriptdir0.rtf)) mta.log $dialog(mta).tab * MTA-MOTD: No changes.
    else {
      !.copy -o 0.tmp " $+ $scriptdir0.rtf"
      mta.log $dialog(mta).tab * MTA-MOTD: Updated.
    }
    !.remove 0.tmp
  }
}
on *:LOAD:{
  mta
  if ($script(1) != $script) !.reload -rs1 $+(",$script,")
}
on *:UNLOAD:if (!$input(Are you sure to unload 'mta.mrc'?,uywd,MTA:mA)) !.timer 1 0 !.load -rs1 $+(",$script,")
on *:START:{
  !.localinfo
  if ($readini($scriptdirmta.ini,0,auto)) mta
  if ($script(1) != $script) !.reload -rs1 $+(",$script,")
}
