• 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!

[0.3.6-0.4] Top fragers and top guilds with one database query

Updated a bit, as it was counting not final_hit-only frags, so it was enough that player attacked someone to get better score.
 
I considered doing this, but i also wanted to add the latest 20 deaths/frags of the guild, would be pretty cool :D
 
I see in the script a
Code:
$i = 0
$i++;

That means that you missed a line above this line:
Code:
<td><a href="?subtopic=characters&name=' . urlencode($player['name']) . '">' . $player['name'] . '</a></td>

Shouldnt be this line there?:
Code:
<td style="text-align: center;">'.$i.'</td>
and on the table starting on the top of the script:
Code:
	    <td class="white" style="text-align: center; font-weight: bold;">#</td>

Am I wrong?
 
Last edited:
I got and error, when i click in the guild in my website i get this:

The Following Errors Have Occurred:
# Guild with ID 0 doesn't exist.

Then i noticed that when i pass my mouse over the guild, the link goes: index.php?subtopic=guilds&action=show&guild= <- no guildID
and it should go index.php?subtopic=guilds&action=show&guild=GUILDID

I checked my database, the guildID is 8, s,o how do i fix that error?
 
You are probably using old Gesior AAC that was with guildname instead of ID :p Try this.
PHP:
$main_content .= '<div class="NewsHeadline">
	<div class="NewsHeadlineBackground" style="background-image:url(' . $layout_name . '/images/news/newsheadline_background.gif)">
		<table border="0">
			<tr>
				<td style="text-align: center; font-weight: bold;">
					<font color="white">Most powerfull guilds</font>
				</td>
			</tr>
		</table>
	</div>
</div>
<table border="0" cellspacing="3" cellpadding="4" width="100%">
	<tr>';

foreach($SQL->query('SELECT `g`.`id` AS `id`, `g`.`name` AS `name`,
	`g`.`logo_gfx_name` AS `logo`, 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, 4;') as $guild)
	$main_content .= '		<td style="width: 25%; text-align: center;">
			<a href="?subtopic=guilds&action=show&guild=' .urlencode($guild['name']). '"><img src="guilds/' . ((!empty($guild['logo']) && file_exists('guilds/' . $guild['logo'])) ? $guild['logo'] : 'default_logo.gif') . '" width="64" height="64" border="0"/><br />' . $guild['name'] . '</a><br />' . $guild['frags'] . ' kills
		</td>';

$main_content .= '	</tr>
just added urlencode() which I know isn't the problem, but give a try xD, WTD I can't even see the guild name in your website, lol!
 
Last edited:
elf i love you, read your guild war post on donor thread plx :D

works perfectly
 
Last edited:
idk why it isnt work for you
PHP:
$main_content .= '<div class="NewsHeadline">
	<div class="NewsHeadlineBackground" style="background-image:url(' . $layout_name . '/images/news/newsheadline_background.gif)">
		<table border="0">
			<tr>
				<td style="text-align: center; font-weight: bold;">
					<font color="white">Most powerfull guilds</font>
				</td>
			</tr>
		</table>
	</div>
</div>
<table border="0" cellspacing="3" cellpadding="4" width="100%">
	<tr>';

foreach($SQL->query('SELECT `g`.`id` AS `id`, `g`.`name` AS `name`,
	`g`.`logo_gfx_name` AS `logo`, 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, 4;') as $guild)
	$main_content .= '<td style="width: 25%; text-align: center;"><a href="?subtopic=guilds&action=show&guild=' . $guild['id'] . '"><img src="guilds/' . ((!empty($guild['logo']) && file_exists('guilds/' . $guild['logo'])) ? $guild['logo'] : 'default_logo.gif') . '" width="64" height="64" border="0"/><br />' . $guild['name'] . '</a><br />' . $guild['frags'] . ' kills</td>';

$main_content .= '</tr></table>';
 
This script works perfectly fine for me, Just be sure to have the collum 'frags' in your DB.
 
Have same problem...
The Following Errors Have Occurred:
# Guild with ID 0 doesn't exist.

Sth must be wrong with:
a href="?subtopic=guilds&action=show&guild=' . $guild['id'] . '
because $guild['id'] is always nil

Probably know what's going on...
This script have problem when:
-you haven't created any guild,
-you have created guilds, but none of them have any frags.
 
Last edited by a moderator:
Back
Top