This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

CounterStrike Source

Old posts that have not been replied to for several years.
Locked
f
fade85
Voice
Posts: 4
Joined: Mon May 09, 2005 2:35 pm

CounterStrike Source

Post by fade85 »

Hi.

Ok, here's the thing.

I have a working eggdrop bot, on my irc channel.
I have the latest qstat, so I can check up halflife 2 servers and show the information (players online,map)
Thing is, I want the eggbot, to react to a certain command, to show off this information.
I'm actually kinda new to this, so please excuse me if my question is stupidly asked. :roll:
I'm using windows XP for the server computer.

Thanks.
User avatar
^DooM^
Owner
Posts: 772
Joined: Tue Aug 26, 2003 5:40 pm
Location: IronForge
Contact:

Post by ^DooM^ »

It can be done but without the script to modify your question is about as much use as an inflateable dartboard :lol:
The lifecycle of a noob is complex. Fledgling noobs gestate inside biometric pods. Once a budding noob has matured thru gestation they climb out of their pod, sit down at a PC, ask a bunch of questions that are clearly in the FAQ, The Noob is born
f
fade85
Voice
Posts: 4
Joined: Mon May 09, 2005 2:35 pm

Post by fade85 »

Code: Select all

#
# qstat4eggdrop.tcl v1.0
#
# A little script to redirect output of Qstat to IRC 
# for eggdrop 1.4
# Author: Mikael Blomqvist (micke@peachpuff.com)
#
# http://eggdrop.peachpuff.com/
#
# Sometimes I don't get along with Tcl, so please don't complain too
# much about the code. Comments are very welcome though.
# There was an earlier version of this script which only managed to list QW servers
# This is a completely rewritten one which supports everything that Qstat does (hopefully)

# ATM all the files has to be in the same directory as the bot is started (including qstat).
# You can ofcourse change the exec lines in exec_get_servers & exec_get_servers_with_players
# if you want to move them.
#


# public commands
bind pub -|- !help help
bind pub -|- !q q
bind pub -|- !qp qplayers
bind pub -|- !qf qfind

proc help {nick host hand chan arg} {
    putserv "NOTICE $nick :Commands:"
    putserv "NOTICE $nick : !q <searchword>; List servers"
    putserv "NOTICE $nick : !qf <player searchword>; Search for players on all servers"
    putserv "NOTICE $nick : !qp <searchword>; Display all players on matched servers"
    return 0
}
proc exec_get_servers {} {
    return [exec ./qstat -sort g -default qws -Ts server.qstat -Tp players.qstat -f qstat4eggdrop.lst]
}
proc exec_get_servers_with_players {} {
    return [exec ./qstat -sort g -default qws -Ts server.qstat -Tp players.qstat -f qstat4eggdrop.lst -P]
}

proc get_number_of {i type} {
    switch -exact $i {
	0 {
	    return "No ${type}s found."
	}
	1 {
	    return "1 $type found."
	}
	default {
	    return "$i ${type}s found."
	}
    }
}

proc sort2 {a b} {
    set tal1 [string trim [string range $a 0 2]]
    set tal2 [string trim [string range $b 0 2]]
    return [expr int($tal1) < int($tal2)]
}

proc q {nick host hand chan arg} {
    set stat [exec_get_servers]
    set stat_arr [split $stat "\n"]
    set i 0
    set str [lsort $stat_arr]
    set players [list]
    set found 0
    if {[llength $arg] == 1} then {
	foreach rad $str {
	    if {[string first $arg [string tolower $rad]] != -1} then {
		incr i
		putquick "NOTICE $nick :$rad"
		incr found
	    }
	}
    } else {
	foreach rad $str {
	    incr i
	    putquick "NOTICE $nick :$i: $rad"
	    incr found
	}
    }
    set info_str [get_number_of $found "server"]
    putquick "NOTICE $nick :$info_str"
    return 0
}

