TFC related mIRC scripts

Here you will find posts that were of interest and have been placed into this forum for information purposes...
Post Reply
User avatar
pizzahut
Extraordinary Gentleman
Posts: 1210
Joined: Fri Sep 17, 2004 1:25 am

TFC related mIRC scripts

Post by pizzahut »

General installation instructions:

http://www.roystonvasey.eu/forum/viewto ... 0179#20179

hlserver.mrc (original author: Dennis "ParaSite" Hellewegen)

Queries Goldsource (e.g. TFC) and Source (e.g. TF2) servers.

Usage: !hlserver ip:port

Note: Fixed to be compatible with mIRC v7 (Unicode).

Version with time.dll (more precise, but requires said dll file)

Code: Select all

alias hlserver {
  if ($1 == $null) halt
  set %hlserver.ip $1
  set %hlserver.spitchan $iif($2,$2,$active)
  if (%hlserver.spitchan == Status Window) {
    echo -s You are not on a channel
    halt
  }
  var %char = $left($1,1)
  if (((%char >= A) && (%char <= Z)) || ((%char >= a) && (%char <= z))) {
    set %hlserver.no-ip 0
    dns $gettok($1,1,58)
  }
  else {
    dll time.dll GetTime .
    bset &query 1 255
    bset &query 2 255
    bset &query 3 255
    bset &query 4 255
    bset -t &query 5 TSource Engine Query
    bset &query 25 0
    sockudp -nk hlchanserver $gettok($1,1,58) $iif($gettok($1,2,58),$ifmatch,27015) &query
    set %hlserver.time $dll(time.dll,GetTime,.)
    timertimeout 1 3 hlserver.timeout
  }
}

on *:DNS:{
  if (%hlserver.ip) {
    if ($dns(0) == 0) {
      msg %hlserver.spitchan This domain name couldn't be resolved.
      unset %hlserver.*
      halt
    }
    set %hlserver.ip $dns(1).ip $+ $iif($gettok(%hlserver.ip,2,58),: $+ $ifmatch)
    dll time.dll GetTime .
    bset &query 1 255
    bset &query 2 255
    bset &query 3 255
    bset &query 4 255
    bset -t &query 5 TSource Engine Query
    bset &query 25 0
    var %port = $iif($gettok(%hlserver.ip,2,58),$ifmatch,27015)
    sockudp -nk hlchanserver $raddress %port &query
    set %hlserver.time $dll(time.dll,GetTime,.)
    timertimeout 1 3 hlserver.timeout
    ; msg %players.spitchan Server IP = $raddress $+ $chr(58) $+ %port
  }
}

alias hlserver.timeout {
  sockclose hlchanserver
  msg %hlserver.spitchan No response
  unset %hlserver.*
}

alias hlserver.usage {
  if ($1 == $me) {
    echo -a Usage:
    echo -a !s ip[:port]
    echo -a !s domain[:port]
    echo -a !s fm / rv / 1v1 / dust
    echo -a !fm / !rv / !1v1 / !dust
  }
  else {
    notice $1 Usage:
    notice $1 !s ip[:port]
    notice $1 !s domain[:port]
    notice $1 !s fm / rv / 1v1 / dust
    notice $1 !fm / !rv / !1v1 / !dust
  }
}

on *:input:#:{
  set %hlserver.no-ip 0
  if (($1 == !s) || ($1 == !hlserver)) {
    if ($2 == $null) { msg # $1 | hlserver.usage $me | halt }
    elseif ($2 == rv) { hlserver 37.122.208.248 $chan }
    elseif ($2 == 1v1) { hlserver 37.122.208.248:27025 $chan }
    elseif ($2 == fm) { hlserver 37.122.208.248:27017 $chan }
    elseif ($2 == dust) { hlserver 87.98.219.139:27030 $chan }
    else { set %hlserver.no-ip 1 | hlserver $2 $chan }
  }
  elseif ($1- == !rv) { hlserver 37.122.208.248 $chan }
  elseif ($1- == !1v1) { hlserver 37.122.208.248:27025 $chan }
  elseif ($1- == !fm) { hlserver 37.122.208.248:27017 $chan }
  elseif ($1- == !dust) { hlserver 87.98.219.139:27030 $chan }
}

