Merge pull request #155 from att3/master

Powergamers and achievements
This commit is contained in:
Stefan A. Brannfjell 2014-09-12 11:39:26 +02:00
commit 79195a95ae
6 changed files with 469 additions and 4 deletions

View File

@ -0,0 +1,37 @@
function onThink(interval, lastExecution, thinkInterval)
if (tonumber(os.date("%d")) ~= getGlobalStorageValue(23856)) then
setGlobalStorageValue(23856, (tonumber(os.date("%d"))))
db.query("UPDATE `znote_players` SET `onlinetime7`=`onlinetime6`, `onlinetime6`=`onlinetime5`, `onlinetime5`=`onlinetime4`, `onlinetime4`=`onlinetime3`, `onlinetime3`=`onlinetime2`, `onlinetime2`=`onlinetime1`, `onlinetime1`=`onlinetimetoday`, `onlinetimetoday`=0;")
db.query("UPDATE `znote_players` `z` INNER JOIN `players` `p` ON `p`.`id`=`z`.`player_id` SET `z`.`exphist7`=`z`.`exphist6`, `z`.`exphist6`=`z`.`exphist5`, `z`.`exphist5`=`z`.`exphist4`, `z`.`exphist4`=`z`.`exphist3`, `z`.`exphist3`=`z`.`exphist2`, `z`.`exphist2`=`z`.`exphist1`, `z`.`exphist1`=`p`.`experience`-`z`.`exphist_lastexp`, `z`.`exphist_lastexp`=`p`.`experience`;")
end
db.query("UPDATE `znote_players` SET `onlinetimetoday` = `onlinetimetoday` + 60, `onlinetimeall` = `onlinetimeall` + 60 WHERE `player_id` IN (SELECT `player_id` FROM `players_online` WHERE `players_online`.`player_id` = `znote_players`.`player_id`)")
return true
end
-- TFS 1.0 (globalevents.xml)
-- <!-- Power Gamers -->
-- <globalevent name="PowerGamers" interval="60000" script="powergamers.lua"/>
-- SQL (remember to remove all (--) before executing)--
--ALTER TABLE `znote_players` ADD `exphist_lastexp` BIGINT( 255 ) NOT NULL DEFAULT '0',
--ADD `exphist1` BIGINT( 255 ) NOT NULL DEFAULT '0',
--ADD `exphist2` BIGINT( 255 ) NOT NULL DEFAULT '0',
--ADD `exphist3` BIGINT( 255 ) NOT NULL DEFAULT '0',
--ADD `exphist4` BIGINT( 255 ) NOT NULL DEFAULT '0',
--ADD `exphist5` BIGINT( 255 ) NOT NULL DEFAULT '0',
--ADD `exphist6` BIGINT( 255 ) NOT NULL DEFAULT '0',
--ADD `exphist7` BIGINT( 255 ) NOT NULL DEFAULT '0',
--ADD `onlinetimetoday` BIGINT( 20 ) NOT NULL DEFAULT '0',
--ADD `onlinetime1` BIGINT( 20 ) NOT NULL DEFAULT '0',
--ADD `onlinetime2` BIGINT( 20 ) NOT NULL DEFAULT '0',
--ADD `onlinetime3` BIGINT( 20 ) NOT NULL DEFAULT '0',
--ADD `onlinetime4` BIGINT( 20 ) NOT NULL DEFAULT '0',
--ADD `onlinetime5` BIGINT( 20 ) NOT NULL DEFAULT '0',
--ADD `onlinetime6` BIGINT( 20 ) NOT NULL DEFAULT '0',
--ADD `onlinetime7` BIGINT( 20 ) NOT NULL DEFAULT '0',
--ADD `onlinetimeall` BIGINT( 20 ) NOT NULL DEFAULT '0';
---------------
-- after that execute --
--UPDATE `znote_players` AS `z` INNER JOIN `players` AS `p` ON `p`.`id`=`z`.`player_id` SET `z`.`exphist_lastexp`=`p`.`experience`

61
achievements.php Normal file
View File

