-
-
Notifications
You must be signed in to change notification settings - Fork 126
/
queststatus.php
54 lines (50 loc) · 1.37 KB
/
queststatus.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<table id="questTable">
<?php
$completed = '<font color="green">[Completed]</font>';
$notstarted = '';
function Progress($min, $max, $design = '<font color="orange">[x%]</font>') {
$design = explode("x%",$design);
$percent = ($min / $max) * 100;
return $design[0] . $percent . $design[1];
}
$quests = array(
// Simple quests
'Bearslayer' => 1050,
'Sword Quest' => 1337,
// Advanced quest with progress par:
'Postman Quest' => array(
1338,
3,
),
);
?>
<tr class="yellow">
<td>Quest Name</td>
<td>Status</td>
</tr>
<?php
// Rolling through quests
foreach ($quests as $key => $quest) {
// Is quest NOT an array (advanced quest?)
if (!is_array($quest)) {
// Query to find quest results
$query = mysql_select_single("SELECT `value` FROM `player_storage` WHERE `key`='$quest' AND `player_id`='$user_id' AND `value`='1' LIMIT 1;");
if ($query !== false) $quest = $completed;
else $quest = $notstarted;
} else {
$query = mysql_select_single("SELECT `value` FROM `player_storage` WHERE `key`='".$quest[0]."' AND `player_id`='$user_id' AND `value`>'0' LIMIT 1;");
if (!$query) $quest = $notstarted;
else {
if ($query['value'] >= $quest[1]) $quest = $completed;
else $quest = Progress($query['value'], $quest[1]);
}
}
?>
<tr>
<td><?php echo $key; ?></td>
<td><?php echo $quest; ?></td>
</tr>
<?php
}
?>
</table>