on *:text:!s:#:hlserver.usage $nick
on *:text:!hlserver:#:hlserver.usage $nick

on *:text:!s *:#:{
  set %hlserver.no-ip 0
  if ($2 == rv) { hlserver 37.122.208.248 $chan }
  elseif ($2 == 1v1) { hlserver 37.122.208.248:27025 $chan }
  elseif ($2 == fm) { hlserver 37.122.208.248:27017 $chan }
  elseif ($2 == dust) { hlserver 87.98.219.139:27030 $chan }
  else { set %hlserver.no-ip 1 | hlserver $$2 $chan }
}

on *:text:!hlserver *:#:{
  set %hlserver.no-ip 0
  if ($2 == rv) { hlserver 37.122.208.248 $chan }
  elseif ($2 == 1v1) { hlserver 37.122.208.248:27025 $chan }
  elseif ($2 == fm) { hlserver 37.122.208.248:27017 $chan }
  elseif ($2 == dust) { hlserver 87.98.219.139:27030 $chan }
  else { set %hlserver.no-ip 1 | hlserver $$2 $chan }
}

on *:text:!rv:#:set %hlserver.no-ip 0 | hlserver 37.122.208.248 $chan
on *:text:!1v1:#:set %hlserver.no-ip 0 | hlserver 37.122.208.248:27025 $chan
on *:text:!fm:#:set %hlserver.no-ip 0 | hlserver 37.122.208.248:27017 $chan
on *:text:!dust:#:set %hlserver.no-ip 0 | hlserver 87.98.219.139:27030 $chan

