modify this GameServer !status script

Do you have script in mind but no ability to make it, type in what it should do, and you might be lucky.

modify this GameServer !status script

Postby jameS » Thu Aug 20, 2009 1:19 pm

would be cool if there is such an gameserver status script
Last edited by jameS on Thu Aug 20, 2009 2:38 pm, edited 2 times in total.
jameS
 

GameServer !status script

Postby jameS » Thu Aug 20, 2009 2:30 pm

Found one, but it's not working for EnemyTerritory Game, can someone modify it for me? Shouldn't be that hard if i give infos on the game imo.

This .tcl script will make your eggdrop irc-bot to show your nwn1&nwn2 serverstatus (pulled from gamespy) after beeing triggered inside the channel with !status (working also in query and dcc chat). I found this script 2 years ago, and the original version was not programmed by me. (no notice on who did it before i customized it, sorry).

Features:
° reports your gameserver status (module, playercount, status) to an irc channel after beeing triggered with normal chat
° highly configurable
° support for more than one server
° can be used remote (no need to run on your gameserver itself)
(° php status could be used standalone, without eggdrop)

What you need:
° Website with php-support
° Working eggdrop irc-bot

The package contains:
° php file to receive server-information
° tcl file for eggdrop

Installation:
° copy serverstatus.php to your webserver
° copy serverstatus.tcl to your eggdrop script directory
° add serverstatus.tcl to your eggdrop's config-file script-section
° see serverstatus.tcl for further instructions

If you have further questions, do not hesitate to contact me.


Either link me to another Script, or help me modifying this one for Wolfenstein:EnemyTerritory, it's currently setup for NeverwinterNights or so.

Content of serverstatus.tcl
Code: Select all
## Serverstatus - get from php

# Anbindung der Befehle
set listmc(!status) status.txt

# Do you also want these commands avilable public too?
# 0 = no
# 1 = yes
set mc_rf(public) 1

# If triggered in public, do you want it to read the file in public insted
# of privmsg to the user?
# 0 = no
# 1 = yes
set mc_rf(public:read) 0

# If above public is 1 (yes), what channels do you want them on exactly?
# Set to "" for all channels.
set mc_rf(channels) ""

# To slow the post speed down a bit, how many seconds do you want to
# space out each post?  (Seconds per Line)
# example:  2 will post 1 line every 2 seconds
set mc_rf(speed) 1

# How many times in how many min.s can the user access a command?
set mc_rf(user:access) 1:1

# Overall, how many commands:min can be accessed before considering
# a possible flood and disable all commands?
set mc_rf(over:access) 6:1

# If the flood is detected, how long do you want to keep the commands
# disabled?  (in seconds)
set mc_rf(flood:sec) 10

# MC SVS (Script Version Server)
# Do you want the bot to connection to MC_8's SVS to see if there are newer versions
# of this script avilable?  It will only tell you -- It's up to you to get the newest
# version (I decided not to auto update the code, there may be new features in the
# newest script that may require your attention).
# 0=no/1=yes
set mc_rf(svs:enabled) 0

# Once a day the script will check with the SVS -- this specifies when
# that should happen.  The setting should be the hour (military).
# examples:
#  set mc_rf(svs:check) 0   ;#This is at Midnight
#  set mc_rf(svs:check) 5   ;#This is at 5am
#  set mc_rf(svs:check) 13  ;#This is at 1pm
#  set mc_rf(svs:check) 23  ;#This is at 11pm
set mc_rf(svs:check) 3

# Upon finding a newer version, who do you want to notify via note?
# Seperate each user with a " " (space).
set mc_rf(svs:notify) "RQScott"



## Do not venture past here, TCL Coding below.
set mc_rf(version) v1.4
set mc_rf(svs:script) "readfile 001004000000"
set mc_rf(svs:server) "mc.svs.purehype.net 8085"

bind pubm - * mc:rf:telllist:pubm

proc mc:rf:telllist:pubm {nick uhost hand chan args} {
 global mc_rf
putlog 1
 if {!$mc_rf(public)} {return}
 if {$mc_rf(channels) == ""} {set channels [string tolower [channels]]} {
  set channels [string tolower $mc_rf(channels)]
 }
putlog "$nick $args $chan $channels"
 if {![string match "* [string tolower $chan] *" " $channels "]} {return 0}
 mc:rf:telllist $nick $uhost $hand [join $args] $chan
}

bind msgm - * mc:rf:telllist:msgm
proc mc:rf:telllist:msgm {nick uhost hand args} {
 global mc_rf ; mc:rf:telllist $nick $uhost $hand [join $args] msg
}

