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

AAC Znote users.php help please

Vantoria

www.ClassicOT.us
Joined
Jun 6, 2014
Messages
186
Reaction score
16
Location
USA
hello friends how i can add world check in this part im using tfs 1.2 so it have to be read from players_online table i have first player_id and second world_id querys
PHP:
function user_count_online($world_id) {
    if ($world_id == '1') {
        $online = mysql_select_single("SELECT COUNT(`player_id`) AS `value` FROM `players_online`;");
        return ($online !== false) ? $online['value'] : 0;
    } elseif ($world_id == '2') {
        $online = mysql_select_single_test("SELECT COUNT(`player_id`) AS `value` FROM `players_online`;");
        return ($online !== false) ? $online['value'] : 0;
    } else {
        $data = mysql_select_single("SELECT COUNT(`id`) AS `count` from `players` WHERE `online` = 1;");
        return ($data !== false) ? $data['count'] : 0;
    }
}
im trying to copy it from here but this was created for othire im trying to implement in new znote but no know how i want this get world_id first

PHP:
function user_count_online($world) {
        if ($world == '1') {
                $data = mysql_select_single_first("SELECT COUNT(`id`) AS `count` from `players` WHERE `online` = 1;");
                return ($data !== false) ? $data['count'] : 0;
        } elseif ($world == '2') {
                $data = mysql_select_single_test("SELECT COUNT(`id`) AS `count` from `players` WHERE `online` = 1;");
                return ($data !== false) ? $data['count'] : 0;
        } else {
                $data = mysql_select_single("SELECT COUNT(`id`) AS `count` from `players` WHERE `online` = 1;");
                return ($data !== false) ? $data['count'] : 0;
        }
}
 
Last edited:
Solution
This should work:

PHP:
// Create Search house box
?>
<form action="" method="get" class="houselist">
    <table style="width: 100%;/*border:3px double #fff;*/box-shadow:1px 1px 10px #000;" cellpadding="10" cellspacing="1">
        <tr class="yellow">
            <th>World</th>
            <th>Town</th>
            <th>Order</th>
            <th>Sort</th>
            <th></th>
        </tr>
        <tr>
            <td>
                <select class="form-control" name="world" style="width:100px;">
                    <?php
                        foreach ($worlds as $w)
                            echo '<option value="'. $w['id'] . '"' . ($world != $w['id'] ?: ' selected') . '>'. $w['name'] .'</option>';
                    ?>...
TFS 1.2 normally doesn't support world id.
How do you segregate the worlds? Is world_id added to the players table, or is it a separate extension table, or do you use a separate connection for it?