on *:udpread:hlchanserver:{
  timertimeout off
  var %hlserver.ping = $dll(time.dll,GetTime,.) - %hlserver.time
  sockread &temp
  sockclose hlchanserver
  if ($bvar(&temp,5) == 73) {
    var %hlserver.source 1
    var %i = 7
    ; msg %hlserver.spitchan Reply format: Source
  }  
  elseif ($bvar(&temp,5) == 109) {
    var %i = $bfind(&temp,6,0) + 1
    ; msg %hlserver.spitchan Reply format: GoldSource (obsolete)
  }  
  else {
    sockclose hlchanserver
    msg %hlserver.spitchan Unknown reply format
    unset %hlserver.*
    halt
  }
  var %hlserver.name = $bvar(&temp,%i,100).text
  inc %i $len(%hlserver.name)
  inc %i
  var %hlserver.debug = $bvar(&temp,%i,1)
  if (%hlserver.debug == 0) inc %i
  var %hlserver.map = $bvar(&temp,%i,100).text
  inc %i $len(%hlserver.map)
  inc %i
  var %hlserver.shortmod = $bvar(&temp,%i,100).text
  inc %i $len(%hlserver.shortmod)
  inc %i
  var %hlserver.mod = $bvar(&temp,%i,100).text
  inc %i $len(%hlserver.mod)
  if (%hlserver.mod == Counter-Strike) var %hlserver.mod = CS
  elseif (%hlserver.mod == Day of Defeat) var %hlserver.mod = DoD
  elseif (%hlserver.mod == Team Fortress Classic) var %hlserver.mod = TFC
  elseif (%hlserver.mod == Counter-Strike: Global Offensive) var %hlserver.mod = CS:GO
  elseif (%hlserver.mod == Counter-Strike: Source) var %hlserver.mod = CS:S
  elseif (%hlserver.mod == Day of Defeat: Source) var %hlserver.mod = DoD:S
  elseif (%hlserver.mod == Team Fortress) var %hlserver.mod = TF2
  inc %i $iif(%hlserver.source,3,1)
  var %hlserver.numplayers = $bvar(&temp,%i,1)
  inc %i
  var %hlserver.maxplayers = $bvar(&temp,%i,1)
  if (%hlserver.source) var %hlserver.bots = $bvar(&temp,$calc(%i + 1),1)
  inc %i 4
  var %hlserver.password = $bvar(&temp,%i,1)
  if (%hlserver.source) inc %i
  else {
    inc %i 2
    %i = $bfind(&temp,%i,0) + 1
    %i = $bfind(&temp,%i,0) + 1
    %i = $bfind(&temp,%i,0) + 11
  }
  var %hlserver.vac = $bvar(&temp,%i,1)
  if (%hlserver.source != 1) {
    if (%hlserver.mod == HLTV) var %hlserver.bots = 0
    else var %hlserver.bots = $bvar(&temp,$calc(%i + 1),1)
  }
  var %hlserver.humans = $calc(%hlserver.numplayers - %hlserver.bots)
  msg %hlserver.spitchan $iif(%hlserver.password == 1,Password $chr(124)) $&
    $iif(%hlserver.bots > 0,%hlserver.bots bots $chr(124)) $&
    $iif(%hlserver.vac == 1,VAC $chr(124)) $&
    %hlserver.name $chr(124) $&
    $iif(%hlserver.no-ip != 1,%hlserver.ip $chr(124)) $&
    %hlserver.mod $chr(124) $&
    $iif(%hlserver.bots > 0,%hlserver.humans humans,%hlserver.humans $+ / $+ %hlserver.maxplayers) $chr(124) $&
    %hlserver.map $chr(124) $&
    %hlserver.ping $+ ms
  unset %hlserver.*
}
Version without time.dll (less precise, but doesn't require the dll file)

Code: Select all

Remove the line
  dll time.dll GetTime .

Replace all two occurrences of
  $dll(time.dll,GetTime,.)
with
  $ticks
Last edited by pizzahut on Mon Dec 24, 2012 6:23 pm, edited 13 times in total.
User avatar
pizzahut
Extraordinary Gentleman
Posts: 1210
Joined: Fri Sep 17, 2004 1:25 am

Post by pizzahut »

tfcmaps.mrc (original author: Dennis "ParaSite" Hellewegen)

Finds TFC maps

Usage: !tfcmap map_name

requires tfcmap.txt

Code: Select all

on *:sockopen:tfcmap.*:{
  if ($sockerr != 0) {
    /sockclose $sockname
    /showresult
    /halt
  }
  /sockwrite -n $sockname GET $path($read(tfcmapservers.txt,$gettok($sockname,2,46))) HTTP/1.1 
  /sockwrite -n $sockname Host: $host($read(tfcmapservers.txt,$gettok($sockname,2,46))) $+ $crlf $+ $crlf
}

on *:sockread:tfcmap.*:{
  /var %temp
  /sockread -f %temp
  if (*200* iswm $htmlfree(%temp)) {
    /showresult $read(tfcmapservers.txt,$gettok($sockname,2,46))
  }
  else {
    /sockclose $sockname
    /showresult
  }
}

alias -l tfcread {
  /var %temp
  /.remove tfcmapservers.txt
  /set %temp $read(tfcmap.txt,1)
  while ($len(%temp) > 0) {
    /write tfcmapservers.txt $replace(%temp,@mapname,%mapsearch) 
    /set %temp $read(tfcmap.txt,$calc($readn + 1))
  }
  /checkservers  
}

on *:text:*:#:{
  ; Comment (out) the elseif part for spammy mode.
  if (($$1 == !tfcmap) && ($2)) {  
    if (!%tfcbot.spam) {  
      /set -u20 %tfcbot.spam 1  
      ;/set %mapsearch $lower($$2)
      /set %mapsearch $$2
      /set %mapsearchchan $chan
      /tfcread
    }
  }
  elseif ((Found the map ' $+ %mapsearch $+ ' at http* iswm $1-) || (Sorry, the map ' $+ %mapsearch $+ ' could not be found! == $1-)) {
    /sockclose tfcmap.*
    /unset %mapsearch
    /unset %mapsearchchan
    /unset %tfcbot.spam
  }
}

