[Znote AAC] Most powerful guilds (TFS 0.3/4 and 1.0)

Discussion in 'Website Applications' started by Znote, Feb 7, 2014.

  1. Znote

    Znote <?php echo $title; ?> Staff Member Global Moderator Premium User

    Joined:
    Feb 14, 2008
    Messages:
    6,361
    Likes Received:
    1,058
    Best Answers:
    148
    Created 2 versions, with table design and without, just remove the one that does not fit your layout.
    Screenshot 2014-02-07 22.34.03.png
    In index.php, before:
    Code (PHP):
    1. $cache = new Cache('engine/cache/news');
    Add this code:
    Code (PHP):
    1.  
    2. // Most powerful guilds for TFS 0.3/4 and 1.0
    3. ////////////////////////
    4. // Create a cache file to avoid high SQL load
    5. $cache = new Cache('engine/cache/guilds');
    6. if ($cache->hasExpired()) {
    7.     // Fetch guild data
    8.  
    9. if ($config['TFSVersion'] == 'TFS_03') $guilds = mysql_select_multi('SELECT `g`.`id` AS `id`, `g`.`name` AS `name`, COUNT(`g`.`name`) as `frags` FROM `killers` k LEFT JOIN `player_killers` pk ON `k`.`id` = `pk`.`kill_id` LEFT JOIN `players` p ON `pk`.`player_id` = `p`.`id` LEFT JOIN `guild_ranks` gr ON `p`.`rank_id` = `gr`.`id` LEFT JOIN `guilds` g ON `gr`.`guild_id` = `g`.`id` WHERE `k`.`unjustified` = 1 AND `k`.`final_hit` = 1 GROUP BY `name` ORDER BY `frags` DESC, `name` ASC LIMIT 0, 3;');
    10. elseif ($config['TFSVersion'] == 'TFS_10') $guilds = mysql_select_multi('SELECT `g`.`id` AS `id`, `g`.`name` AS `name`, COUNT(`g`.`name`) as `frags` FROM `players` p LEFT JOIN `player_deaths` pd ON `pd`.`killed_by` = `p`.`name` LEFT JOIN `guild_membership` gm ON `p`.`id` = `gm`.`player_id` LEFT JOIN `guilds` g ON `gm`.`guild_id` = `g`.`id` WHERE `pd`.`unjustified` = 1 GROUP BY `name` ORDER BY `frags` DESC, `name` ASC LIMIT 0, 3;');
    11.     $cache->setContent($guilds);
    12.     $cache->save();
    13. } else {
    14.     $guilds = $cache->load();
    15. }
    16. if (!empty($guilds) || !$guilds) {
    17.     $divsize = 400;
    18.     ?>
    19.     <!-- No table design -->
    20.     <center><h1>Most powerful guilds</h1></center>
    21.     <div style="margin: auto; width: <?php echo $divsize; ?>px;">
    22.         <?php
    23.         $number = 1;
    24.         foreach ($guilds as $guild) {
    25.             ?>
    26.             <div style="float: left; width: <?php echo (int)$divsize / 3; ?>px;">
    27.                 <a href="guilds.php?name=<?php echo $guild['name']; ?>"><img style="max-width: <?php echo (int)$divsize / 3; ?>px;" src="medals/<?php echo $number; ?>.png" alt="<?php echo $number; ?>"><br>
    28.                 <center><b><?php echo $guild['name']; ?></b><br>
    29.                 Kills: <?php echo $guild['frags']; ?></center></a>
    30.             </div>
    31.             <?php
    32.             $number++;
    33.         }
    34.         ?>
    35.     </div>
    36.     <!-- With table design -->
    37.     <table id="news">
    38.         <tr class="yellow">
    39.             <td class="zheadline"><center><b>Most powerful guilds</b></center></td>
    40.         </tr>
    41.         <tr>
    42.             <td>
    43.                 <div style="margin: auto; width: <?php echo $divsize; ?>px;">
    44.                     <?php
    45.                    $number = 1;
    46.                    foreach ($guilds as $guild) {
    47.                        ?>
    48.                        <div style="float: left; width: <?php echo (int)$divsize / 3; ?>px;">
    49.                            <a href="guilds.php?name=<?php echo $guild['name']; ?>"><img style="max-width: <?php echo (int)$divsize / 3; ?>px;" src="medals/<?php echo $number; ?>.png" alt="<?php echo $number; ?>"><br>
    50.                            <center><b><?php echo $guild['name']; ?></b><br>
    51.                            Kills: <?php echo $guild['frags']; ?></center></a>
    52.                        </div>
    53.                        <?php
    54.                        $number++;
    55.                    }
    56.                    ?>
    57.                </div>
    58.             </td>
    59.         </tr>
    60.     </table>
    61. <?php
    62. }
    63. // End powerful guilds
    64.  
    Download medals.zip and extract it to your Znote AAC folder to make images work.

    Thanks to @gremlee for letting me borrow his database while creating this.
     

    Attached Files:

    Last edited: Apr 11, 2017
  2. HalfAway

    HalfAway Well-Known Member

    Joined:
    Sep 3, 2011
    Messages:
    3,581
    Likes Received:
    2,309
    Best Answers:
    15
    Awesome work, thanks alot!
     
    Last edited: Feb 9, 2014
  3. gremlee

    gremlee Qumora.com

    Joined:
    Jul 15, 2008
    Messages:
    512
    Likes Received:
    16
    Best Answers:
    0
    Thanks alot znote!
     
  4. Printer

    Printer if Printer then print("LUA") end Premium User

    Joined:
    Dec 27, 2009
    Messages:
    5,653
    Likes Received:
    1,940
    Best Answers:
    13
    Great job, but why not 1.0 :/
     
  5. Naxtie

    Naxtie mapper, designer

    Joined:
    Oct 15, 2011
    Messages:
    1,563
    Likes Received:
    243
    Best Answers:
    1
    Cool, good job :D
     
  6. Avuenja

    Avuenja Just breathe!

    Joined:
    Oct 5, 2012
    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Very good! Perfect job! ;)
     
  7. Remmacs

    Remmacs Legendary User

    Joined:
    Dec 31, 2009
    Messages:
    1,099
    Likes Received:
    206
    Best Answers:
    0
    You're one of few that's doing this good, perfect release.
     
  8. Tovar

    Tovar Brak V

    Joined:
    Jul 26, 2008
    Messages:
    347
    Likes Received:
    8
    Best Answers:
    0
    +1
     
  9. Ninja

    Ninja Global Moderator Staff Member Global Moderator

    Joined:
    Apr 6, 2010
    Messages:
    5,914
    Likes Received:
    1,521
    Best Answers:
    22
    PHP:
    1. $guilds = mysql_select_multi('SELECT `g`.`id` AS `id`, `g`.`name` AS `name`, COUNT(`g`.`name`) as `frags` FROM `players` p LEFT JOIN `player_deaths` pd ON `pd`.`killed_by` = `p`.`name` LEFT JOIN `guild_membership` gm ON `p`.`id` = `gm`.`player_id` LEFT JOIN `guilds` g ON `gm`.`guild_id` = `g`.`id` WHERE `pd`.`unjustified` = 1 GROUP BY `name` ORDER BY `frags` DESC, `name` ASC LIMIT 0, 3;');
     
    pierroth likes this.
  10. Znote

    Znote <?php echo $title; ?> Staff Member Global Moderator Premium User

    Joined:
    Feb 14, 2008
    Messages:
    6,361
    Likes Received:
    1,058
    Best Answers:
    148
    Missing a filled database I can use to test it to make sure it works.

    This query works for TFS 1.0? Got a pic or link I can check to see it in action?
     
  11. dominique120

    dominique120 Science & Reason Premium User

    Joined:
    Jun 16, 2013
    Messages:
    3,891
    Likes Received:
    1,019
    Best Answers:
    2
    How much stuff do you need in the db to test it? You can use mine but it only has like 6 accs and two guilds
     
  12. Ninja

    Ninja Global Moderator Staff Member Global Moderator

    Joined:
    Apr 6, 2010
    Messages:
    5,914
    Likes Received:
    1,521
    Best Answers:
    22
    I made a quick test with 3 guilds and seems to be counting the frags correctly (TFS 1.0). https://i.imgur.com/JlPL7Ye.png
     
    Last edited: Feb 8, 2014
  13. Znote

    Znote <?php echo $title; ?> Staff Member Global Moderator Premium User

    Joined:
    Feb 14, 2008
    Messages:
    6,361
    Likes Received:
    1,058
    Best Answers:
    148
    Ahh great! :D Thanks.
     
  14. Printer

    Printer if Printer then print("LUA") end Premium User

    Joined:
    Dec 27, 2009
    Messages:
    5,653
    Likes Received:
    1,940
    Best Answers:
    13
    Btw its nice to see you back Znote ^^
     
  15. Tovar

    Tovar Brak V

    Joined:
    Jul 26, 2008
    Messages:
    347
    Likes Received:
    8
    Best Answers:
    0
    @Ninja Thanks and

    +1
     
  16. dominique120

    dominique120 Science & Reason Premium User

    Joined:
    Jun 16, 2013
    Messages:
    3,891
    Likes Received:
    1,019
    Best Answers:
    2
    @Znote How can I put this in a page by itself? I have tried but failed :(
     
  17. Ray Rewind

    Ray Rewind Doctor

    Joined:
    Jun 6, 2009
    Messages:
    1,349
    Likes Received:
    74
    Best Answers:
    0
    Great Release!

    Just the Pictures won't work for me :/

    HTML:
    1. <a href="guilds.php?name=<?php echo $guild['name']; ?>"><img style="max-width: <?php echo (int)$divsize / 3; ?>px;" src="images/medals/<?php echo $number; ?>.png" alt="<?php echo $number; ?>"><br>
     
  18. Tovar

    Tovar Brak V

    Joined:
    Jul 26, 2008
    Messages:
    347
    Likes Received:
    8
    Best Answers:
    0
    you tried
    Code (Text):
    1. src="images/medals/
    and
    Code (Text):
    1. src="medals/
    ?
     
  19. Ray Rewind

    Ray Rewind Doctor

    Joined:
    Jun 6, 2009
    Messages:
    1,349
    Likes Received:
    74
    Best Answers:
    0
  20. simson361

    simson361 The Grim Reaper

    Joined:
    Aug 4, 2010
    Messages:
    627
    Likes Received:
    27
    Best Answers:
    0
    epic thx bro! :D
     

Share This Page

Loading...