PHP:
/*
    All online players: user_count_online(false)
    Online in world id 2: user_count_online(2)
*/
function user_count_online($world_id = false) {
    if (is_int($world_id)) {
        $online = mysql_select_single("
            SELECT 
                COUNT(`o`.`player_id`) AS `value` 
            FROM `players_online` as `o`
            INNER JOIN `players` as `p`
                ON  `p`.`id` = `o`.`player_id`
                AND `p`.`world_id` = {$world_id}
            ;");
    } else {
        $online = mysql_select_single("SELECT COUNT(`player_id`) AS `value` FROM `players_online`;");
    }
    return ($online !== false) ? $online['value'] : 0;
}
 
Last edited:
yes i have world_id in players also in players_online
Post automatically merged:

TFS 1.2 normally doesn't support world id.
How do you segregate the worlds? Is world_id added to the players table, or is it a separate extension table, or do you use a separate connection for it?

PHP:
/*
    All online players: user_count_online(false)
    Online in world id 2: user_count_online(2)
*/
function user_count_online($world_id = false) {
    if (is_int($world_id)) {
        $online = mysql_select_single("
            SELECT
                COUNT(`o`.`player_id`) AS `value`
            FROM `players_online` as `o`
            INNER JOIN `players` as `p`
                ON  `p`.`id` = `o`.`player_id`
                AND `p`.`world_id` = {$world_id}
            ;");
    } else {
        $online = mysql_select_single("SELECT COUNT(`player_id`) AS `value` FROM `players_online`;");
    }
    return ($online !== false) ? $online['value'] : 0;
}
it did work for the count players thanks you man, one more question i have this php to select the world for online players this is my whoisonline.php to select wich world they want to see how many players online
PHP:
<?php require_once 'engine/init.php';
include 'layout/overall/header.php';
?>
    <img src="layout/images/line_body.gif" align="center" height="7" width="100%">
    <img src="images/title_whoisonline.gif" align="left">
    <img src="layout/images/line_body.gif" align="center" height="7" width="100%">
<table>
<table style="width: 100%;/*border:3px double #fff;*/box-shadow:1px 1px 10px #000;" cellpadding="10" cellspacing="1" width="100%"><tbody><tr bgcolor="#505050"><td class="white"><b>World</b></td><td align="center" class="white"><b>Players Online</b></td><td align="center" class="white"><b>Location</b></td><td align="center" class="white"><b>Additional Information</b></td></tr>
<tr bgcolor="#F1E0C6"><td width="140"><a href="http://localhost/online.php?world=<?php echo $configworlds[1];?>"><?php echo $configworlds[1]; ?></td><td width="140" align="center"><?php echo user_count_online(1); ?></td><td align="center">USA <img src="http://localhost/images/flags/flag_USA.gif" width="26" height="13" border="0" align="middle"></td><td align="left">PVP</td></tr>
<tr bgcolor="#F1E0C6"><td width="140"><a href="http://localhost/online.php?world=<?php echo $configworlds[2];?>"><?php echo $configworlds[2]; ?></td><td width="140" align="center"><?php echo user_count_online(2); ?></td><td align="center">GER <img src="http://localhost/images/flags/flag_GER.gif" width="26" height="13" border="0" align="middle"></td><td align="left">PVP</td></tr>
</tr>
</tbody></table>
<?php
include 'layout/overall/footer.php';
?>
i want to check how many players online on that selected world this is the online.php
PHP:
<?php require_once 'engine/init.php';
include 'layout/overall/header.php';
?>
    <img src="layout/images/line_body.gif" align="center" height="7" width="100%">
    <img src="images/title_whoisonline.gif" align="left">
    <img src="layout/images/line_body.gif" align="center" height="7" width="100%">
<table>                  
    <table style="width: 100%;/*border:3px double #fff;*/box-shadow:1px 1px 10px #000;" cellpadding="10" cellspacing="1">
        <tr>
            <th>
                Server Status
            </th>
        </tr>
        <tr>
            <td>
                <i><font size="3" face="georgia">Currently <strong><?php echo user_count_online(); ?></strong> players are online on <b>Miracle World's</b>.</font></i>
            </td>
            <tr>
        </tr>
    </table>
<?php

// Returns a list of players online
$array = false;
$loadFlags = ($config['country_flags']['enabled'] && $config['country_flags']['onlinelist']) ? true : false;
$loadOutfits = ($config['show_outfits']['onlinelist']) ? true : false;
if ($config['ServerEngine'] != 'TFS_10')
    $outfitQuery = ($loadOutfits) ? ", `p`.`lookbody` AS `body`, `p`.`lookfeet` AS `feet`, `p`.`lookhead` AS `head`, `p`.`looklegs` AS `legs`, `p`.`looktype` AS `type`" : "";
else
    $outfitQuery = ($loadOutfits) ? ", `p`.`lookbody` AS `body`, `p`.`lookfeet` AS `feet`, `p`.`lookhead` AS `head`, `p`.`looklegs` AS `legs`, `p`.`looktype` AS `type`" : "";
// Small 30 seconds players_online cache.
$cache = new Cache('engine/cache/onlinelist');
$cache->setExpiration(30);
if ($cache->hasExpired()) {
    // Load online list data from SQL
    if ($config['ServerEngine'] == 'TFS_10') {
        $array = ($loadFlags === true) ? mysql_select_multi("SELECT `p`.`name` AS `name`, `p`.`level` AS `level`, `p`.`vocation` AS `vocation`, `g`.`name` AS `gname`, `za`.`flag` AS `flag` $outfitQuery FROM `players_online` AS `o` INNER JOIN `players` AS `p` ON `o`.`player_id` = `p`.`id` INNER JOIN `znote_accounts` AS `za` ON `p`.`account_id` = `za`.`account_id` LEFT JOIN `guild_membership` AS `gm` ON `o`.`player_id` = `gm`.`player_id` LEFT JOIN `guilds` AS `g` ON `gm`.`guild_id` = `g`.`id`;") : mysql_select_multi("SELECT `p`.`name` AS `name`, `p`.`level` AS `level`, `p`.`vocation` AS `vocation`, `g`.`name` AS `gname` $outfitQuery FROM `players_online` AS `o` INNER JOIN `players` AS `p` ON `o`.`player_id` = `p`.`id` LEFT JOIN `guild_membership` AS `gm` ON `o`.`player_id` = `gm`.`player_id` LEFT JOIN `guilds` AS `g` ON `gm`.`guild_id` = `g`.`id`;");
    } else {
        $array = ($loadFlags === true) ? mysql_select_multi("SELECT `p`.`name` as `name`, `p`.`level` as `level`, `p`.`vocation` as `vocation`, `p`.`world_id` as `world_id`, `g`.`name` as `gname`, `za`.`flag` as `flag` $outfitQuery FROM `players` as `p` INNER JOIN `znote_accounts` as `za` ON `za`.`account_id` = `p`.`account_id` LEFT JOIN `guild_ranks` as `gr` ON `gr`.`id` = `p`.`rank_id` LEFT JOIN `guilds` as `g` ON `gr`.`guild_id` = `g`.`id` WHERE `p`.`online` = '1' ORDER BY `p`.`name` DESC;") : mysql_select_multi("SELECT `p`.`name` as `name`, `p`.`level` as `level`, `p`.`vocation` as `vocation`, `g`.`name` as `gname` $outfitQuery FROM `players` as `p` LEFT JOIN `guild_ranks` as `gr` ON `gr`.`id` = `p`.`rank_id` LEFT JOIN `guilds` as `g` ON `gr`.`guild_id` = `g`.`id` WHERE `p`.`online` = '1' ORDER BY `p`.`name` DESC;");
    }
    // End loading data from SQL
    $cache->setContent($array);
    $cache->save();
} else {
    $array = $cache->load();
}
// End cache

if (!empty($array) && $array !== false) {
    ?>
   
        <table style="width: 100%;/*border:3px double #fff;*/box-shadow:1px 1px 10px #000;" cellpadding="10" cellspacing="1">
        <tr class="yellow">
            <th>Name:</th>
            <th>Guild:</th>
            <th>Level:</th>
            <th>Vocation:</th>
            <tr>
        </tr>
            <?php
            foreach ($array as $value) {
            $url = url("characterprofile.php?name=". $value['name']);
            echo '<tr class="special" onclick="javascript:window.location.href=\'' . $url . '\'">';
            echo '<td><a href="characterprofile.php?name='. $value['name'] .'&world='. $getworldname .'">'. $value['name'] .'</a></td>';
            if (!empty($value['gname'])) echo '<td><a href="guilds.php?name='. $value['gname'] .'&world='. $getworldname .'">'. $value['gname'] .'</a></td>'; else echo '<td></td>';
            echo '<td>'. $value['level'] .'</td>';
            echo '<td>'. vocation_id_to_name($value['vocation']) .'</td>';
            echo '</tr>';
            }
            ?>
    </table>

    <?php
} else {
    echo '';
}
?>
<?php include 'layout/overall/footer.php'; ?>
sorry if i didnt explain good
 
Last edited:
You would need to pass the worl id as a parameter to user_count_online function (line 16 of online.php). I don't know if you have that id stored in some variable
 
You would need to pass the worl id as a parameter to user_count_online function (line 16 of online.php). I don't know if you have that id stored in some variable
how i can do that im using like this to identify the worlds
PHP:
$configworlds = $config['worlds'];
if(isset($_GET['world'])){
    $getworldname = ($_GET['world']);
        if ($getworldname !== $configworlds[1] && $getworldname !== $configworlds[2]){
            $getworldname = $configworlds[1];
        }
}else{
    $getworldname = ($configworlds[1]); //If World not set, default as first world
}
 
@Vantoria I would use something like this:

PHP:
$configworlds = $config['worlds'];
$getworldname = $configworlds[1]; // first world by default
$worldid = 1; // first world by default

if(isset($_GET['world'])){
    $getworldname = $_GET['world'];
    if (getworldname == $configworlds[2]) {
        $worldid = 2;
    }
}
 
@Vantoria I would use something like this:

PHP:
$configworlds = $config['worlds'];
$getworldname = $configworlds[1]; // first world by default
$worldid = 1; // first world by default

if(isset($_GET['world'])){
    $getworldname = $_GET['world'];
    if (getworldname == $configworlds[2]) {
        $worldid = 2;
    }
}
it works thanks man now im facing a problem with houses.php
Sin título.png
how i can move where it says, ( Town , Order, Sort ) to the left side please
this is the part where is this in houses.php
PHP:
        // Create Search house box
        ?>
        <form action="" method="get" class="houselist">
        <table style="width: 100%;/*border:3px double #fff;*/box-shadow:1px 1px 10px #000;" cellpadding="10" cellspacing="1">
        <tr class="yellow">
                    <th>World</th>
                    <th>Town</th>
                    <th>Order</th>
                    <th>Sort</th>
                    <tr>
                </tr>
                    <td>
            <select class="form-control" name="world" style="width:100px;">
            <?php
            foreach ($worlds as $w)
                echo '<option value="'. $w['id'] . '"' . ($world != $w['id'] ?: ' selected') . '>'. $w['name'] .'</option>';
            ?>
            </select>
            <select class="form-control" name="id" style="width:150px;">
            <?php
            foreach ($towns as $id => $name)
                echo '<option value="'. $id .'"' . ($townid != $id ?: ' selected') . '>'. $name .'</option>';
            ?>
            </select>
            <select class="form-control" name="order" style="width:150px;">
            <?php
            $order_allowed = array('id', 'name', 'size', 'beds', 'rent', 'owner');
            foreach($order_allowed as $o)
                echo '<option value="' . $o . '"' . ($o != $order ?: ' selected') . '>' . ucfirst($o) . '</option>';
            ?>
            </select>
            <select class="form-control" name="type" style="width:150px;">
            <?php
            $type_allowed = array('desc', 'asc');
            foreach($type_allowed as $t)
                echo '<option value="' . $t . '"' . ($t != $type ?: ' selected') . '>' . ($t == 'desc' ? 'Descending' : 'Ascending') .'</option>';
            ?>
            </select>
            <input type="submit" value="View" class="btn btn-info"/>
        </p>
        </form>
        <?php
        if(!in_array($order, $order_allowed))
            $order = 'id';

        if(!in_array($type, $type_allowed))
            $type = 'desc';

        $av_worlds = get_av_worlds();
        if(!in_array($world, $av_worlds))
                $world = 0;

        // Create or fetch data from cache
 
This should work:

PHP:
// Create Search house box
?>
<form action="" method="get" class="houselist">
    <table style="width: 100%;/*border:3px double #fff;*/box-shadow:1px 1px 10px #000;" cellpadding="10" cellspacing="1">
        <tr class="yellow">
            <th>World</th>
            <th>Town</th>
            <th>Order</th>
            <th>Sort</th>
            <th></th>
        </tr>
        <tr>
            <td>
                <select class="form-control" name="world" style="width:100px;">
                    <?php
                        foreach ($worlds as $w)
                            echo '<option value="'. $w['id'] . '"' . ($world != $w['id'] ?: ' selected') . '>'. $w['name'] .'</option>';
                    ?>
                </select>
            </td>
            <td>
                <select class="form-control" name="id" style="width:150px;">
                    <?php
                        foreach ($towns as $id => $name)
                            echo '<option value="'. $id .'"' . ($townid != $id ?: ' selected') . '>'. $name .'</option>';
                    ?>
                </select>
            </td>
            <td>
                <select class="form-control" name="order" style="width:150px;">
                    <?php
                        $order_allowed = array('id', 'name', 'size', 'beds', 'rent', 'owner');
                        foreach($order_allowed as $o)
                            echo '<option value="' . $o . '"' . ($o != $order ?: ' selected') . '>' . ucfirst($o) . '</option>';
                    ?>
                </select>
            </td>
            <td>
                <select class="form-control" name="type" style="width:150px;">
                    <?php
                        $type_allowed = array('desc', 'asc');
                        foreach($type_allowed as $t)
                            echo '<option value="' . $t . '"' . ($t != $type ?: ' selected') . '>' . ($t == 'desc' ? 'Descending' : 'Ascending') .'</option>';
                    ?>
                </select>
            </td>
            <td>
                <input type="submit" value="View" class="btn btn-info"/>
            </td>
        </tr>
    </p>
</form>
<?php
if(!in_array($order, $order_allowed))
$order = 'id';

if(!in_array($type, $type_allowed))
$type = 'desc';

$av_worlds = get_av_worlds();
if(!in_array($world, $av_worlds))
$world = 0;

// Create or fetch data from cache

You were missing <td>...</td> for each select
 
Solution
This should work:

PHP:
// Create Search house box
?>
<form action="" method="get" class="houselist">
    <table style="width: 100%;/*border:3px double #fff;*/box-shadow:1px 1px 10px #000;" cellpadding="10" cellspacing="1">
        <tr class="yellow">
            <th>World</th>
            <th>Town</th>
            <th>Order</th>
            <th>Sort</th>
            <th></th>
        </tr>
        <tr>
            <td>
                <select class="form-control" name="world" style="width:100px;">
                    <?php
                        foreach ($worlds as $w)
                            echo '<option value="'. $w['id'] . '"' . ($world != $w['id'] ?: ' selected') . '>'. $w['name'] .'</option>';
                    ?>
                </select>
            </td>
            <td>
                <select class="form-control" name="id" style="width:150px;">
                    <?php
                        foreach ($towns as $id => $name)
                            echo '<option value="'. $id .'"' . ($townid != $id ?: ' selected') . '>'. $name .'</option>';
                    ?>
                </select>
            </td>
            <td>
                <select class="form-control" name="order" style="width:150px;">
                    <?php
                        $order_allowed = array('id', 'name', 'size', 'beds', 'rent', 'owner');
                        foreach($order_allowed as $o)
                            echo '<option value="' . $o . '"' . ($o != $order ?: ' selected') . '>' . ucfirst($o) . '</option>';
                    ?>
                </select>
            </td>
            <td>
                <select class="form-control" name="type" style="width:150px;">
                    <?php
                        $type_allowed = array('desc', 'asc');
                        foreach($type_allowed as $t)
                            echo '<option value="' . $t . '"' . ($t != $type ?: ' selected') . '>' . ($t == 'desc' ? 'Descending' : 'Ascending') .'</option>';
                    ?>
                </select>
            </td>
            <td>
                <input type="submit" value="View" class="btn btn-info"/>
            </td>
        </tr>
    </p>
</form>
<?php
if(!in_array($order, $order_allowed))
$order = 'id';

if(!in_array($type, $type_allowed))
$type = 'desc';

$av_worlds = get_av_worlds();
if(!in_array($world, $av_worlds))
$world = 0;

// Create or fetch data from cache

You were missing <td>...</td> for each select
works thanks you man!
 
Back
Top