@ -0,0 +1,61 @@
<?php require_once 'engine/init.php'; include 'layout/overall/header.php';
if ($config['Ach'] == true) {
?>
<center><h3>Achievements on <?php echo $config['site_title'] ?></h3></center>
<div class="panel-body">
<table class="table table-striped table-bordered table-condensed">
<tr>
<td width="10%">Grade</td>
<td width="17%">Name</td>
<td>Description</td>
<td width="7%">Secret</td>
<td width="2%">Points</td>
</tr>
<style>
#wtf {
margin-left:0px;
}
</style>
<tr>
<?php
foreach ($config['achievements'] as $key => $achName) {
$secret = false;
if (($achName['points'] >= 1) and ($achName['points'] <= 3) and (!$achName['img'])) {
echo '<td><center><img id="wtf" src="http://img2.wikia.nocookie.net/__cb20100828120326/tibia/en/images/0/0b/Achievement_Grade_Symbol.gif"></center></td>';
}
elseif (($achName['points'] >= 4) and ($achName['points'] <= 6) and (!$achName['img']))
{
echo '<td><center><img id="wtf" src="http://img2.wikia.nocookie.net/__cb20100828120326/tibia/en/images/0/0b/Achievement_Grade_Symbol.gif"><img id="wtf" src="http://img2.wikia.nocookie.net/__cb20100828120326/tibia/en/images/0/0b/Achievement_Grade_Symbol.gif"></center></td>';
}
elseif (($achName['points'] >= 7) and ($achName['points'] <= 9) and (!$achName['img']))
{
echo '<td><center><img id="wtf" src="http://img2.wikia.nocookie.net/__cb20100828120326/tibia/en/images/0/0b/Achievement_Grade_Symbol.gif"><img id="wtf" src="http://img2.wikia.nocookie.net/__cb20100828120326/tibia/en/images/0/0b/Achievement_Grade_Symbol.gif"><img id="wtf" src="http://img2.wikia.nocookie.net/__cb20100828120326/tibia/en/images/0/0b/Achievement_Grade_Symbol.gif"></center></td>';
}
elseif (($achName['points'] >= 10) and (!$achName['img']))
{
echo '<td><center><img id="wtf" src="http://img2.wikia.nocookie.net/__cb20100828120326/tibia/en/images/0/0b/Achievement_Grade_Symbol.gif"><img id="wtf" src="http://img2.wikia.nocookie.net/__cb20100828120326/tibia/en/images/0/0b/Achievement_Grade_Symbol.gif"><img id="wtf" src="http://img2.wikia.nocookie.net/__cb20100828120326/tibia/en/images/0/0b/Achievement_Grade_Symbol.gif"></center></td>';
}
else {
echo '<td><img id="wtf" src="' .$achName['img']. '"><br><br></td>';
}
echo '<td>' .$achName[0]. '</td>';
echo '<td>' .$achName[1]. '</td>';
if ($achName['secret'] == true){
echo '<td><img id="wtf" src="http://img04.imgland.net/PuMz0mVqSG.gif"></td>';
echo '<td>'. $achName['points'] .'</td>';
} else {
echo '<td></td><td>'. $achName['points'] .'</td>';
}
echo '</tr>';
}?>
</table>
</div>
</div>
<?php
include 'layout/overall/footer.php';
}
else{
echo 'This page has been disabled, this page can be enabled at config';
}
?>

View File