on *:input:#:{
  if (($$1 == !tfcmap) && ($2)) {  
    ;/set %mapsearch $lower($$2)
    /set %mapsearch $$2
    /set %mapsearchchan $chan
    /tfcread
  }
}

alias -l showresult {
  if (!$1) {
    if ($sock(tfcmap.*,0) == 0) { 
      /msg %mapsearchchan Sorry, the map ' $+ %mapsearch $+ ' could not be found!
      /msg %mapsearchchan Try www.euroskillz.eu or www.uk-tf.co.uk .
      /unset %mapsearch
      /unset %mapsearchchan
    } 
  }
  else {
    /msg %mapsearchchan Found the map ' $+ %mapsearch $+ ' at http:// $+ $1
    /sockclose tfcmap.*
    /unset %mapsearch
    /unset %mapsearchchan
  }
}

alias -l checkservers {
  if (($lines(tfcmapservers.txt) == 0) || ($exists(tfcmapservers.txt) == $false)) { /msg %mapsearchchan Sorry, Connection Error! }
  else {
    /var %count = 0
    /.sockclose tfcmap.*
    while (%count != $lines(tfcmapservers.txt)) {
      /inc %count
      /.timer 1 0 /sockopen tfcmap. $+ %count $host($read(tfcmapservers.txt,%count)) 80
    }
  }
}

alias -l htmlfree {
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;)
  return %x
}

alias -l host { /return $gettok($1,1,47) }

alias -l path { /return $remove($1,$gettok($1,1,47)) }
tfcmap.txt

Code: Select all

bulletland.com/maps/@mapname.zip
fcfuncamp.webs.com/MAPS/@mapname.rar
freewebs.com/fattymaps/@mapname.zip
ftp.wireplay.co.uk/pub/halflife/mods/teamfortressclassic/maps/@mapname.zip
goldsrc.org/files/maps/20/@mapname.7z
goldsrc.org/files/maps/20/@mapname.rar
goldsrc.org/files/maps/20/@mapname.tar.bz2
goldsrc.org/files/maps/20/@mapname.zip
jobsmaps.com/maps/@mapname.zip
nateos.com/ftfcl/Maps/@mapname.zip
stfcc.org/files/maps/@mapname.zip
strategyinformer.com/earthwalker/tfcmaps/@mapname.zip
tc.paing.com/maps/@mapname.zip
tfc.flumpcakes.co.uk/@mapname.zip
tfxsoft.com/007/files/maps_music/@mapname.zip
tfxsoft.com/007/files/maps_music/@mapname-temple.zip
tfxsoft.com/007/files/beta/@mapname_BETA2_with-music.zip
tfxsoft.com/007/files/beta/@mapname_BETA2.zip
tfxsoft.com/007/files/beta/@mapname_BETA1_with-music.zip
tfxsoft.com/007/files/beta/@mapname_BETA1.zip
trepid.net/maps/files/@mapname.zip
mrclan.com/tfcmaps/@mapname.zip
fortress.pwnz.it/maps/@mapname.rar
fortress.pwnz.it/maps/@mapname.zip
fortress.pwnz.it/maps/@mapname.tar.bz2
Last edited by pizzahut on Wed Apr 11, 2012 10:42 pm, edited 8 times in total.
User avatar
pizzahut
Extraordinary Gentleman
Posts: 1210
Joined: Fri Sep 17, 2004 1:25 am

Post by pizzahut »

Original (old / outdated) scripts: Web archive
Original (old / outdated) data files: http://www.xs4all.nl/~hllwgn/
Original author (contact): http://steamcommunity.com/id/dennisch/
User avatar
pizzahut
Extraordinary Gentleman
Posts: 1210
Joined: Fri Sep 17, 2004 1:25 am

Post by pizzahut »

Installation instructions

