Esempio n. 1
0
 private function onFriendInboxCommand(Session $session)
 {
     $uid = $session->getUID();
     $fromSmall = self::TYPE_FROM_SMALL;
     $fromLarge = self::TYPE_FROM_LARGE;
     $friend = self::TYPE_FRIEND;
     $result = $this->main->getMySQLi()->query("SELECT(SELECT primaryname FROM players WHERE uid=sel.uid)AS name,theirFriends AS theirFriendsCnt,(SELECT rank FROM players WHERE uid=sel.uid)AS rank FROM(SELECT uid,(SELECT COUNT(*) FROM kitpvp_friends WHERE type={$friend} AND(smalluid=uid OR largeuid=uid))AS theirFriends FROM(SELECT IF(smalluid={$uid},largeuid,smalluid)AS uid FROM kitpvp_friends WHERE(smalluid={$uid} AND type={$fromLarge})OR(largeuid={$uid} AND type={$fromSmall}))AS friends)AS sel", MysqlConnection::ALL);
     $names = [];
     foreach ($result as &$row) {
         $row["theirFriendsCnt"] = (int) $row["theirFriendsCnt"];
         $name = $row["name"];
         if ($row["theirFriendsCnt"] >= Settings::kitpvp_maxFriends((int) $row["rank"])) {
             $name = TextFormat::RED . "{$name} (full)" . TextFormat::WHITE;
         }
         $names[] = $name;
     }
     return sprintf("You have %d received friend request(s) from:\n%s.", count($names), count($names) > 0 ? implode(", ", $names) : "---");
 }