proc mc:rf:telllist {nick uhost hand args method} {
putlog $args
exec lynx -preparsed -dump http://127.0.0.1/serverstatus.php > status.txt
 global listmc listmcg mc_rf ; set args [join $args]
putlog $args
 if {[info exists listmc([string tolower $args])]} {
  set temp $args:[string range $uhost [expr [string first @ $uhost]+1] e]
  set access [lindex [split $mc_rf(user:access) :] 0]
  if {[info exists mc_rf(user:$temp)]} {
   if {$mc_rf(user:$temp) > $access} {
    if {![string match "*catch {incr mc_rf(user:$temp) -1}*" [timers]]} {
     unset mc_rf(user:$temp) ; utimer 1 mc:rf:telllist $nick $uhost $hand $args $method
    } {putlog "ReadFile:  Ignoring $nick!$uhost's request of $args.  (Detected from from $nick)"}
    return 0
   } {
    incr mc_rf(user:$temp) 1
    timer [lindex [split $mc_rf(user:access) :] 1] "catch {incr mc_rf(user:$temp) -1}"
   }
  } {
   set mc_rf(user:$temp) 1
   timer [lindex [split $mc_rf(user:access) :] 1] "catch {incr mc_rf(user:$temp) -1}"
  }
  set access [lindex [split $mc_rf(over:access) :] 0]
  if {[info exists mc_rf(over:flood)]} {
   if {$mc_rf(over:flood) > $access} {
    if {![string match "catch {incr mc_rf(over:flood) -1}" [timers]]} {
     unset mc_rf(over:flood) ; utimer 1 mc:rf:tellist $nick $uhost $hand $args $method
    } {
     set mc_rf(over:flood:ignore) 1
     utimer $mc_rf(flood:sec) "catch {unset mc_rf(over:flood:ignore)}"
     putlog "ReadFile:  Ignoring $nick!$uhost's request of $args.  (Detected overall flood)"
    } ; return 0
   } {
    incr mc_rf(over:flood) 1
    timer [lindex [split $mc_rf(over:access) :] 1] "catch {incr mc_rf(over:flood) -1}"
   }
  } {
   set mc_rf(over:flood) 1
   timer [lindex [split $mc_rf(over:access) :] 1] "catch {incr mc_rf(over:flood) -1}"
  } ; if [info exists mc_rf(over:flood:ignore)] {return 0}
  if {$mc_rf(public:read) && ($method != "msg")} {set nick $method}
  if {![file exists $listmc([string tolower $args])]} {
   puthelp "PRIVMSG $nick :ReadFile: error, $listmc([string tolower $args]) doesn't exist."
  } {
   # reading info...
   set file [open $listmc([string tolower $args]) r]
   if {!$mc_rf(speed)} {
    while {![eof $file]} {
     set get [gets $file]
     puthelp "PRIVMSG $nick :$gets"
    }
   } {
    set i 1
    while {![eof $file]} {
     set get [gets $file]
     utimer $i "puthelp {PRIVMSG $nick :$get}"
     incr i $mc_rf(speed)
    }
   } ; close $file
   # End Of File
  }
 } ; return 1
}

foreach temp [array names listmc] {
 if {[string tolower $temp] != $temp} {
  set listmc([string tolower $temp]) $listmc($temp)
  unset listmc($temp)
 }
}

if {$mc_rf(svs:enabled)} {
 if {($mc_rf(svs:check) > "23") || ($mc_rf(svs:check) < "0")} {set mc_rf(svs:check) 0}
 bind time - "* $mc_rf(svs:check) * * *" mc:rf:svs:time
 proc mc:rf:svs:time {min hour day month year} {
  global mc_rf
  catch {control [connect [lindex $mc_rf(svs:server) 0] [lindex $mc_rf(svs:server) 1]] mc:rf:svs:interface}
 }
}
proc mc:rf:svs:interface {idx args} {
 global mc_rf;set args [join $args]
 switch -- [lindex $args 0] {
  "" {return 1}
  000 {putdcc $idx q}
  002 {putdcc $idx [lindex $mc_rf(svs:script) 0]}
  003 {
   set args [lrange $args 1 e]
   if {[lindex $args 0] != [lindex $mc_rf(svs:script) 0]} {return 0}
   if {[lindex $args 1] > [lindex $mc_rf(svs:script) 1]} {
    foreach notify [join [split $mc_rf(svs:notify) ",;"]] {
     switch -- [sendnote SVS $notify "The version of [lindex $args 2] you are using is old.  The current version is [lindex $args 3], and your using $mc_rf(version).  You can find this newer version at http://bseen.tclslave.net/search.html or from ftp.eggheads.org."] {
      0 {putlog "MC SVS for [lindex $mc_rf(svs:script) 0] had some errors updating $notify on current version of script; unknown reason!"}
      3 {putlog "MC SVS for [lindex $mc_rf(svs:script) 0] had some errors updating $notify on current version of script; notebox too full!"}
     }
    }
   } ; putdcc $idx q
  }
 } ; return 0
}

putlog "Serverstatus loaded"

Content of serverstatus.php
Code: Select all
<?php 
$ipaddr = "127.0.0.1";
$port = "5121";
$timeout = 19;
$connect = fsockopen( "udp://" . $ipaddr, $port, $errno, $errstr, $timeout );
if ( ! $connect )   {
   print( "Server is down [21~" );
   print( ">ERROR: $errno - $errstr</h3>" );
   exit;
} else {
   socket_set_timeout( $connect, $timeout );
   $send = "\xFE\xFD\x00\xE0\xEB\x2D\x0E\x14\x01\x0B\x01\x05\x08\x0A\x33\x34\x35\x13\x04\x36\x37\x38\x39\x14\x3A\x3B\x3C\x3D\x00\x00";
   fwrite( $connect, $send );
   $output = fread( $connect, 5000 );
   if ( ! $output ) {
      print ( "NWN2 Server down!");
   } else {
      $lines = explode( "\x00", $output );
      print( "NWN Server >> ONLINE << - Mod: $lines[4] - Spieler: $lines[5]/$lines[6] -" );
      $dlines = explode( "\n", $lines[15] );
   }
}
fclose( $connect );         
?>


Everything works except that it does not show "mod&players" from my et server, output etc. works just fine
jameS
 

Re: modify this GameServer !status script

Postby jonlar » Sun Jun 20, 2010 5:18 pm

Is it possible to rewrite the File(s) to use for more ips:ports ?

I would like to use this for my bnc servers
jonlar
 


Return to TCL Scripting Request

Who is online

Users browsing this forum: No registered users and 1 guest

cron