proc qplayers {nick host hand chan arg} {
    if {[llength $arg] < 1} then {
	putquick "NOTICE $nick : You might wanna put in a search word to limit the list a bit"
	return
    }
    set stat [exec_get_servers_with_players]
    set stat_arr [split $stat "\n"]
    set str $stat_arr
    set found 0
    set players_found 0
    for {set i 0} {$i < [llength $str]} {incr i} {
	if {[string range [lindex $str $i] 0 6] != "Player:"} then {
	    if {[string first $arg [string tolower [lindex $str $i]]] != -1} then {
		incr found
		set players [list]
		set j [expr $i + 1]
		# Loop through all the players and save them into a list
		while {[string range [lindex $str $j] 0 6] == "Player:"} {
		    lappend players [string trimleft [lindex $str $j] "Player:"]
		    incr j
		    incr players_found
		}
		# Display server
		putquick "NOTICE $nick :[lindex $str $i]"
		# If we have any players list them up sorted
		if {[llength $players] > 0} then {
		    foreach player [lsort -command sort2 $players] {
			putquick "NOTICE $nick :  $player"
		    }
		}
	    }
	}
    }
    set info_str [get_number_of $found "server"]
    set info_str2 [get_number_of $players_found "player"]
    putquick "NOTICE $nick :$info_str $info_str2"
    return 0
}

proc qfind {nick host hand chan arg} {
    if {[llength $arg] < 1} then {
	putquick "NOTICE $nick : You might wanna put in a search word to limit the list a bit"
	return
    }
    set stat [exec_get_servers_with_players]
    set stat_arr [split $stat "\n"]
    set i 0
    set str $stat_arr
    set found 0
    #    set str [lsort $stat_arr]
    for {set i 0} {$i < [llength $str]} {incr i} {
	set j [expr $i + 1]
	# Loop through all the players and save them into a list
	while {[string range [lindex $str $j] 0 6] == "Player:"} {
	    set player [string trimleft [lindex $str $j] "Player:"]
	    set playername [lindex [split $player " "] 2]
	    set server [join [lindex [split [lindex $str $i] ""] 1] " "]
	    if {[string first [string tolower $arg] [string tolower $playername]] != -1} then {
		incr found
		putquick "NOTICE $nick :$playername is on $server"
	    }
	    incr j
	}
	# Make sure we don't check through the players again
	set i [expr $j - 1]
    }
    set info_str [get_number_of $found "player"]
    putquick "NOTICE $nick :$info_str"
    return 0
}
 
The command I want to add, is -hl2s

To execute qstat.exe and show the information (in command prompt), i type qstat -hl2s IP
And, I want it parsed into a IRC channel.

Thanks for the quick reply.
User avatar
^DooM^
Owner
Posts: 772
Joined: Tue Aug 26, 2003 5:40 pm
Location: IronForge
Contact:

Post by ^DooM^ »

What are you using this script for? And are you actually running this on your Windrop?
The lifecycle of a noob is complex. Fledgling noobs gestate inside biometric pods. Once a budding noob has matured thru gestation they climb out of their pod, sit down at a PC, ask a bunch of questions that are clearly in the FAQ, The Noob is born
f
fade85
Voice
Posts: 4
Joined: Mon May 09, 2005 2:35 pm

Post by fade85 »

It's used, for people to be able to type !q in the channel, and it lists CounterStrike servers (that I have in another file)
with players on it, the score, etc.
And yes, I tried it on my eggbot, and it worked fine, 'cept that it don't recognize the command that is in the new qstat version for halflife2.
User avatar
^DooM^
Owner
Posts: 772
Joined: Tue Aug 26, 2003 5:40 pm
Location: IronForge
Contact:

Post by ^DooM^ »

Paste the new version lets try and fix that one rather than adding complete new code.
The lifecycle of a noob is complex. Fledgling noobs gestate inside biometric pods. Once a budding noob has matured thru gestation they climb out of their pod, sit down at a PC, ask a bunch of questions that are clearly in the FAQ, The Noob is born
f
fade85
Voice
Posts: 4
Joined: Mon May 09, 2005 2:35 pm

Post by fade85 »

the new version is'nt in ltc..it's in .c
and, it's way too much text to post here. :roll:
Locked