public static function execute(SR_Player $player, array $args) { if (count($args) !== 2) { $player->message(Shadowhelp::getHelp($player, 'swapkp')); return false; } if ('' === ($kp = $player->getKnowledge('places'))) { $player->msg('1023'); // $player->message('You have no known places yet.'); return false; } if (false === ($placeA = Shadowcmd_goto::getTLCByArg($player, $args[0]))) { $player->msg('1023'); // $player->message(sprintf('The first place, %s, is unknown.', $args[0])); return false; } if (false === ($placeB = Shadowcmd_goto::getTLCByArg($player, $args[1]))) { $player->msg('1023'); // $player->message(sprintf('The second place, %s, is unknown.', $args[1])); return false; } if ($placeA === $placeB) { $player->msg('1030'); // $player->message('Swapping nothing, so bailout.'); return false; } $all = explode(',', $kp); if (false === ($a = array_search($placeA, $all, true))) { $player->message('DB Error 1'); return false; } if (false === ($b = array_search($placeB, $all, true))) { $player->message('DB Error 2'); return false; } $all[$a] = $placeB; $all[$b] = $placeA; if (false === $player->saveBase('known_places', implode(',', $all))) { $player->message('DB Error 3'); return false; } return Shadowcmd_known_places::execute($player, array()); }
public function onCast(SR_Player $player, array $args, $wanted_level = true) { echo "Casting teleport with ... " . implode(',', $args) . " L{$wanted_level}\\ņ"; if (true === $this->isBrewMode()) { return $this->onBrew($player, 30, 2, 5); } echo "Casting teleport with ... " . implode(',', $args) . " L{$wanted_level}\\ņ"; $p = $player->getParty(); if (false === $p->isIdle()) { $player->msg('1033'); // $player->message('This spell only works when your party is idle.'); return false; } if (count($args) === 0) { $player->msg('1072'); // $player->message('Please specify a target to teleport to.'); return false; } $bot = Shadowrap::instance($player); if (false === ($tlc = Shadowcmd_goto::getTLCByArg($player, $args[0]))) { $player->msg('1069'); // $player->message('This location is unknown.'); return false; } $cityclass = $p->getCityClass(); if (false === ($target = $cityclass->getLocation($tlc))) { $player->msg('1070', array($p->getCity())); // $bot->reply(sprintf('The location %s does not exist in %s.', $tlc, $p->getCity())); return false; } $tlc = $target->getName(); if (!$player->hasKnowledge('places', $tlc)) { $player->msg('1023'); // $bot->reply(sprintf('You don`t know where the %s is.', $tlc)); return false; } if ($p->getLocation() === $tlc) { $player->msg('1071', array($tlc)); // $bot->reply(sprintf('You are already at the %s.', $tlc)); return false; } # Imprisoned if (false !== ($loc = $p->getLocationClass('inside'))) { if (!$loc->isExitAllowed($player)) { $player->msg('1074'); // $bot->reply('You cannot cast teleport inside this lcoation.'); return false; } } # Minlevels (thx sabretooth) if (false === $this->checkCityTargetLimits($player, $target)) { return false; } $level = $this->getLevel($this->getCaster()); $mc = $p->getMemberCount(); $need_level = $mc / 2; if ($level < $need_level) { $player->msg('1076', array($this->getName(), $need_level, $mc)); return false; // $bot->reply(sprintf('You need at least teleport level %s to teleport %s party members.', $need_level, $mc)); // return false; } $need = $this->getManaCost($player, $need_level); $have = $player->getMP(); if ($need > $have) { $player->msg('1055', array($need, $this->getName(), $need_level, $have)); return false; // $player->message(sprintf('You need %s MP to cast %s, but you only have %s.', $need, $this->getName(), $have)); // return false; } if (true === $this->isCastMode()) { $player->healMP(-$need); } $p->ntice('5133', array($player->getName(), $need, $this->getName(), $tlc)); // $p->notice(sprintf('%s used %s MP to cast teleport and your party is now outside of %s.', $player->getName(), $need, $tlc)); $p->pushAction('outside', $tlc); return true; }