public function scoreStreak(Player $player) { if (!$this->enabled) { return false; } $n = strtolower($player->getName()); $streak = $this->owner->updateDb($n, "streak"); if ($streak < $this->minkills) { return false; } $this->owner->getServer()->getPluginManager()->callEvent(new KillRateNewStreakEvent($this->owner, $player, $streak)); $this->owner->getServer()->broadcastMessage(TextFormat::YELLOW . mc::_("%1% has a %2%-kill streak", $player->getDisplayName(), $streak)); if ($this->money === null) { return true; } list($points, $money) = $this->owner->getPrizes("streak"); $this->owner->getServer()->getPluginManager()->callEvent($ev = new KillRateBonusScoreEvent($this->owner, $player, $money)); if ($ev->isCancelled()) { return true; } $player->sendMessage(TextFormat::GREEN . mc::_("You earn an additional \$%1% for being in kill-streak!", $ev->getMoney())); MoneyAPI::grantMoney($this->money, $player, $ev->getMoney()); return true; }
public function activateSign($pl, $tile) { $sign = $tile->getText(); $mode = $this->cfg["signs"][$sign[0]]; switch ($mode) { case "stats": $name = $pl->getName(); $text = ["", "", "", ""]; $text[0] = mc::_("Stats: %1%", $name); $l = 1; foreach (["Player" => mc::_("Kills: "), "points" => mc::_("Points: ")] as $i => $j) { $score = $this->dbm->getScore($name, $i); if ($score) { $score = $score["count"]; } else { $score = "N/A"; } $text[$l++] = $j . $score; } $text[$l++] = mc::_("Money: ") . MoneyAPI::getMoney($this->money, $name); break; case "online-tops": $text = $this->topSign(true, "default", mc::_("Top Online"), $sign); break; case "rankings": $text = $this->topSign(false, "default", mc::_("Top Players"), $sign); break; case "rankings-names": $text = $this->topSign(false, "names", mc::_("Top Names"), $sign); break; case "rankings-points": $text = $this->topSign(false, "scores", mc::_("Top Scores"), $sign); break; case "online-top-names": $text = $this->topSign(true, "names", mc::_("On-line Names"), $sign); break; case "online-top-points": $text = $this->topSign(true, "scores", mc::_("On-line Scores"), $sign); break; default: return; } $this->updateSign($pl, $tile, $text); }
public function updateScores($player, $perp, $vic) { //echo "VIC=$vic PERP=$perp\n";//##DEBUG if ($this->settings["points"] || $this->money !== null) { list($points, $money) = $this->getPrizes($vic); if (!$this->settings["points"]) { $points = false; } if (!$this->money !== null) { $money = false; } } else { list($points, $money) = [false, false]; } $this->getServer()->getPluginManager()->callEvent($ev = new KillRateScoreEvent($this, $player, $vic, $points, $money)); if ($ev->isCancelled()) { return [false, false]; } if ($ev->getIncr()) { $kills = $this->updateDb($perp, $vic, $ev->getIncr()); } else { $kills = null; } $awards = [false, false]; $awards[0] = $points = $ev->getPoints(); if ($points !== false && $points != 0) { $newscore = $this->updateDb($perp, "points", $points); } else { $newscore = null; } $awards[1] = $money = $ev->getMoney(); if ($money !== false) { MoneyAPI::grantMoney($this->money, $perp, $money); } $this->achievements->awardKills($player, $vic, $kills); if ($newscore !== null) { $this->ranks->promote($player, $newscore); } return $awards; }