Scripts go to "%APPDATA%\mIRC\scripts". If you use an external editor then the file extension should be ".mrc", not ".ini". In Windows Explorer there's a setting "hide file extension for known file types" - best disable it to avoid confusion, such as text editors secretly adding ".txt".

Other files such as DLLs or TXTs go to "%APPDATA%\mIRC".
User avatar
Tempted
crooked doctor
Posts: 688
Joined: Wed May 13, 2009 6:25 pm

Post by Tempted »

oooowww scripts...
yum
/me blabs to spanky
bunnyhop is NOT a hack!!
also, i like kitties ^_^
further more, if you look up, you cant see your feet.
User avatar
pizzahut
Extraordinary Gentleman
Posts: 1210
Joined: Fri Sep 17, 2004 1:25 am

Post by pizzahut »

SteamID converter steamID.mrc

Code: Select all

; Script to turn STEAM_IDs into Community page URLS and the other way around. Created by CShadowRun!
; Use is simple just type /profile STEAM_ID or Community ID (The very large number at the end of the URL)
alias profile {
  if ($regex($1-,^STEAM_\d:(\d):(\d+)$)) {
    var %n = $right(76561197960265728,$calc($len($regml(2) + 1)))
    var %id = $calc(($regml(2) * 2) + $regml(1) + %n)
    echo -a $+($1-,'s) Community page is: $+(http://steamcommunity.com/profiles/,$left(76561197960265728,$calc(13 - $len($regml(2)))),%id)  
  }
  else if ($regex($1-,^7656119\d+$)) {
    var %n = $right($1-,10)
    var %n = $calc(%n - 7960265728)
    if (. isin $calc(%n / 2)) { var %one = 1 | dec %n }
    var %n = $calc(%n / 2)
    echo -a Profile ID $1- Belongs to: $+(STEAM_0:,$iif(%one,1,0),:,%n)
  }
  else { echo -a $1- Does not appear to be a valid Community or Steam ID. }
}
Source is probably this forum post: http://forums.alliedmods.net/showpost.p ... stcount=39

Full thread: http://forums.alliedmods.net/showthread.php?t=60899
User avatar
pizzahut
Extraordinary Gentleman
Posts: 1210
Joined: Fri Sep 17, 2004 1:25 am

Re: TFC related mIRC scripts

Post by pizzahut »

Updated the hlserver script so it works with domain names. It's not optimised though, lots of duplicate code.

[14:13:45] <pizzahut> !hlserver tfc.roystonvasey.org.uk
[14:13:46] <pizzahut> 2 bots | VAC | Royston Vasey - Jolene's Server | TFC | 2/32 | 2fort | 58ms

[14:27:40] <pizzahut> !hlserver CCRetroGaming.co.uk:27035
[14:27:40] <pizzahut> VAC | CCRetroGaming.co.uk - TFC 1.6 | TFC | 0/32 | rock2 | 29ms

[14:29:03] <pizzahut> !hlserver SkillzWorld.eu:27035
[14:29:03] <pizzahut> SkillzWorld.eu Climb | TFC | 0/18 | cg_strafejumpZ | 27ms
User avatar
pizzahut
Extraordinary Gentleman
Posts: 1210
Joined: Fri Sep 17, 2004 1:25 am

Re: TFC related mIRC scripts

Post by pizzahut »

Copying the connection and password info of the pickup bot is simple enough, you mark the commands excluding the tfc:// URL and let go, start up TFC, open console, and paste it.

Ideally I'd like to be able to double click on the tfc:// URL, but this doesn't work because a) it should be steam://connect/ and b) mIRC doesn't recognise steam:// URLs.

So instead I'm parsing the connection info and have TFC start automatically.

Code: Select all

