Skip to content

Instantly share code, notes, and snippets.

@mattmils
Created July 29, 2011 23:32
Show Gist options
  • Save mattmils/1114970 to your computer and use it in GitHub Desktop.
Save mattmils/1114970 to your computer and use it in GitHub Desktop.
Raidboss Script
<?php
// Anti Hacking Measure
if (!defined('REVOLT'))
{
exit();
}
if (!$user->data['is_registered'])
{
echo '<p class="bold">Please login to view the raidboss status.</p>';
return;
}
if ($revolt_cache->start_cache('raid', $cachetimes['raid']))
return;
echo '<h1 class="shadow">Raidboss Status</h1><div style="margin:auto;width:300px">';
if ($l2jdb->get_link())
{
$query = "(SELECT gd.respawn_time, npc.name, npc.title, (1) AS epic FROM grandboss_data AS gd INNER JOIN npc ON gd.boss_id = npc.id)
UNION
(SELECT rs.respawn_time, npc.name, npc.title, (0) AS epic FROM raidboss_spawnlist AS rs INNER JOIN custom_npc AS npc ON rs.boss_id = npc.id WHERE npc.title LIKE '%royal%' OR npc.title LIKE '%prince%' OR npc.title LIKE '%lord%' OR npc.title LIKE '%revolt%' OR npc.title LIKE '%epic%')
UNION
(SELECT rs.respawn_time, npc.name, npc.title, (0) AS epic FROM raidboss_spawnlist AS rs INNER JOIN npc ON rs.boss_id = npc.id WHERE npc.title LIKE '%royal%' OR npc.title LIKE '%prince%' OR npc.title LIKE '%lord%' OR npc.title LIKE '%revolt%' OR npc.title LIKE '%epic%')
ORDER BY epic DESC, title ASC, name ASC";
$result = $l2jdb->sql_query($query);
$last_group = null;
$alt = null;
while ($row = $l2jdb->sql_fetchrow($result))
{
$status = ($row['respawn_time'] == '0' || $row['respawn_time'] <= (date("U") * 1000)) ?
'<span class="green shadow bold">Alive</spawn>' : '<span class="red">Dead</span>';
if ($row['title'] != $last_group)
{
top_margin();
echo '<h2 class="orange shadow">' . $row['title'] . '</h2>';
$last_group = $row['title'];
$alt = null;
}
printf('<p><span class="bold%s">%s</span><span style="float:right">%s</span></p>',$alt, $row['name'], $status);
$alt = ($alt == null) ? " alt" : null;
}
$l2jdb->sql_freeresult($result);
top_margin();
printf('<p class="right bold font09">Last check on: %s</p>' ,date('H:i:s', time()));
} else
{
print ('<h2>Database connection can not be established.</h2>');
print ('<p>The Gameserver is either rebooting or undergoing maintenance.</p>');
}
echo '</div>';
$revolt_cache->end_cache('raid');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment