CBPug
Posted by Young~Money
Tuesday, August 17, 2004
Description: C-Bots Pug Bot

Just remember the bots needs ops, and DONT FORGET to private message the bot and say .owner as soon as it is put up. First to do it gets ownership :)


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;; CBPug Bot                              ;;;;;
;;;;; Version: 2.0                           ;;;;;
;;;;; Author: youngMoney                     ;;;;;
;;;;; Notes: -Part of the C-Bots family      ;;;;;
;;;;;        -When first loading the bot,    ;;;;;
;;;;;         query the bot and say .owner   ;;;;;
;;;;;         to give yourself ownership     ;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ON *:START:{
  hmake pusers 10
  hmake pservers 10
  hmake pstaff
  set %slots 10
  set %doing 1
  if (!%pug.num) {
    set %pug.num 1
  }
  hload pstaff pstaff.hsh
  hload pservers pservers.hsh

}
on *:text:.view:#:{
  var %done 1
  var %need %slots
  var %pusers [^K]10×[^K]3 Pug Userlist: [^K]10 $chr(91)
  var %x 1
  while (%x <= $hget(pusers,0).item) {
    var %pusers %pusers $hget(pusers, $+ %x $+ ).data
    inc %done
    inc %x
  }
  while (%done <= %need) {
    var %pusers %pusers [^K]12·
    inc %done
  }
  msg $chan %pusers [^K]10 $chr(93) [^K]7 $calc(%slots - $hget(pusers,0).item) Remaining slots [^K]10×
}
ON *:TEXT:.list:#:{
  if ($hfind(pusers,*,0,w) == 0) {
    msg $chan [^K]10×[^K]3 There are no people in line for a pug. [^K]10×
  }
  else {
    set %x 1
    unset %pusers
    while (%x <= $hget(pusers,0).item) {
      if (%pusers) {
        var %pusers %pusers $hget(pusers, $+ %x $+ ).data
      }
      else {
        var %pusers $hget(pusers, $+ %x $+ ).data
      }
      inc %x
    }
    msg $chan [^K]10×[^K]3 Pug List: [^K]10 $chr(91) %pusers $chr(93) [^K]7 $calc(%slots - $hget(pusers,0).item) Remaining slots [^K]10×
  }
}
on *:text:.help:#:{
  if (%doing == 1) {
    set %doing 2
    sleep 500
    msg $chan [^K]10×[^K]3 [^B].slots [#][^B] use to set the number of slots for the pug. Must be between 2-16. [^K]10×
    sleep 500
    msg $chan [^K]10×[^K]3 [^B].join[^B] use to join the pug list. [^K]10×
    sleep 500
    msg $chan [^K]10×[^K]3 [^B].quit[^B] use to quit the pug list. [^K]10×
    sleep 500
    msg $chan [^K]10×[^K]3 [^B].startpug[^B] use to manually start the pug. [^K]10×
    sleep 500
    msg $chan [^K]10×[^K]3 [^B].view[^B] use to view the pug list. [^K]10×
    sleep 500
    msg $chan [^K]10×[^K]3 [^B].servers[^B] use to view the server list. [^K]10×
    sleep 500
    msg $chan [^K]10×[^K]3 [^B].numbers[^B] use to view the amount of pugs served. [^K]10×
    sleep 500
    msg $chan [^K]10×[^K]3 [^B].about[^B] use to view info the the pug bot. [^K]10×
    if ($paccess > 100) {
      cnotice $nick $chan [^K]10×[^K]3 [^B].ahelp[^B] admin control help. [^K]10×
    }
    timer 1 10 set %doing 1
  }
  else {
    halt
  }
}
on *:text:.ahelp:#:{
  if (%doing == 1) {
    if ($paccess > 100) {
      set %doing 2
      sleep 500
      cnotice $nick $chan [^K]10×[^K]3 [^U]Admin Controls[^U] [^K]10×
      sleep 500
      cnotice $nick $chan [^K]10×[^K]3 [^B].addserver [IP][^B] use to add a server to the list. (100+ Access) [^K]10×
      sleep 500
      cnotice $nick $chan [^K]10×[^K]3 [^B].delserver [IP][^B] use to delete a server from the list. (100+ Access) [^K]10×
      sleep 500
      cnotice $nick $chan [^K]10×[^K]3 [^B].clearpug[^B] use to clear the pug list. (100+ Access) [^K]10×
      sleep 500
      cnotice $nick $chan [^K]10×[^K]3 [^B].addadmin [Access][^B] use to add an admin. (200+ Access) [^K]10×
      sleep 500
      cnotice $nick $chan [^K]10×[^K]3 [^B].deladmin[^B] use to delete an admin. (200+ Access) [^K]10×
      timer 1 10 set %doing 1
    }
  }
  else {
    halt
  }
}
on *:text:.numbers:#:{
  msg $chan [^K]10×[^K]3 I have served[^K]7 %pug.num [^K]3pugs. [^K]10×
}
on *:text:.about:#:{
  msg $chan [^K]10×[^K]3 I am using[^K]7 CBPug Bot v2.0[^K]3, a bot in the C-Bots family line.  [^K]10×
  msg $chan [^K]10×[^K]3 C-Bots were/are created by [^K]7youngMoney [^K]10×
}
ON *:TEXT:.owner:?:{
  if ($hfind(pstaff,500,1,w).data) {
    msg $nick [^K]10×[^K]3 The owner is already set to the hostmask $hfind(pstaff,500,1,w).data [^K]10×
  }
  else {
    hadd pstaff $address($nick,2) 500
    hsave pstaff pstaff.hsh
    msg $nick [^K]10×[^K]3 You have been added as the owner. [^K]10×
  }
}
ON *:TEXT:.addadmin*:#:{
  if ($paccess >= 200) {
    if (!$3) {
      hadd pstaff $address($2,2) 200
      hsave pstaff pstaff.hsh
      notice $nick [^K]10×[^K]3 $2 has been added with 200 access. [^K]10×
    }
    else {
      if ($paccess > $3) {
        hadd pstaff $address($2,2) $3
        hsave pstaff pstaff.hsh
        notice $nick [^K]10×[^K]3 $2 has been added with $3 access. [^K]10×
      }
    }
  }
  else {
    notice $nick [^K]10×[^K]3 You do not have the access to use this command. [^K]10×
  }
}
ON *:TEXT:.deladmin*:#:{
  if ($paccess >= 200) && ($paccess > $hget(pstaff,$address($2,2))) {
    hdel pstaff $address($2,2)
    hsave pstaff pstaff.hsh
    notice $nick [^K]10×[^K]3 $2 has had their access deleted. [^K]10×
  }
  else {
    notice $nick [^K]10×[^K]3 You do not have the access to use this command. [^K]10×
  }
}

