Exemplo n.º 1
0
 public function updateScores($player, $perp, $vic)
 {
     //echo "VIC=$vic PERP=$perp\n";//##DEBUG
     if ($this->cfg["settings"]["points"] || $this->cfg["settings"]["rewards"]) {
         list($points, $money) = $this->getPrizes($vic);
         if (!$this->cfg["settings"]["points"]) {
             $points = false;
         }
         if (!$this->cfg["settings"]["rewards"]) {
             $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()) {
         $this->updateDb($perp, $vic, $ev->getIncr());
     }
     $awards = [false, false];
     $awards[0] = $points = $ev->getPoints();
     if ($points !== false && $points != 0) {
         $this->updateDb($perp, "points", $points);
     }
     $awards[1] = $money = $ev->getMoney();
     if ($money !== false) {
         MoneyAPI::grantMoney($this->money, $perp, $money);
     }
     return $awards;
 }
Exemplo n.º 2
0
 public function updateScores($player, $perp, $vic)
 {
     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;
 }