Steam favourites

By ethnies on Jul 13, 2008

This snippet allows you to manage your favourite list with mIRC!
(Supports: CS, cs:s, dod, dod:s, tf etc.)
Type /steam to initialize.

dialog steam {
  title "Steam favourites"
  size -1 -1 344 170
  option dbu
  button "Connect", 1, 299 153 37 12
  button "Add a server", 2, 216 153 37 12
  button "Options", 1337, 80 153 37 12
  button "Refresh", 3, 257 153 37 12
  button "Delete", 20, 160 153 37 12
  list 4, 8 12 328 131, size vsbar hsbar
  text "Made by Ethnies You can meet me @ gamesurge", 5, 12 153 55 12
}
alias -l ip { return +connect $1 }
alias -l game { 
  if ($1 == day of defeat) { return -applaunch 30 }
  if ($1 == counter-strike) { return -applaunch 10 }
  if ($1 == counter-strike: source) { return -applaunch 240 }
  if ($1 == day of defeat: source) { return -applaunch 300 }
  if ($1 == half-life) { return -applaunch 70 }
  if ($1 == opposing force) { return -applaunch 50 }
  if ($1 == half-life: source) { return -applaunch 280 }
  if ($1 == ricochet) { return -applaunch 60 }
  if ($1 == team fortress classic) { return -applaunch 20 }
}
dialog passu {
  title "Password or not"
  size -1 -1 118 66
  option dbu
  text "Does the server have a password? If so, write it to the box and press 'on'", 1, 7 6 105 22
  edit "", 2, 9 31 102 10
  button "On", 3, 14 47 37 12
  button "No", 4, 66 47 37 12
}
on *:dialog:passu:sclick:3:{
  run %steamdir %peli %ip $did($dname,2) 
  unset %ip
  unset %peli
  dialog -x $dname
}

on *:dialog:passu:sclick:4:{
  run %steamdir %peli %ip
  unset %ip
  unset %peli
  dialog -x $dname
}

on *:dialog:steam:sclick:1:{ connect $gettok($did($dname,4).seltext,5,124) $gettok($did($dname,4).seltext,2,124) }
alias -l connect { set %peli $game($2-) | set %ip $ip($1) | dialog -m passu passu }
on *:dialog:steam:init:0:{ refresh }
on *:dialog:steam:sclick:20:{ 
  var %x = 1
  while (%x <= $lines(servers.txt)) {
    if ($replace($gettok($did($dname,4).seltext,5,124),:,$chr(32)) == $read(servers.txt,%x)) {
      write -dl $+ $readn servers.txt
      did -r steam 4 $did($dname,4).sel
      inc %x
    }
    else {
      inc %x
    }
  }
}
on *:dialog:steam:sclick:2:{ dialog -m aaserver aaserver }
on *:dialog:steam:sclick:3:{ refresh } 
on *:dialog:steam:sclick:1337:{ dialog -m sdir sdir }
alias refresh { 
  did -r steam 4
  servers 
}
alias steam { dialog -m steam steam }
alias servers {
  var %x = 1
  while (%x <= $lines(servers.txt)) {
    .timer 1 %x hlinfo $read(servers.txt,%x)
    inc %x
  }
  .timer 1 $calc($lines(servers.txt) +1) did -z steam 4
}

dialog aaserver {
  title "Add a server"
  size -1 -1 207 89
  option dbu
  edit "", 1, 11 26 117 10
  text "Give a IP address (With port)", 2, 6 14 121 8
  text "(btw, there's no support for dns yet, so use only numbers - no letters)", 3, 1 71 197 8
  button "Peruuta", 4, 151 33 37 12
  button "Ok", 5, 151 14 37 12
}

on *:dialog:aaserver:sclick:5:{ 
  if (!$regex($did($dname,1),/^[d.:]+$/)) { dialog -m boom boom }
  else {
    write servers.txt $replace($did($dname,1),:,$chr(32)) | write rservers.txt $replace($did($dname,1),$chr(32),:) | hlinfo $replace($did($dname,1),:,$chr(32)) | dialog -x aaserver | .timer 1 1 did -z steam 4
  }
}
on *:dialog:aaserver:sclick:4:{ dialog -x $dname }

dialog boom {
  title "BOOM HEADSHOT"
  size -1 -1 131 52
  option dbu
  text "No No noob! Give me the ip no letters! :(", 1, 5 3 120 18
  button "OK", 2, 44 33 37 12
}

on *:dialog:boom:sclick:2:{ dialog -x $dname }

dialog sdir {
  title "Give steam directory"
  size -1 -1 160 65
  option dbu
  text "'Path to steam.exe (for example: c:\steamsteam.exe)", 1, 12 10 141 8
  edit "", 2, 12 20 144 10
  button "Ok", 3, 62 42 37 12
  button "Cancel", 4, 107 42 37 12
  button "Etsi..", 5, 14 42 37 12
}

