public function getStats($new = 604800) { $info = new TeamInfo(); $data = $this->main->getMySQLi()->query("SELECT COUNT(*)AS cnt,SUM((SELECT kills FROM kitpvp WHERE uid=players.uid))AS kills,SUM((SELECT deaths FROM kitpvp WHERE uid=players.uid))AS deaths,MAX((SELECT maxstreak FROM kitpvp WHERE uid=players.uid))AS pvpmaxstreak,SUM((SELECT completions FROM parkour WHERE uid=players.uid))AS completions,SUM((SELECT falls FROM parkour WHERE uid=players.uid))AS falls,SUM((SELECT tmpfalls FROM parkour WHERE uid=players.uid))AS tmpfalls,SUM((SELECT wins FROM spleef WHERE uid=players.uid))AS wins,SUM((SELECT losses FROM spleef WHERE uid=players.uid))AS losses,SUM((SELECT draws FROM spleef WHERE uid=players.uid))AS draws,MAX((SELECT maxstreak FROM spleef WHERE uid=players.uid))AS spleefmaxstreak FROM players WHERE tid={$this->tid} AND teamjointime<=unix_timestamp()-{$new}", MysqlConnection::ASSOC); $info->oldMembers = $data["cnt"]; $info->totalMembers = count($this->members); $info->pvpKills = $data["kills"]; $info->pvpDeaths = $data["deaths"]; $info->pvpMaxStreak = $data["pvpmaxstreak"]; $info->parkourWins = $data["completions"]; $info->parkourFalls = $data["falls"]; $info->parkourTmpFalls = $data["tmpfalls"]; $info->spleefWins = $data["wins"]; $info->spleefLosses = $data["losses"]; $info->spleefDraws = $data["draws"]; $info->spleefMaxStreak = $data["spleefmaxstreak"]; return $info; }
public function __construct(LegionPE $main) { parent::__construct($main); $this->main = $main; $main->getServer()->getScheduler()->scheduleDelayedRepeatingTask($this, 2400, 2400); $this->sql = new \SQLite3(":memory:"); $this->sql->exec("CREATE TABLE teams (id INTEGER PRIMARY KEY, name TEXT COLLATE NOCASE, open INTEGER)"); $this->main->getMySQLi()->query("UPDATE teams SET has_founder=0 WHERE isnull((SELECT uid FROM players WHERE tid=teams.tid AND teamrank=%d))", MysqlConnection::RAW, Team::RANK_LEADER); $this->main->getMySQLi()->query("UPDATE players SET tid=-1,teamrank=0 WHERE(SELECT has_founder FROM teams WHERE tid=players.tid)=0", MysqlConnection::RAW); $this->main->getMySQLi()->query("DELETE FROM teams WHERE(SELECT COUNT(*)FROM players WHERE players.tid=teams.tid)=0", MysqlConnection::RAW); foreach ($this->main->getMySQLi()->query("SELECT *,(SELECT rank FROM players WHERE tid=teams.tid AND teamrank=4 LIMIT 1)AS leaderrank FROM teams", MysqlConnection::ALL) as $row) { $tid = (int) $row["tid"]; $members = []; foreach ($this->main->getMySQLi()->query("SELECT uid,teamrank FROM players WHERE tid={$tid}", MysqlConnection::ALL) as $member) { $members[(int) $member["uid"]] = (int) $member["teamrank"]; } $this->teams[$tid] = new Team($main, $tid, $row["name"], Settings::team_maxCapacity($row["leaderrank"]), (bool) (int) $row["open"], $members, isset($row["invited"]) ? $row["invited"] : "", isset($row["requires"]) ? $row["requires"] : "", isset($row["rules"]) ? $row["rules"] : ""); $op = $this->sql->prepare("INSERT INTO teams (id, name, open)VALUES(:id, :name, :open)"); $op->bindValue(":id", $tid); $op->bindValue(":name", $row["name"]); $op->bindValue(":open", $row["open"]); $op->execute(); } }
public function update() { if ($this->changed) { $this->main->getMySQLi()->query("INSERT INTO parkour(uid,progress,completions,falls,tmpfalls)VALUES({$this->session->getUID()},{$this->progress},{$this->completions},{$this->falls},{$this->tmpFalls})ON DUPLICATE KEY UPDATE progress={$this->progress},completions={$this->completions},falls={$this->falls},tmpfalls={$this->tmpFalls};", MysqlConnection::RAW); } }
private function handleRegisterMessage(PlayerCommandPreprocessEvent $event) { $event->setCancelled(); $msg = $event->getMessage(); $this->tell(str_repeat("~", 34)); if ($this->session === self::SESSION_REG_INTRO) { if (substr($msg, 0, 1) === "/") { $this->tell("I don't think a password starting with a slash is a good idea..."); $this->tell("Register by typing your password directly into chat!"); return; } elseif (strlen($msg) < 4) { $this->tell("Seriously? Don't you think it is too short to be guessed? Make at least 4 characters."); $this->tell("Try again."); return; } $this->tmpPswd = self::hash($msg); $this->tell("Thank you. Now, please type in your password again to confirm you didn't enter the wrong thing."); $this->session = self::SESSION_REG_REP; } elseif ($this->session === self::SESSION_REG_REP) { if (self::hash($msg) === $this->tmpPswd) { $this->tell("The password matched."); $this->tellIPAuthSettings(); $this->session = self::SESSION_REG_IP; } else { $this->tell("The password doesn't match! Let's start all over again..."); $this->session = self::SESSION_REG_INTRO; $this->tell("To protect your account, please register your username (%s) by typing a password directly into chat and send it.", $this->getPlayer()->getName()); $this->tell("Don't worry, nobody else will see that."); $this->tell("And remember, don't forget your password!"); } } elseif ($this->session === self::SESSION_REG_IP) { switch (strtolower($msg)) { case "no": $this->tell("OK, thanks. You can always change this option via /auth."); $ipconfig = self::IPCONFIG_DISABLE; break; case "yes": $this->tell("Sure! You can always change this option via /auth."); $ipconfig = self::IPCONFIG_LASTIP; break; case "all": $this->tell("Sorry, historical IP is now disabled."); $this->tell("Maybe I should repeat?"); $this->tellIPAuthSettings(); return; // $this->tell("OK. You can always change this option via /auth."); // $ipconfig = self::IPCONFIG_ANYIP; // break; // $this->tell("OK. You can always change this option via /auth."); // $ipconfig = self::IPCONFIG_ANYIP; // break; default: $this->tell("Sorry... I don't understand what the word '{$msg}' means."); $this->tell("Maybe I should repeat?"); $this->tellIPAuthSettings(); return; } $this->uid = $this->main->getMySQLi()->nextUID(); $data = ["uid" => $this->getUID(), "names" => $this->getPlayer()->getName() . "|", "hash" => $this->tmpPswd, "coins" => 100, "lastonline" => time(), "registry" => time(), "rank" => 0, "lastip" => $this->getPlayer()->getAddress(), "histip" => $this->getPlayer()->getAddress(), "ipconfig" => $ipconfig, "notag" => 0, "lastgrind" => 0, "tid" => -1, "teamrank" => 0, "teamjointime" => 0, "ignoring" => ",", "primaryname" => strtolower($this->getPlayer()->getName()), "ads" => 0, "caps" => 0, "swears" => 0, "spams" => 0, "imposes" => 0, "chatwarns" => 0, "flies" => 0, "sprints" => 0, "ghwarns" => 0, "modswarns" => 0, "miscwarns" => 0, "ontime" => 0, "warnpts" => 0]; $this->mysqlSession->setData($data); $this->auth("registration"); } }