• 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] Offline Training Page

FabianoBN

l|¬¬"|l
Joined
Jan 23, 2009
Messages
745
Reaction score
22
Location
Goias - Brazil
Hello >:D
Go to put the Offiline Training in your page?

In www/engine/function
Open the life users.php
go to line 1190 press the ENTER

and put this:
PHP:
function training_count_online() {
	return mysql_result(mysql_query("SELECT COUNT(`id`) from `players` WHERE `offlinetraining_skill` > 0;"), 0);
}

Now, open the file general.php
go to line 294 press the ENTER
and put this:
PHP:
function offtraining_list() {
	$count = training_count_online();
	$query = mysql_query("SELECT `name`, `level`, `vocation` FROM `players` WHERE `offlinetraining_skill`>'0' ORDER BY `name` DESC;");
	for ($i = 0; $i < $count; $i++) {
		$row = mysql_fetch_row($query);
		$array[] = $row;
	}

	if (isset($array)) {
		return $array;
	} else {
		return false;
	}
}

Now, create the file offlinetraininglist.php in your folder www
and put this:
PHP:
<?php require_once 'engine/init.php'; include 'layout/overall/header.php'; ?>

<h1>Who is Offline Training?</h1>
<?php
$array = offtraining_list();
if ($array) {
	?>
	
	<table id="onlinelistTable">
		<tr class="yellow">
			<td>Name:</td>
			<td>Level:</td>
			<td>Vocation:</td>
		</tr>
			<?php
			foreach ($array as $value) {
			echo '<tr>';
			echo '<td><a href="characterprofile.php?name='. $value[0] .'">'. $value[0] .'</a></td>';
			echo '<td>'. $value[1] .'</td>';
			echo '<td>'. vocation_id_to_name($value[2]) .'</td>';
			echo '</tr>';
			}
			?>
	</table>

	<?php
} else {
	echo 'Nobody is Offline Training.';
}
?>
<?php include 'layout/overall/footer.php'; ?>

Now, in your folder www/layout (if is the layout TIBIACOM)
Open your rightside.php

and Change this line:
PHP:
<a href="onlinelist.php" id="online">Players online: <br><?php echo user_count_online();?></a>

to:

PHP:
<a href="onlinelist.php" id="online">Players online: <?php echo user_count_online();?></a><br><a href="offtraininglist.php" id="online">Off Training: <?php echo training_count_online();?></a>


but if it is the default layout of the Engine ZNote AAC, go to the folder layout/widgets
open the file serverinfo.php
and change the line:

PHP:
<li><a href="onlinelist.php">Players online: <?php echo user_count_online();?></a></li>

to:

PHP:
<li><a href="onlinelist.php">Players online: <?php echo user_count_online();?></a><br><a href="offtraininglist.php" id="online">Off Training: <?php echo training_count_online();?></a></li>

Any questions just ask! Thanks ^^

Demo: Offline Training
 
Last edited:
Looks very nice. :)

You should try to use more Znote AAC functionality, look at this improvement:

  • mysql_select_single
    • Used to fetch single rows from database.
    • Is false if empty.
    • Returns single array of 1 row. Sample: echo $row['column'];
  • mysql_select_multi
    • Used to select many/multiple rows from database.
    • Is false if empty.
    • Returns multi-array of rows. Sample: foreach(rows as row){ echo row['column']; }
Sample usage:
PHP:
<?php
// Last created player welcome
$player = mysql_select_single("SELECT `name` FROM `players` ORDER BY `id` DESC LIMIT 1;");
echo "Welcome to our newest player: ". $player['name'] .". I hope you enjoy your stay!";

// List all sorcerers that exist on server. Best sorcerers first.
$sorcerers = mysql_select_multi("SELECT `name`, `level` FROM `players` WHERE `vocation`='1' OR `vocation`='5' ORDER BY `level` DESC;");
if ($sorcerers !== false) {
	echo "There are ". count($sorcerers) ." Sorcerers on this server. Here is the list:\n";
	?>
	<table>
		<tr>
			<td>Name</td>
			<td>Level</td>
		</tr>
		<?php
		foreach($sorcerers as $sorc) {
			echo "<tr>";
				echo "<td>". $sorc['name'] ."</td>";
				echo "<td>". $sorc['level'] ."</td>";
			echo "</tr>";
		}
		?>
	</table>
	<?php
} else echo "No sorcerers exist on this server yet.";
?>


Here I rewrite some of your code to show how it would work with you:
PHP:
///////////// Engine function users.php
function training_count_online() {
	$count = mysql_select_single("SELECT COUNT(`id`) AS `value` from `players` WHERE `offlinetraining_skill` > 0;");
	if (!$count) return 0;
	else return $count['value'];
}

function offtraining_list() {
	$offlinePlayers = mysql_select_multi("SELECT `name`, `level`, `vocation` FROM `players` WHERE `offlinetraining_skill`>'0' ORDER BY `name` DESC;");
	return $offlinePlayers; // mysql_select_multi will either return false if empty, or array with values if exist.
}

PHP:
<?php
//////////// PAGE
require_once 'engine/init.php'; include 'layout/overall/header.php'; 
$players = offtraining_list();
$count = 0;
if ($players !== false) $count = count($players);
?>

<h1>Who is Offline Training? [<?php echo $count; ?>]</h1>
<?php
if ($players !== false) {
    ?>
    
    <table id="onlinelistTable">
        <tr class="yellow">
            <td>Name:</td>
            <td>Level:</td>
            <td>Vocation:</td>
        </tr>
            <?php
            foreach ($players as $player) {
            echo '<tr>';
	            echo "<td><a href='characterprofile.php?name=". $player['name'] ."'>". $player['name'] ."</a></td>";
	            echo "<td>". $player['level'] ."</td>";
	            echo "<td>". vocation_id_to_name($player['vocation']) ."</td>";
            echo '</tr>';
            }
            ?>
    </table>

    <?php
} else {
    echo 'Nobody is Offline Training.';
}

include 'layout/overall/footer.php'; ?>


Understand? :thumbup:
 
I Complet all steps for install offline training page. but not work for me...

I create the file offlinetraininglist.php and put on folder www

why is the problem? all steps are complete! thanks


offtranings.jpg
 
When you go to the link it says "Noone is offline training" but I know there are! Any idea why? @Znote Account I use is Znote AAC Version: 1.4_
 
hi @Znote

znote.png

How could you put this exemplified Znote 1.5_svn on my page or file that you have to add?

but how many are put all professions

greetings and thanks
 
(Sorry it won't let me edit my last post)

Error:
Code:
[03-Sep-2014 00:47:52 America/Chicago] PHP Warning:  mysql_result() expects parameter 1 to be resource, boolean given in /home/frostot/public_html/frost-ot/engine/function/users.php on line 1189
 
Hello
would be too much to ask that the skill that is trained will see, because only leave those who are training offline, char name, lvl and vocation, no, but would remain more cool if you put the skills that this training, although it is very difficult, because and so it xDD me.
 
Back
Top