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

Znote

<?php echo $title; ?>
Staff member
Global Moderator
Premium User
Joined
Feb 14, 2008
Messages
6,367
Best answers
150
Likes
1,060
Location
Norway, Oslo
#1
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:
PHP:
$cache = new Cache('engine/cache/news');
Add this code:
PHP:
// Most powerful guilds for TFS 0.3/4 and 1.0
////////////////////////
// Create a cache file to avoid high SQL load
$cache = new Cache('engine/cache/guilds');
if ($cache->hasExpired()) {
    // Fetch guild data
 
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;');
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;');
    $cache->setContent($guilds);
    $cache->save();
} else {
    $guilds = $cache->load();
}
if (!empty($guilds) || !$guilds) {
    $divsize = 400;
    ?>
    <!-- No table design -->
    <center><h1>Most powerful guilds</h1></center>
    <div style="margin: auto; width: <?php echo $divsize; ?>px;">
        <?php
        $number = 1;
        foreach ($guilds as $guild) {
            ?>
            <div style="float: left; width: <?php echo (int)$divsize / 3; ?>px;">
                <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>
                <center><b><?php echo $guild['name']; ?></b><br>
                Kills: <?php echo $guild['frags']; ?></center></a>
            </div>
            <?php
            $number++;
        }
        ?>
    </div>
    <!-- With table design -->
    <table id="news">
        <tr class="yellow">
            <td class="zheadline"><center><b>Most powerful guilds</b></center></td>
        </tr>
        <tr>
            <td>
                <div style="margin: auto; width: <?php echo $divsize; ?>px;">
                    <?php
                   $number = 1;
                   foreach ($guilds as $guild) {
                       ?>
                       <div style="float: left; width: <?php echo (int)$divsize / 3; ?>px;">
                           <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>
                           <center><b><?php echo $guild['name']; ?></b><br>
                           Kills: <?php echo $guild['frags']; ?></center></a>
                       </div>
                       <?php
                       $number++;
                   }
                   ?>
               </div>
            </td>
        </tr>
    </table>
<?php
}
// End powerful guilds
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.
 

Attachments

Last edited:

Arpas

Legendary User
Premium User
Joined
Dec 31, 2009
Messages
1,103
Best answers
0
Likes
185
Location
Sweden
#7
You're one of few that's doing this good, perfect release.
 

Ninja

Global Moderator
Staff member
Global Moderator
Joined
Apr 6, 2010
Messages
5,933
Best answers
28
Likes
1,386
Location
Sweden
#9
PHP:
$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;');
 

Znote

<?php echo $title; ?>
Staff member
Global Moderator
Premium User
Joined
Feb 14, 2008
Messages
6,367
Best answers
150
Likes
1,060
Location
Norway, Oslo
#10
Great job, but why not 1.0 :/
Missing a filled database I can use to test it to make sure it works.

PHP:
$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;');
This query works for TFS 1.0? Got a pic or link I can check to see it in action?
 

dominique120

Science & Reason
Premium User
Joined
Jun 16, 2013
Messages
3,891
Best answers
2
Likes
988
Location
Númenor
#11
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?
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
 
Joined
Jun 6, 2009
Messages
1,349
Best answers
0
Likes
74
Location
Germany
#17
Great Release!

Just the Pictures won't work for me :/

HTML:
<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>
 
Top