;
; /WORLD MAPS/
; /by bar Budun/
; Usage: /getmap TR
; Usage: /getmap IL
alias GetMap {
if ($len($1) !== 2) || ($1 !isalpha) return
set %getmap $1
sockopen getmap worldtimeserver.com 80
echo $color(info) -e * /getmap: trying to resolve map
}
ON 1:SOCKOPEN:getmap: {
if (!$window(@getmap)) window -pdoC +L @getmap -1 -1 200 200
drawfill @getmap 1 1 1 1
drawtext @getmap 0 georgia 20 40 50 Please wait..
if (%bin) unset %bin
if ($isfile($+(%getmap,.jpg)) == $true) .remove $+(%getmap,.jpg)
sockwrite -n getmap GET $+(/images/maps/,%getmap,.jpg) HTTP/1.0
sockwrite -n getmap Host: worldtimeserver.com
sockwrite getmap $crlf
}
ON 1:SOCKREAD:getmap: {
if (!%bin) {
sockread %temp
if ($len(%temp) < 4) set %bin .
if (!%bin) return
}
sockread &getmap
bwrite $+(%getmap,.jpg) -1 -1 &getmap
}
ON 1:SOCKCLOSE:getmap:{
if ($file($+(%getmap,.jpg)).size < 8000) {
echo $color(info) -e * /getmap: No country resolved
.remove $+(%getmap,.jpg)
return
}
drawpic -s @getmap 0 0 190 190 $+(%getmap,.jpg)
}