• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[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,802
Best answers
236
Reaction score
1,533
Location
Norway
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:
Joined
Sep 3, 2011
Messages
3,738
Best answers
22
Reaction score
2,427
Location
Sweden
Awesome work, thanks alot!
 
Last edited:

Printer

if Printer then print("LUA") end
Premium User
Joined
Dec 27, 2009
Messages
5,733
Best answers
21
Reaction score
2,037
Location
Sweden?
Great job, but why not 1.0 :/
 

XZN

Legendary User
Joined
Dec 31, 2009
Messages
1,104
Best answers
0
Reaction score
186
Location
Sweden
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,946
Best answers
33
Reaction score
1,445
Location
Sweden
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;');
 
OP
Znote

Znote

<?php echo $title; ?>
Staff member
Global Moderator
Premium User
Joined
Feb 14, 2008
Messages
6,802
Best answers
236
Reaction score
1,533
Location
Norway
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,889
Best answers
2
Reaction score
994
Location
Númenor
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
 

Printer

if Printer then print("LUA") end
Premium User
Joined
Dec 27, 2009
Messages
5,733
Best answers
21
Reaction score
2,037
Location
Sweden?
Btw its nice to see you back Znote ^^
 

Ray Rewind

Doctor
Joined
Jun 6, 2009
Messages
1,349
Best answers
0
Reaction score
75
Location
Germany
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>
 

Tovar

Brak V
Joined
Jul 26, 2008
Messages
347
Best answers
0
Reaction score
7
you tried
Code:
src="images/medals/
and
Code:
src="medals/
?
 
Top