@ -9,6 +9,9 @@ if (isset($_GET['name']) === true && empty($_GET['name']) === false) {
if ($config['TFSVersion'] == 'TFS_10') {
$profile_data = user_character_data($user_id, 'name', 'level', 'vocation', 'lastlogin', 'sex');
$profile_data['online'] = user_is_online_10($user_id);
if ($config['Ach'] == true) {
$achievementPoints = mysql_select_single("SELECT SUM(`value`) AS `sum` FROM `player_storage` WHERE `key` LIKE '30___' AND `player_id`='$user_id'");
}
} else $profile_data = user_character_data($user_id, 'name', 'level', 'vocation', 'lastlogin', 'online', 'sex');
$profile_znote_data = user_znote_character_data($user_id, 'created', 'hide_char', 'comment');
@ -18,6 +21,7 @@ if (isset($_GET['name']) === true && empty($_GET['name']) === false) {
$guild = get_player_guild_data($user_id);
$guild_name = get_guild_name($guild['guild_id']);
}
?>
<!-- PROFILE MARKUP HERE-->
@ -48,7 +52,32 @@ if (isset($_GET['name']) === true && empty($_GET['name']) === false) {
}
?></font></li>
<li><font class="profile_font" name="profile_font_status">Status:</font> <?php
<!-- Achievement start -->
<?php if ($config['Ach'] == true) {
foreach ($achievementPoints as $achievement)
{
if ($achievement > 0) //if player doesn't have any achievement points it won't echo the line below.
echo '<tr><td>Achievement Points</td><td>' .$achievement. ' </td></tr>';
}
}
?>
<!-- Achievement end -->
<?php $houses = array();
$houses = mysql_select_multi("SELECT `id`, `owner`, `name`, `town_id` FROM `houses` WHERE `owner` = $user_id ;");
if ($houses !== false) {
$playerlist = array();
foreach ($houses as $h)
if ($h['owner'] > 0)
$playerlist[] = $h['owner'];
if ($profile_data['id'] = $h['owner']) { ?>
<li>House: <?php echo $h['name']; ?>, <?php
foreach ($config['towns'] as $key=>$value) {
if ($key == $h['town_id']) {
echo $value;
}
} ?></li>
<li><font class="profile_font" name="profile_font_status">Status:</font> <?php }}
if ($config['TFSVersion'] == 'TFS_10') {
if ($profile_data['online']) {
echo '<font class="profile_font" name="profile_font_online" color="green"><b>ONLINE</b></font>';
@ -65,7 +94,45 @@ if (isset($_GET['name']) === true && empty($_GET['name']) === false) {
?></li>
<li><font class="profile_font" name="profile_font_created">Created: <?php echo getClock($profile_znote_data['created'], true); ?></font></li>
<li><font class="profile_font" name="profile_font_comment">Comment:</font> <br><textarea name="profile_comment_textarea" cols="70" rows="10" readonly="readonly" class="span12"><?php echo $profile_znote_data['comment']; ?></textarea></li>
<!-- DEATH LIST -->
<!-- Achievements start -->
<?php if ($config['Ach'] == true) { ?>
<h3 class="header-ok">Achievements</h3>
<div id="accordion">
<h3>Show/hide player achievements</h3>
<div>
<table class="table table-striped table-bordered">
<tbody>
<style>
#secondD {
margin-left:0px;
}
</style>
<?php
foreach ($config['achievements'] as $key => $achiv) {
$uery = mysql_select_single("SELECT `player_id`, `value`, `key` FROM `player_storage` WHERE `player_id`='$user_id' AND `key`='$key' LIMIT 1;");
foreach ($uery as $luery)
if (($luery) == $key)
{
if (!array_key_exists(($achiv), $config['achievements'])) {
echo '<tr><td width="17%">' .$achiv[0]. '</td><td>' .$achiv[1]. '</td>';
if ($achiv['secret'] == true) {
echo '<td><img id="secondD" src="http://img04.imgland.net/PuMz0mVqSG.gif"></td>';
echo '<td>'. $achiv['points'] .'</td>';
} else {
echo '<td></td><td>'. $achiv['points'] .'</td>';
}
echo '<tr>';
}
}
}
?>
</tbody>
</table>
</div></div>
<br>
<?php } ?>
<!-- Achievements end -->
<!-- DEATH LIST -->
<li>
<b>Death List:</b><br>
<?php

File diff suppressed because one or more lines are too long

70
powergamers.php Normal file
View File

@ -0,0 +1,70 @@
<?php
require_once 'engine/init.php';
include 'layout/overall/header.php';
if (!$config['powergamers']['enabled']) {
echo 'This page has been disabled at config.php.';
include 'layout/overall/footer.php';
exit();
}
$limit = $config['powergamers']['limit'];
?>
<style>
#selectedP {
text-decoration: underline
}
</style>
<?php
$type = $_GET['type'];
function coloured_value($valuein)
{
$value2 = $valuein;
while(strlen($value2) > 3)
{
$value .= '.'.substr($value2, -3, 3);
$value2 = substr($value2, 0, strlen($value2)-3);
}
@$value = $value2.$value;
if($valuein > 0)
return '<b><font color="green">+'.$value.'</font></b>';
elseif($valuein < 0)
return '<font color="red">'.$value.'</font>';
else
return $value;
}
if(empty($type))
$znotePlayers = mysql_select_multi('SELECT `a`.`id`, `b`.`player_id`, `a`.`name`, `a`.`vocation`, `a`.`level`, `a`.`group_id`, `a`.`experience`, `b`.`exphist_lastexp`, `b`.`exphist1`, `b`.`exphist2`, `b`.`exphist3`, `b`.`exphist4`, `b`.`exphist5`, `b`.`exphist6`, `b`.`exphist7`, (`a`.`experience` - `b`.`exphist_lastexp`) AS `expdiff` FROM `players` `a` JOIN `znote_players` `b` ON `a`.`id` = `b`.`player_id` WHERE `a`.`group_id` < 2 ORDER BY `expdiff` DESC LIMIT '.$limit);
elseif($type >= 1 && $type <= 3)
$znotePlayers = mysql_select_multi('SELECT `a`.`id`, `b`.`player_id`, `a`.`name`, `a`.`vocation`, `a`.`level`, `a`.`group_id`, `a`.`experience`, `b`.`exphist_lastexp`, `b`.`exphist1`, `b`.`exphist2`, `b`.`exphist3`, `b`.`exphist4`, `b`.`exphist5`, `b`.`exphist6`, `b`.`exphist7`, (`a`.`experience` - `b`.`exphist_lastexp`) AS `expdiff` FROM `players` `a` JOIN `znote_players` `b` ON `a`.`id` = `b`.`player_id` WHERE `a`.`group_id` < 2 ORDER BY `exphist' . (int) $type . '` DESC LIMIT '.$limit);
echo '<CENTER><H2>Ranking of powergamers</H2></CENTER>
<BR>
<table class="table table-striped">
<td><center><b>#</b></center></td>
<td><b>Name</b></td>';
echo '<td><center>Total</center></td>';
for($i = 3; $i >= 2; $i--)
echo ($type == $i) ? '<TD id="selectedP" width="16%"><a href="powergamers.php?type='.$i.'">'.$i.'<b> Days Ago</b></a></B></TD>' : '<TD width="16%"><center><a href="powergamers.php?type='.$i.'">'.$i.' Days Ago</a></TD>';
echo ($type == 1) ? '<TD id="selectedP" width="16%"><b><a href="powergamers.php?type=1">1 Day Ago</a></B></TD>' : '<TD width="16%"><a href="powergamers.php?type=1">1 Day Ago</a></TD>';
echo (empty($type)) ? '<TD id="selectedP"><b><a href="powergamers.php">Today</a></b></TD>' : '<TD><a href="powergamers.php">Today</a></TD>';
echo '</TR>';
$number_of_rows = 1;
if($znotePlayers)
foreach($znotePlayers as $player)
{
echo '<td><center>'. $number_of_rows . '.</center></td>';
echo '<td><a href="characterprofile.php?name=' .$player['name']. '">' .$player['name']. '</a>';
echo '<br> ' .$player['level']. ' '.htmlspecialchars(vocation_id_to_name($player['vocation'])).' ';
echo '<td><center>'.coloured_value($player['exphist1'] + $player['exphist2'] + $player['exphist3'] + $player['experience'] - $player['exphist_lastexp']).'</center></td>';
echo '<td><center>'.coloured_value($player['exphist3']).'</center></td><td><center>'.coloured_value($player['exphist2']).'</center></td><td><center>'.coloured_value($player['exphist1']).'</center></td><td><center>'.coloured_value($player['experience']-$player['exphist_lastexp']).'</center></td></tr>'; $number_of_rows++;
}
echo '</table><br></div>';
?>
<?php
include 'layout/overall/footer.php';
?>

87
toponline.php Normal file
View File

@ -0,0 +1,87 @@
<?php
require_once 'engine/init.php';
include 'layout/overall/header.php';
if (!$config['toponline']['enabled']) {
echo 'This page has been disabled at config.php.';
include 'layout/overall/footer.php';
exit();
}
$limit = $config['toponline']['limit'];
$type = $_GET['type'];
function onlineTimeTotal($value)
{
$hours = floor($value / 3600);
$value = $value - $hours * 3600;
$minutes = floor($value / 60);
return '<font color="black">'.$hours.'h '.$minutes.'m</font>';
}
function hours_and_minutes($value, $color = 1)
{
$hours = floor($value / 3600);
$value = $value - $hours * 3600;
$minutes = floor($value / 60);
if($color != 1)
return '<font color="black">'.$hours.'h '.$minutes.'m</font>';
else
if($hours >= 12)
return '<font color="red">'.$hours.'h '.$minutes.'m</font>';
elseif($hours >= 6)
return '<font color="black">'.$hours.'h '.$minutes.'m</font>';
else
return '<font color="green">'.$hours.'h '.$minutes.'m</font>';
}
if(empty($type))
$znotePlayers = mysql_select_multi('SELECT * FROM `znote_players` AS `z` JOIN `players` AS `p` WHERE `p`.`id`=`z`.`player_id` and `p`.`group_id` < 3 ORDER BY `onlinetimetoday` DESC LIMIT '.$limit);
elseif($type == "sum")
$znotePlayers = mysql_select_multi('SELECT * FROM `znote_players` AS `z` JOIN `players` AS `p` WHERE `p`.`id`=`z`.`player_id` and `p`.`group_id` < 3 ORDER BY `z`.`onlinetimeall` DESC LIMIT '. $limit);
elseif($type >= 1 && $type <= 4)
$znotePlayers = mysql_select_multi('SELECT * FROM `znote_players` AS `z` JOIN `players` AS `p` WHERE `p`.`id`=`z`.`player_id` and `p`.`group_id` < 3 ORDER BY `onlinetime' . (int) $type . '` DESC LIMIT '.$limit);
echo '<CENTER><H2>Most online on <?php echo $config['site_title'] ?></H2></CENTER>
<BR>
<table class="table table-striped">
<td><center><b>#</b></center></td>
<td width="10%"><b>Name</b></td>';
if($type == "sum")
echo '<td ><center><b><center><a href="?subtopic=onlinetime&type=sum">Total</a></center></B></TD>';
else
echo '<td ><center><b><center><a href="?subtopic=onlinetime&type=sum">Total</a></center></B></TD>';
for($i = 3; $i >= 2; $i--)
{
if($type == $i)
echo '<TD ><b><center><a href="?subtopic=onlinetime&type='.$i.'">'.$i.' Days Ago</a></center></B></TD>';
else
echo '<TD ><b><center><a href="?subtopic=onlinetime&type='.$i.'">'.$i.' Days Ago</a></center></B></TD>';
}
if($type == 1)
echo '<TD ><b><center><a href="?subtopic=onlinetime&type=1">1 Day Ago</a></center></B></TD>';
else
echo '<TD ><b><center><a href="?subtopic=onlinetime&type=1">1 Day Ago</a></center></B></TD>';
if(empty($type))
echo '<TD><b><center><a href="?subtopic=onlinetime">Today</a></center></B></TD>';
else
echo '<TD ><b><center><a href="?subtopic=onlinetime">Today</a></center></B></TD>';
echo '</TR>';
$number_of_rows = 1;
if($znotePlayers)
foreach($znotePlayers as $player)
{
echo '<td><center>'. $number_of_rows . '.</center></td>';
echo '<td><a href="characterprofile.php?name=' .$player['name']. '">' .$player['name']. '</a>';
echo '<br> ' .$player['level']. ' '.htmlspecialchars(vocation_id_to_name($player['vocation'])).' ';
echo '<td ><center>' .onlineTimeTotal($player['onlinetimeall']).'</td>';
$number_of_rows++;
echo '<td ><center>'.hours_and_minutes($player['onlinetime3']).'</center></td><td ><center>'.hours_and_minutes($player['onlinetime2']).'</center></td><td ><center>'.hours_and_minutes($player['onlinetime1']).'</center></td><td ><center>'.hours_and_minutes($player['onlinetimetoday']).'</center></td></tr>';
}
echo '</TABLE></div>';
?>
<?php
include 'layout/overall/footer.php';
?>