Exemple #1
0
 public function on_create(SR_Player $player, array $args)
 {
     if (false !== ($clan = SR_Clan::getByPlayer($player))) {
         $player->msg('1120', array($clan->getName()));
         // 			$player->message(sprintf('You are already in the "%s" clan, chummer.', $clan->getName()));
         return false;
     }
     // 		printf('PID: %s', $player->getID());
     // 		return true;
     $dcost = Shadowfunc::displayNuyen(self::COST_CREATE);
     if ($player->getBase('level') < self::LVL_CREATE) {
         $player->msg('1127', array(self::LVL_CREATE));
         // 			$player->message(sprintf('You do not have the minimum level of %s to create a clan.', self::LVL_CREATE));
         return false;
     }
     if (false === $player->hasNuyen(self::COST_CREATE)) {
         $player->msg('1063', array($dcost, $player->displayNuyen()));
         // 			$player->message(sprintf('It cost %s to create a clan, but you only got %s.', $dcost, $player->displayNuyen()));
         return false;
     }
     $name = implode(' ', $args);
     if (strlen($name) > SR_Clan::MAX_NAME_LEN) {
         $player->msg('1128');
         // 			$player->message('The name of your clan is too long or too short.');
         return false;
     }
     if (strlen($name) < SR_Clan::MIN_NAME_LEN) {
         $player->msg('1128');
         // 			$player->message('The name of your clan is too long or too short.');
         return false;
     }
     if (false !== ($clan2 = SR_Clan::getByName($name))) {
         $player->msg('1129');
         // 			$player->message('A clan with this name already exists.');
         return false;
     }
     if (false === ($clan = SR_Clan::create($player, $name))) {
         $player->message('DB ERROR 5');
         return false;
     }
     if (false === $player->giveNuyen(-self::COST_CREATE)) {
         $player->message('DB ERROR 6');
         return false;
     }
     $player->msg('5168', array($clan->getName()));
     // 		$player->message(sprintf('Congratulations. You formed a new clan named "%s".', $clan->getName()));
     return true;
 }