on *:text:connect*:?:{
  if ($nick == RV-N00BS) {
    var %f1 = $gettok($1-,1,59)
    var %c1 = $gettok(%f1,1,32)
    var %p1 = $gettok(%f1,2,32)

    var %f2 = $gettok($1-,2,59)
    var %c2 = $gettok(%f2,1,32)
    var %p2 = $gettok(%f2,2,32)

    run -p H:\Programme\Steam\Steam.exe -applaunch 20 + $+ %c2 %p2 + $+ %c1 %p1
  }
}
The path to Steam needs to be adjusted.
User avatar
pizzahut
Extraordinary Gentleman
Posts: 1210
Joined: Fri Sep 17, 2004 1:25 am

Re: TFC related mIRC scripts

Post by pizzahut »

Bit spammy, but anyway:

Code: Select all

[22:34:28] <pizzahut> !players 37.122.208.248:27015
[22:34:28] <pizzahut> Score | Time       | Player name
[22:34:28] <pizzahut> ------+------------+--------------------
[22:34:28] <pizzahut>    28 | 1h 35m 41s | Siev Birch
[22:34:28] <pizzahut>    29 | 1h 16m 41s | majik
[22:34:28] <pizzahut>     9 | 1h  8m 33s | 69
[22:34:28] <pizzahut>     2 | 1h  2m 15s | Paranoidcat
[22:34:28] <pizzahut>    16 | 0h 42m 55s | Markus de Neyr
[22:34:28] <pizzahut>     4 | 0h 42m 35s | warpath rules
[22:34:28] <pizzahut>    28 | 0h 39m 39s | 007
[22:34:28] <pizzahut>    10 | 0h 35m 46s | Purgamentum
[22:34:28] <pizzahut>    17 | 0h 34m 35s | Pichicat doll
[22:34:28] <pizzahut>    13 | 0h 26m 23s | Globoss
[22:34:28] <pizzahut>    26 | 0h 13m 58s | Pony-tail thug
[22:34:28] <pizzahut>    16 | 0h 13m 57s | Jimbob
[22:34:28] <pizzahut>    15 | 0h 13m 52s | Mazzma
[22:34:28] <pizzahut>    52 | 0h 13m 49s | Undz
[22:34:28] <pizzahut>     7 | 0h 13m 41s | Radio
[22:34:28] <pizzahut>     5 | 0h 13m 41s | SpaCe1182
[22:34:28] <pizzahut>    24 | 0h 12m 52s | pzy
[22:34:28] <pizzahut>    -1 | 0h  6m 58s | Player
[22:34:28] <pizzahut>     1 | 0h  4m 55s | (2)player
[22:34:28] <pizzahut>     2 | 0h  4m  4s | Lord Yves
[22:34:28] <pizzahut>    -2 | 0h  3m  6s | (3)Player
Started with ParaSite's !hlserver script as basis, added retrieval of a challenge number (otherwise servers won't give player infos), parsing including floating point and formatting with an invisible character other than space.

However since this script is so spammy it's probably better to just output the player names.

Code: Select all

alias players {
  if ($1 == $null) usage
  set %players.ip $1
  set %players.spitchan $iif($2,$2,$active)
  if (%players.spitchan == Status Window) {
    echo -s You are not on a channel
    halt
  }
  var %char = $left($1,1)
  if (((%char >= A) && (%char <= Z)) || ((%char >= a) && (%char <= z))) {
    dns $gettok($1,1,58)
  }
  else {
    bset &query 1 255 255 255 255 $asc(U) 255 255 255 255 0
    sockudp -k PlayersUDPSocket $gettok($1,1,58) $iif($gettok($1,2,58),$ifmatch,27015) &query
    timertimeout 1 3 players.timeout
  }
}

on *:DNS:{
  if (%players.ip) {
    bset &query 1 255 255 255 255 $asc(U) 255 255 255 255 0
    sockudp -k PlayersUDPSocket $raddress $iif($gettok(%players.ip,2,58),$ifmatch,27015) &query
    timertimeout 1 3 players.timeout
    set %players.ip $raddress $+ $chr(58) $+ $iif($gettok(%players.ip,2,58),$ifmatch,27015)
  }
}

alias players.timeout {
  sockclose PlayersUDPSocket
  msg %players.spitchan No response
  unset %players.*
}

