public function onScoreReset(KillRateResetEvent $ev) { $ev->getPlayer()->sendMessage("You are being demoted to Level 0!"); /* * Make sure that the default group in the PurePerms configuration * is the Level 0 group! * * This only happens if you enable the score reset when you die function * in KillRate. */ $this->pp->getUser($ev->getPlayer())->setGroup($this->pp->getDefaultGroup(), null); }
public function deadDealer($pv) { //echo __METHOD__.",".__LINE__."\n";//##DEBUG if ($pv instanceof Player) { // Score that this player died! //echo __METHOD__.",".__LINE__."\n";//##DEBUG $deaths = $this->updateDb($pv->getName(), "deaths"); if ($this->cfg["settings"]["reset-on-death"] && $this->cfg["settings"]["reset-on-death"] > 0) { if ($deaths >= $this->cfg["settings"]["reset-on-death"]) { // We died too many times... reset scores... $this->getServer()->getPluginManager()->callEvent($ev = new KillRateResetEvent($this, $pv)); if (!$ev->isCancelled()) { $this->delScore($pv); } } } if ($this->cfg["settings"]["kill-streak"]) { $n = $pv->getName(); $newstreak = $this->dbm->getScore($n, "streak"); // Keep track of the best streak ever... if ($newstreak) { $newstreak = $newstreak["count"]; $oldstreak = $this->dbm->getScore($n, "best-streak"); if ($oldstreak) { $oldstreak = $oldstreak["count"]; if ($newstreak > $oldstreak) { $this->dbm->updateScore($n, "best-streak", $newstreak); $this->getServer()->broadcastMessage(mc::_("%1% beat previous streak record of %2% at %3% kills", $n, $oldstreak, $newstreak)); } } else { $this->dbm->insertScore($n, "best-streak", $newstreak); $this->getServer()->broadcastMessage(mc::_("%1% ended his kill-streak at %2% kills", $n, $newstreak)); } } $this->dbm->delScore($n, "streak"); } } $cause = $pv->getLastDamageCause(); // If we don't know the real cause, we can score it! //echo __METHOD__.",".__LINE__."-".get_class($cause)."\n";//##DEBUG if (!$cause instanceof EntityDamageEvent) { return; } //echo __METHOD__.",".__LINE__."\n";//##DEBUG switch ($cause->getCause()) { case EntityDamageEvent::CAUSE_PROJECTILE: $pp = $cause->getDamager(); //echo get_class($pp)." PROJECTILE\n";//##DEBUG break; case EntityDamageEvent::CAUSE_ENTITY_ATTACK: $pp = $cause->getDamager(); break; case EntityDamageEvent::CAUSE_ENTITY_EXPLOSION: $pp = $cause->getDamager(); if ($pp instanceof Projectile) { $pp = $pp->shootingEntity; } //echo get_class($pp)." EXPLOSION\n";//##DEBUG break; default: //echo "Cause: ".$cause->getCause()."\n";//##DEBUG return; } //echo __METHOD__.",".__LINE__."\n";//##DEBUG if (!$pp instanceof Player) { return; } // Not killed by player... // No scoring for creative players... if ($pp->isCreative() && !$this->cfg["settings"]["creative"]) { return; } if ($this->cfg["settings"]["achievements"]) { $pp->awardAchievement("killer"); } $perp = $pp->getName(); $vic = $pv->getName(); if ($pv instanceof Player) { $vic = "Player"; // OK killed a player... check for a kill streak... $pv->sendMessage(TextFormat::RED . mc::_("You were killed by %1%!", $pp->getName())); if ($this->cfg["settings"]["kill-streak"]) { $streak = $this->updateDb($perp, "streak"); if ($streak > $this->cfg["settings"]["kill-streak"]) { if ($this->cfg["settings"]["achievements"]) { $pp->awardAchievement("serialKiller"); } $this->getServer()->broadcastMessage(TextFormat::YELLOW . mc::_("%1% has a %2% kill streak", $pp->getName(), $streak)); if ($this->cfg["settings"]["rewards"]) { list($points, $money) = $this->getPrizes($vic); $pp->sendMessage(TextFormat::GREEN . mc::_("You earn an additional \$%1% for being in kill-streak!", $money)); MoneyAPI::grantMoney($this->money, $perp, $money); } } } } $perp = $pp->getName(); list($points, $money) = $this->updateScores($pp, $perp, $vic); $this->announce($pp, $points, $money); }
public function onScoreReset(KillRateResetEvent $ev) { $ev->getPlayer()->sendMessage("You are being demoted to Level 0!"); $this->pp->getUser($ev->getPlayer())->setGroup($this->pp->getDefaultGroup(), null); }
public function deadDealer($pv) { //echo __METHOD__.",".__LINE__."\n";//##DEBUG if ($pv instanceof Player) { // Score that this player died! //echo __METHOD__.",".__LINE__."\n";//##DEBUG $deaths = $this->updateDb($pv->getName(), "deaths"); if ($this->settings["reset-on-death"] && $settings["reset-on-death"] > 0) { if ($deaths >= $this->settings["reset-on-death"]) { // We died too many times... reset scores... $this->getServer()->getPluginManager()->callEvent($ev = new KillRateResetEvent($this, $pv)); if (!$ev->isCancelled()) { $this->delScore($pv); $this->ranks($pv); } } } $this->kstreak->endStreak($pv); } $cause = $pv->getLastDamageCause(); // If we don't know the real cause, we can score it! //echo __METHOD__.",".__LINE__."-".get_class($cause)."\n";//##DEBUG if (!$cause instanceof EntityDamageEvent) { return; } //echo __METHOD__.",".__LINE__."\n";//##DEBUG switch ($cause->getCause()) { case EntityDamageEvent::CAUSE_PROJECTILE: $pp = $cause->getDamager(); //echo get_class($pp)." PROJECTILE\n";//##DEBUG break; case EntityDamageEvent::CAUSE_ENTITY_ATTACK: $pp = $cause->getDamager(); break; case EntityDamageEvent::CAUSE_ENTITY_EXPLOSION: $pp = $cause->getDamager(); if ($pp instanceof Projectile) { $pp = $pp->shootingEntity; } //echo get_class($pp)." EXPLOSION\n";//##DEBUG break; default: //echo "Cause: ".$cause->getCause()."\n";//##DEBUG return; } //echo __METHOD__.",".__LINE__."\n";//##DEBUG if (!$pp instanceof Player) { return; } // Not killed by player... // No scoring for creative players... if ($pp->isCreative() && !$this->settings["creative"]) { return; } $perp = $pp->getName(); $vic = $pv->getName(); if ($pv instanceof Player) { $vic = "Player"; // OK killed a player... check for a kill streak... $pv->sendMessage(TextFormat::RED . mc::_("You were killed by %1%!", $pp->getName())); if ($this->kstreak->scoreStreak($pp)) { $this->achievements->awardSerialKiller($pp); } } $perp = $pp->getName(); list($points, $money) = $this->updateScores($pp, $perp, $vic); $this->announce($pp, $points, $money); }