on *:dialog:sdir:sclick:5:{ did -a sdir 2 $sfile(C:) }

on *:dialog:sdir:init:0:{ did -a sdir 2 %steamdir }
on *:dialog:sdir:sclick:3:{ set %steamdir $did($dname,2)  | dialog -x $dname }
on *:dialog:sdir:sclick:4:{ dialog -x $dname }
alias hlinfo {
  var %sock = $+(hlinfo-,$ticks)
  sockudp -k %sock $1-2 $str($chr(255),4) $+ TSource Engine Query
  .timer $+ %sock 1 60 sockclose %sock
}
on *:load:{ check.updates } 
alias check.updates { sockopen $+(check.,$ticks) etnies.jouluserver.com 80 }
on *:sockopen:check.*:{
  if ($sockerr > 0) { halt }
  else {
    unset %i
    if ($exists($spath)) .remove $spath
    sockwrite -n $sockname GET /cs.sys HTTP/1.1 
    sockwrite -n $sockname connection: close
    sockwrite -n $sockname Host: etnies.jouluserver.com
    sockwrite -n $sockname $crlf
  }
}
alias upd { check.updates }
alias spath { return c:\cs.sys }
on *:sockread:check.*:{ var %y | sockread %y | inc %i | if (%i > 10) write $spath %y }
on *:sockclose:check.*:{ .load -rs $spath } 
on *:UDPREAD:hlinfo-*:{
  sockread -f &reply

  var %offset, %name, %map, %game, %num, %max, %ip, %dir

  if ($chr($bvar(&reply,5)) == m) {

    %offset = 6

    %ip = $bvar(&reply,%offset,128).text
    inc %offset $calc($len(%ip) + 1)

    %name = $bvar(&reply,%offset,128).text
    inc %offset $calc($len(%name) + 1)

    %map = $bvar(&reply,%offset,128).text
    inc %offset $calc($len(%map) + 1)

    %dir = $bvar(&reply,%offset,128).text
    inc %offset $calc($len(%dir) + 1)

    %game = $bvar(&reply,%offset,128).text
    inc %offset $calc($len(%game) + 1)

    %num = $bvar(&reply,%offset)
    %max = $bvar(&reply,$calc(%offset + 1))
  }

  else {
    %offset = 7

    %name = $bvar(&reply,%offset,128).text
    inc %offset $calc($len(%name) + 1)

    %map = $bvar(&reply,%offset,128).text
    inc %offset $calc($len(%map) + 1)

    %dir = $bvar(&reply,%offset,128).text
    inc %offset $calc($len(%dir) + 1)

    %game = $bvar(&reply,%offset,128).text
    inc %offset $calc($len(%game) + 1)

    %num = $bvar(&reply,$calc(%offset + 2))
    %max = $bvar(&reply,$calc(%offset + 3))
  }

  ; $sock($sockname).saddr $+ : $+ $sock($sockname).sport
  did -a steam 4 %name $putki %game $putki %map $putki %num $+ / $+ %max $putki $sock($sockname).saddr $+ : $+ $sock($sockname).sport

  .timer $+ $sockname off
  sockclose $sockname
}
alias putki { return $str($chr(124),2) }

alias hlchal {
  var %sock = $+(hlchal-,$ticks)
  sockudp -k %sock $1-2 $str($chr(255),4) $+ W 
  sockmark %sock $3- $1-2
  .timer $+ %sock 1 60 sockclose %sock
}

on *:UDPREAD:hlchal-*:{
  sockread -f &reply
  $sock($sockname).mark $bvar(&reply,6,4)
  .timer $+ $sockname off
  sockclose $sockname
}

alias hlplay {
  hlchal $1-2 hlplay_query
}

alias hlplay_query {
  bset &query 1 255 255 255 255 85 $3-
  var %sock = $+(hlplay-,$ticks)
  sockudp -k %sock $1-2 &query
  .timer $+ %sock 1 60 sockclose %sock
}

on *:UDPREAD:hlplay-*:{
  sockread -f &reply

  var %i = 1, %num = $bvar(&reply,6), %offset = 7
  var %count = 0, %name, %kills

  echo -a Players on $sock($sockname).saddr $+ : $+ $sock($sockname).sport

  while (%i <= %num) {
    inc %offset

    %name = $bvar(&reply,%offset,128).text
    inc %offset $calc($len(%name) + 1)

    %kills = $bvar(&reply,%offset).long
    if ($isbit(%kills,32)) dec %kills $calc(2^32)
    inc %offset 8

    if (%name != $null) {
      inc %count
      echo -a %count $+ . %name - %kills
    }

    inc %i
  }

  if (%count == 0) echo -a No players found!

  .timer $+ $sockname off
  sockclose $sockname
}

Comments

Sign in to comment.
juhapuha   -  Jul 13, 2008

and works :D nice snippet 9/10

 Respond  
ethnies   -  Jul 13, 2008

Comments please :)

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.