0 Members and 1 Guest are viewing this topic.
<?php/** Teams Module for BE Bot <http://bebot.fieses.net>* Module coded by Craized <http://www.craized.net>/*Add a "_" at the beginning of the file (Teams.php) if you do not want it to be loaded.*/$teams = new Teams($bot);$commands["pgmsg"]["teams"] = &$teams;$commands["pgjoin"][] = &$teams;$commands["pgleave"][] = &$teams;/*The Class itself...*/class Teams{ var $bot; var $pgroup; /* Constructor: Hands over a referance to the "Bot" class. */ function Teams (&$bot) { $this -> bot = &$bot; } /* This gets called on a msg in the privgroup with the command */ function pgmsg($name, $msg) { $msg = explode(" ", $msg); $red = "<font color=#FF0000>"; if ($msg[1] == "") { $teams = ceil(count($this -> pgroup)/6); for($num=1; $num<=$teams; $num++) { $result .= $red . $num . ": LDR "; for($spot=1; $spot<=6; $spot++) { if($this -> team -> $num[$spot]) { if($spot == 1) { $result .= $this -> team -> $num[$spot]; } else { $result .= " - " . $spot . "." . $this -> team -> $num[$spot]; } } } $this -> bot -> send_pgroup($result); } } if($msg[1] == "clear") { foreach($this -> pgroup as $player) { $this -> pgroup[$player] = "lft"; unset($this -> team); } $this -> bot -> send_pgroup($red . "Teams cleared"); } if(preg_match("#^[0-9]#", $msg[1], $info)) { $team = $msg[1]; $spot = count($this -> team)+1; if ($spot <= 6){ if($msg[2] == "") { $this -> team -> $team[$spot] = $name; $this -> bot -> send_pgroup($red . $name . " assigned to team " . $msg[1]); } else { $user = ucfirst($msg[2]); if($this -> pgroup[$user]) { $this -> team -> $team[$spot] = $user; $this -> bot -> send_pgroup($red . $user . " assigned to team " . $msg[1] . " in spot " . $spot); } else { $this -> bot -> send_pgroup($red . $msg[2] . " not in " . $this -> bot -> botname); } } } else { $this -> bot -> send_pgroup($red . "Sorry, team " . $team . " is currently full."); } } if($msg[1] == spot) { $team = $msg[2]; $count = count($this -> team)+1; $this -> bot -> send_pgroup($count); } } /* This gets called if someone joins the privgroup */ function pgjoin($name) { $this -> pgroup[$name] = "lft"; } /* This gets called if someone leaves the privgroup */ function pgleave($name) { if (isset($this -> pgroup[$name])) { unset($this -> pgroup[$name]); } }}?>
function pgjoin($name) { if(!$this -> pgroup[$name]) { $this -> pgroup[$name] = "lft"; $this -> teams = ceil(count($this -> pgroup)/6); } } /* This gets called if someone leaves the privgroup */ function pgleave($name) { if ($this -> pgroup[$name] == "lft") { unset($this -> pgroup[$name]); } }