alias players.usage {
  echo Usage:
  echo !players ip[:port]
  echo /players ip[:port] [#channel]
  echo Parameters in brackets are optional.
  halt
}

on *:input:#:{
  if ($1 == !players) {
    if ($2 == $null) players.usage
    players $2 $chan
  }
}

on *:text:!players *:#:{
  if (%players_cooldown != 1) {
    set -u30 %players_cooldown 1
    unset %players_warning
    players $$2 $chan
  }
  else {
    if (%players_warning != 1) {
      set %players_warning 1
      msg # Please wait 30s before using this command again.
    }
  }
}

on *:udpread:PlayersUDPSocket:{
  timertimeout off
  sockread &temp

  ; Received a challenge number ?
  if ($bvar(&temp,5) == $asc(A)) {
    bset &temp 5 $asc(U)
    bset &temp 10 0
    sockudp -k PlayersUDPSocket $gettok(%players.ip,1,58) $iif($gettok(%players.ip,2,58),$ifmatch,27015) &temp
    timertimeout 1 3 players.timeout
    halt
  }

  sockclose PlayersUDPSocket
  if ($bvar(&temp,5) == $asc(D)) {
    var %n = $bvar(&temp,6,1)
    var %i = 1
    var %pos = 7
    if (%n >= 1) {
      msg %players.spitchan Score $chr(124) Time $+ $str($chr(160),6) $chr(124) Player name
      msg %players.spitchan ------+------------+--------------------
    }
    while (%i <= %n) {

      ; Index is always zero for some reason.
      ; var %p_index = $bvar(&temp,%pos,1)
      inc %pos

      ; Name
      var %nul_pos = $bfind(&temp,%pos,0)
      var %p_name = $bvar(&temp,%pos,$calc(%nul_pos - %pos + 1)).text
      var %pos = $calc(%nul_pos + 1)

      ; Score
      var %p_score = $bvar(&temp,%pos).long
      if (%p_score >= 2147483648) dec %p_score 4294967296
      inc %pos 4

      ;Time
      ; 4 byte floating point
      var %f1 = $bvar(&temp,%pos,1)
      inc %pos
      var %f2 = $bvar(&temp,%pos,1)
      inc %pos
      var %f3 = $bvar(&temp,%pos,1)
      inc %pos
      var %f4 = $bvar(&temp,%pos,1)
      inc %pos

      var %fraction = %f1
      var %fraction = $calc(%f2 + %fraction / 256)
      var %fraction = $calc($and(%f3,127) + %fraction / 256)
      var %fraction = $calc(1 + (%fraction / 128))

      var %exponent = $calc($and(%f4,127) * 2 + $and(%f3,128) / 128)
      var %exponent = %exponent - 127

      var %sign = $calc($and(%f4,128) / 128 * -1)

      var %p_time = $calc(-1 ^ %sign * %fraction * 2 ^ %exponent)
      var %s = $round($calc(%p_time % 60), 0)
      var %p_time = $int($calc(%p_time / 60))
      var %m = %p_time % 60
      var %p_time = $int($calc(%p_time / 60))
      var %h = %p_time

      msg %players.spitchan $str($chr(160),$calc(5 - $len(%p_score))) $+ %p_score $chr(124) %h $+ h $iif(%m > 9,%m,$chr(160) $+ %m) $+ m $iif(%s > 9,%s,$chr(160) $+ %s) $+ s $chr(124) %p_name
      inc %i
    }
    unset %players.*
  }
User avatar
pizzahut
Extraordinary Gentleman
Posts: 1210
Joined: Fri Sep 17, 2004 1:25 am

Re: TFC related mIRC scripts

Post by pizzahut »

Less spammy version of above, added rv as replacement for the server IP.

[02:45:41] <pizzahut> !players rv
[02:45:41] <pizzahut> RedSoldier, BlueSoldier, RedMedic, BlueMedic

[02:45:44] <pizzahut> !players 37.122.208.248
[02:45:44] <pizzahut> RedSoldier, BlueSoldier, RedMedic, BlueMedic

[02:46:05] <pizzahut> !players tfc.roystonvasey.org.uk
[02:46:05] <pizzahut> RedSoldier, BlueSoldier, RedMedic, BlueMedic

[02:55:59] <pizzahut> !players tfc.roystonvasey.org
[02:55:59] <pizzahut> This domain name couldn't be resolved.

Code: Select all

alias players {
  if ($1 == $null) usage
  set %players.ip $1
  set %players.spitchan $iif($2,$2,$active)
  if (%players.spitchan == Status Window) {
    echo -s You are not on a channel
    halt
  }
  var %char = $left($1,1)
  if (((%char >= A) && (%char <= Z)) || ((%char >= a) && (%char <= z))) {
    dns $gettok($1,1,58)
  }
  else {
    bset &query 1 255 255 255 255 $asc(U) 255 255 255 255 0
    sockudp -k PlayersUDPSocket $gettok($1,1,58) $iif($gettok($1,2,58),$ifmatch,27015) &query
    timertimeout 1 3 players.timeout
  }
}

on *:DNS:{
  if (%players.ip) {
    if ($dns(0) == 0) {
      msg %players.spitchan This domain name couldn't be resolved.
      unset %players.*
      halt
    }
    bset &query 1 255 255 255 255 $asc(U) 255 255 255 255 0
    sockudp -k PlayersUDPSocket $raddress $iif($gettok(%players.ip,2,58),$ifmatch,27015) &query
    timertimeout 1 3 players.timeout
    set %players.ip $raddress $+ $chr(58) $+ $iif($gettok(%players.ip,2,58),$ifmatch,27015)
  }
}

alias players.timeout {
  sockclose PlayersUDPSocket
  msg %players.spitchan No response
  unset %players.*
}

alias players.usage {
  echo Usage:
  echo !players ip[:port]
  echo /players ip[:port] [#channel]
  echo Parameters in brackets are optional.
  halt
}

on *:input:#:{
  if ($1 == !players) {
    if ($2 == $null) players.usage
    if ($2 == rv) { players tfc.roystonvasey.org.uk $chan }
    else { players $2 $chan }
  }
}

on *:text:!players *:#:{
  if (%players_cooldown != 1) {
    set -u30 %players_cooldown 1
    unset %players_warning
    if ($2 == rv) { players tfc.roystonvasey.org.uk $chan }
    else { players $$2 $chan }
  }
  else {
    if (%players_warning != 1) {
      set %players_warning 1
      msg # Please wait 30s before using this command again.
    }
  }
}