ON *:TEXT:.slots*:#:{
  if (!$2) {
    msg $chan [^K]10×[^K]3 Number of slots for pug is set to[^K]7 %slots [^K]10×
  }
  else {
    if ($2 isnum 2-16) {
      set %slots $2
      msg $chan [^K]10×[^K]3 The number of slots for pug is now set to[^K]7 %slots [^K]10×
    }
    else {
      notice $nick [^K]10×[^K]3 That is an invalid number of slots. [^K]10×
    }
  }
}
ON *:TEXT:.clearpug:#:{
  if ($paccess >= 100) {
    hfree pusers
    hmake pusers
    msg $chan [^K]10×[^K]3 The pug information has been cleared. [^K]10×
  }
}
ON *:TEXT:.join:#:{
  if ($hfind(pusers,*,0,w) <= %slots ) {
    hadd -u600 pusers $address($nick,2) $nick
    msg $chan [^K]10×[^K]3 Player[^K]7 $nick [^K]3added.[^K]7 $$calc(%slots - $hget(pusers,0).item) [^K]3slots remaining. [^K]10×
  }
  if ($hfind(pusers,*,0,w) == %slots ) {
    startpug
  }
}
ON *:TEXT:.quit:#:{
  hdel pusers $address($nick,2)
  msg $chan [^K]10×[^K]3 Player[^K]7 $nick [^K]3has been removed.[^K]7 $calc(%slots - $hget(pusers,0).item) [^K]3slots remaining. [^K]10×
}
ON *:NICK:{
  if ($hget(pusers,$address($newnick,2))) {
    hadd -u600 pusers $address($newnick,2) $newnick
  }
}
ON *:EXIT:{
  if ($hfind(pusers,$nick,1).data) {
    hdel pusers $hfind(pusers,$nick,1,w).data
    msg $chan [^K]10×[^K]3 Player[^K]7 $nick [^K]3removed (Exit).[^K]7 $calc(10- $hget(pusers,0).item) [^K]3slots remaining. [^K]10×
  }
}
on *:PART:#:{
  if ($hfind(pusers,$nick,1).data) {
    hdel pusers $hfind(pusers,$nick,1,w).data
    msg $chan [^K]10×[^K]3 Player[^K]7 $nick [^K]3removed (Exit).[^K]7 $calc(10- $hget(pusers,0).item) [^K]3slots remaining. [^K]10×
  }
}
ON *:TEXT:.servers:#:{
  if ($hfind(pservers,*,0,w) == 0) {
    msg $chan [^K]10×[^K]3 There are no servers set for the pug. To add yours, type .addserver [^B]ip:port [^K]10×
  }
  else {
    set %x 1
    while (%x <= $hget(pservers,0).item) {
      var %pservers %pservers [^B]IP:[^B] $hget(pservers, $+ %x $+ ).item [^B]PW:[^B] $hget(pservers, $+ %x $+ ).data  
      inc %x
    }
    msg $chan [^K]10×[^K]3 Server List: [^K]10 %pservers [^K]10×
  }
}
ON *:TEXT:.addserver*:#:{
  if ($paccess >= 100) {
    hadd pservers $2 $3
    hsave -o pservers pservers.hsh
    notice $nick [^K]10×[^K]3 Server has been added. [^K]10×
  }
}
ON *:TEXT:.delserver*:#:{
  if ($hfind(pservers,$2,1,W)) && ($paccess >= 100) {
    hdel pservers $2
    hsave -o pservers pservers.hsh
    notice $nick [^K]10×[^K]3 Server has been deleted from the list. [^K]10×
  }
}
ON *:TEXT:.startpug:#:{
  startpug
}
on *:text:.a*:#:{
  if (!$2) {
    if ($hget(pstaff,$address($nick,2))) {
      notice $nick You have $hget(pstaff,$address($nick,2)) access.
    }
    else {
      notice $nick You lack access.
    }
  }
  else {
    if ($hget(pstaff,$address($2,2))) {
      notice $nick $2 has $hget(pstaff,$address($2,2)) access
    }
    else {
      notice $nick $2 lacks access.
    }
  }
}
ctcp *:version:*:/ctcpreply $nick VERSION CBPug v2.0 by youngMoney
alias startpug {
  if ($hget(pusers,0).item == %slots) {
    if ($hget(pservers,0).item > 0) {
      var %x 1
      var %y $calc($hget(pusers,0).item /2+1))
      var %terrorists [^B]Terrorists:[^B]
      var %counterterrorists [^B]Counter-Terrorists:[^B]
      var %half $calc($hget(pusers,0).item $+ /2)
      while (%x <= $calc($hget(pusers,0).item /2)) {
        var %terrorists %terrorists $hget(pusers, $+ %x $+ ).data
        cprivmsg $hget(pusers, $+ %x $+ ).data $chan [^K]10×[^K]3 Pug now starting. Check $chan for more information. [^K]10×
        inc %x
      }
      while (%y <= $calc($hget(pusers,0).item)) {
        var %counterterrorists %counterterrorists $hget(pusers, $+ %y $+ ).data
        cprivmsg $hget(pusers, $+ %y $+ ).data $chan [^K]10×[^K]3 Pug now starting. Check $chan for more information. [^K]10×
        inc %y
      }
      msg $chan [^K]10× [^K]15,14The Pug is now starting. Please choose a server from the .servers list.[^K] [^K]10×
      msg $chan [^K]10× [^K]15,14The teams are:[^K] [^K]10×
      msg $chan [^K]10×[^K]3 [^K]0,4 $+ %counterterrorists  $+ [^K] [^K]10×
      msg $chan [^K]10×[^K]3 [^K]0,12 $+ %terrorists $+ [^K] [^K]10×
      msg $chan [^K]10× [^K]15,14This pug has been brought to you by the CBPug Bot. Enjoy your game, and please play respectfully.[^K] [^K]10×
      hfree pusers
      hmake pusers
      inc %pug.num
    }
    else {
      msg $chan [^K]10×[^K]3 There has been no server supplied for the pug. Please .addserver [^B]IP:Port[^B] and then type .startpug [^K]10×
    }
  }
  else {
    msg $chan [^K]10×[^K]3 There are not enough people for the pug. Please fill the remaining $calc(%slots - $hget(pusers,0).item) slots. [^K]10×
  }
}
alias paccess {
  return $hget(pstaff,$address($nick,2))
}
alias ipverify {
  ;; Checks for a valid ip/port
  ;; Usage: $ipverify(ip[:port])[.ip|port]
  var %regex = /((?:\d{1,3}\.){3}\d{1,3})((?::|\s)\d{1,5})*$/
  if ($regex(ip,$1,%regex)) {
    var %x = 1
    while (%x <= $gettok($regml(ip,1),0,46)) {
      if ($gettok($regml(ip,1),%x,46) > 255) return Invalid
      inc %x
    }
    if ($prop == ip) return Valid - $regml(ip,1)
    if ($prop == port) {
      if ($regml(ip,2)) {
        if ($right($ifmatch,-1) <= 65535) return Valid
        else return Invalid
      }
    }
    else return Valid
  }
  else return Invalid
}
alias sleep {
  var %a = $ticks $+ .wsf
  write %a <job id="js"><script language="jscript">WScript.Sleep( $+ $$1 $+ );</script></job>
  .comopen %a WScript.Shell
  if !$comerr { .comclose %a $com(%a,Run,3,bstr,%a,uint,0,bool,true) }
  .remove %a
}
question about the bot
Posted by Rotz
Friday, August 20, 2004 06:29am PDT
well i have figured out how to get the script installed but i cant get it to work. i dont know if im to see the bot in my channel or not but i cant see it and i dontknow how to message it so please help
Nick changings
Posted by Bruttuss
Friday, September 10, 2004 08:41pm PDT
The only bad thing is when someone changes thier nick while there on the pug liste it doesn't change the name there
rcon control
Posted by borrissk
Tuesday, October 05, 2004 12:13pm PDT
is there more to this bot or does anyone know any other pugbots available, that automatically changes the server password and allows control ingame through rcon?
Nick Changes
Posted by Young~Money
Thursday, October 14, 2004 01:09pm PDT
Bruttuss:
ON *:NICK:{
  if ($hget(pusers,$address($newnick,2))) {
    hadd -u600 pusers $address($newnick,2) $newnick
  }
}
removes players?
Posted by Secret
Sunday, September 25, 2005 10:03am PDT
The bot seems to randomly remove people after a certain amount of time without even telling them, is there a way to fix this?
Removing players
Posted by Cosmidillian
Wednesday, October 19, 2005 06:20pm PDT
i also want to know if there is  any way to not remove people off the list after a certain amount of time, thanks and also if there is a way to just completely delete the list after 15 minutes of inactivity, please help
Subject line
Posted by HellRaz0r
Monday, May 14, 2007 09:49pm PDT
if your gonna post scripts atleast make sure they work, i had to make serval changes to the script to make it work for someone and i made it alot more efficient.
Submit a comment
Oops! You need to login or register before you can post a comment!

ebaum's world