Example #1
0
 private static function cleanupPlayers()
 {
     echo __METHOD__ . PHP_EOL;
     $players = GDO::table('SR_Player');
     $before = $players->countRows();
     if (false === ($result = $players->select('sr4pl_id, sr4pl_partyid'))) {
         echo GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         return;
     }
     $sr_time = Shadowrun4::getTime();
     while (false !== ($row = $players->fetch($result, GDO::ARRAY_N))) {
         if (false !== ($player = SR_Player::getByID($row[0]))) {
             if (false === SR_Party::getByID($player->getPartyID())) {
                 if ($player->isHuman()) {
                     printf("WARNING: %s has not party!!\n", $player->getName());
                 } else {
                     $player->delete();
                 }
             }
         }
     }
     $players->free($result);
     $after = $players->countRows();
     printf("I removed %s players from the database and %s are left.\n", $before - $after, $after);
 }
Example #2
0
 private static function cleanupNPC($player_id)
 {
     if (false === ($player = SR_Player::getByID($player_id))) {
         echo GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         return false;
     }
     if ($player->isHuman()) {
         return true;
     }
     if (false === ($party = SR_Party::getByID($player->getPartyID(), false))) {
         printf("Deleting lonely NPC %s.\n", $player->getVar('sr4pl_classname'));
         $player->deletePlayer();
         return true;
     }
     if (false === $party->getMemberByPID($player_id)) {
         printf("NPC is not in that party! deleting!\n", $player->getVar('sr4pl_classname'));
         $player->deletePlayer();
         return true;
     }
 }
Example #3
0
 /**
  * Get or reload a party from/into memory.
  * @param int $partyid
  * @return SR_Party
  */
 public static function getParty($partyid, $events = true)
 {
     if (0 === ($partyid = (int) $partyid)) {
         return false;
     }
     if (false === isset(self::$parties[$partyid])) {
         if (false === ($party = SR_Party::getByID($partyid, $events))) {
             return false;
         }
         self::$parties[$partyid] = $party;
     }
     return self::$parties[$partyid];
 }