on *:udpread:PlayersUDPSocket:{
  timertimeout off
  sockread &temp

  ; Received a challenge number ?
  if ($bvar(&temp,5) == $asc(A)) {
    bset &temp 5 $asc(U)
    bset &temp 10 0
    sockudp -k PlayersUDPSocket $gettok(%players.ip,1,58) $iif($gettok(%players.ip,2,58),$ifmatch,27015) &temp
    timertimeout 1 3 players.timeout
    halt
  }

  sockclose PlayersUDPSocket
  if ($bvar(&temp,5) == $asc(D)) {
    var %n = $bvar(&temp,6,1)
    var %i = 1
    var %pos = 8
    if (%n >= 1) {
      var %nul_pos = $bfind(&temp,%pos,0)
      var %p_name = $bvar(&temp,%pos,$calc(%nul_pos - %pos + 1)).text
      var %names = %p_name
      var %pos = %nul_pos
      inc %pos 10
      inc %i
      while (%i <= %n) {
        var %nul_pos = $bfind(&temp,%pos,0)
        var %p_name = $bvar(&temp,%pos,$calc(%nul_pos - %pos + 1)).text
        var %names = %names $+ $chr(44) %p_name
        var %pos = %nul_pos
        inc %pos 10
        inc %i
      }
      msg %players.spitchan %names
    }
    unset %players.*
  }
Post Reply