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

Lua Znote, OTHire Ban List Problem

Arcadius

Banned User
Joined
Sep 11, 2014
Messages
60
Reaction score
1
Location
Developing
So Im trying to just fetch atleast one user from the ban list to atleast get a start for the page, so I can later make it list last 25 banned or something. But right now, I cant even get it to display the name or comment from ban table.

I am using OTHire and Znote, here is what I have made so far.

Code:
<?php require_once 'engine/init.php'; include 'layout/overall/header.php';

echo '<table border="0" cellspacing="0"><tr class="yellow"><td><center>Ban Table</center></td></tr>
<tr><td>';
$baninfo = mysql_query("SELECT `id`, `comment` FROM `bans` ORDER BY `id` DESC LIMIT 1");
$bans = mysql_fetch_assoc($baninfo);
echo '<center>Our last banned player: '.$bans['id'].' for '.$bans['comment'].'</a></center></td></tr>';
echo '</table>';

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

If anyone can help me figure this out, I would greatly appreciate it.
 
Something like~ > Using foreach below (haven't tested)

Code:
<?php require_once 'engine/init.php'; include 'layout/overall/header.php';

echo '<table border="0" cellspacing="0"><tr class="yellow"><td><center>Ban Table</center>
<tr>';
$baninfo = mysql_query("SELECT `id`, `comment` FROM `bans` ORDER BY `id` DESC LIMIT 1");
foreach ($baninfo as $bans) {
echo '<td><center>Our last banned player: '.$bans['id'].' for '.$bans['comment'].'</a></center></td>';
}
echo '</tr></table>';

include 'layout/overall/footer.php'; ?>
 
Don't use mysql_query, its deprecated in Znote AAC 1.5+, and PHP 5.5+

Use the Znote helper functions. Its also much easier that way.
PHP:
<?php require_once 'engine/init.php'; include 'layout/overall/header.php';

// Fetch ban data and store it as an array[row][columns] = value
$bans = mysql_select_multi("SELECT `id`, `comment` FROM `bans` ORDER BY `id` DESC LIMIT 25");
?>
<table border="0" cellspacing="0">
    <tr class="yellow">
        <td><center>Ban Table</center></td>
    </tr>
    <?php
    foreach ($bans as $ban) {
        ?>
        <tr>
            <td><center><?php echo "Ban id: ".$ban['id']." for ".$ban['comment']; ?></center></td>
        </tr>
        <?php
    }
    ?>
</table>

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

Also its ugly to output html tags with echo. Break out of PHP to do HTML stuff. We do not have a template engine so we don't need to intentionally write ugly code.

PHP:
<?php
// MySQL helper functions on Znote AAC:

// Fetch latest player joined and store it as an array[column] = value
$player = mysql_select_single("SELECT `name` FROM `players` ORDER BY `id` DESC LIMIT 1;");

if ($player === false) echo "No players exist.";
else echo "Welcome to our server: " . $player['name'];

// Fetch latest 5 players and store it as an array[row][column] = value
$players = mysql_select_multi("SELECT `name`, `vocation` FROM `players` ORDER BY `id` DESC LIMIT 5;");

if ($players === false) echo "No players exist.";
else {
    echo "Latest " . count($players) . " info:";
    foreach ($players as $player) {
        echo $player['name'] . " is vocation: " . vocation_id_to_name($player['vocation']);
    }
}
// Also got: mysql_update(QUERY), mysql_delete(QUERY), mysql_insert(QUERY) which are void queries that don't return data. 
?>
 
Last edited:
This, actually, is ones opinion.

echo "<div class=\"post\"><h1>Sure, you are correct.</h1><p>I'm sorry for saying my <strong>presumptions</strong></p></div>";

But considering my whole AAC is made this way, I believe having some consistency is good.
 
echo "<div class=\"post\"><h1>Sure, you are correct.</h1><p>I'm sorry for saying my <strong>presumptions</strong></p></div>";

But considering my whole AAC is made this way, I believe having some consistency is good.

Just use single quotes for echo if backslashes are looking bad for you. It seems better to just quote them instead of adding a lot of PHP tags just to close statements. In regular programming languages you dont have a choice and PHP teaches a lot of bad habits.
 
@Znote - Hey there Znote, thanks a bunch for the fix! Although right now it displays like this.

Code:
Ban id: 28 for Auto-Ban: Excessive Player Killing. 
Ban id: 27 for Auto-Ban: Excessive Player Killing.

It doesnt actually show the players names unfortunately, I have tried to make a mysql code that uses playerid from ban table to search players table to get the name but I am having no success.
 
@Znote - Hey there Znote, thanks a bunch for the fix! Although right now it displays like this.

Code:
Ban id: 28 for Auto-Ban: Excessive Player Killing.
Ban id: 27 for Auto-Ban: Excessive Player Killing.

It doesnt actually show the players names unfortunately, I have tried to make a mysql code that uses playerid from ban table to search players table to get the name but I am having no success.
Something like this
Again haven't tested this, it may not work immediately but if you can understand it you should get it working with minor edits.
Brief explanation:
`b` = "bans" > to make it shorter I used `b`
`p`= "players" > same thing >> "SELECT bans.id, players.name
Code:
$bans = mysql_select_multi("SELECT `b`.`id`, `b`.`comment`, `p`.`name`, `p`.`vocation` FROM `bans` AS `b` INNER JOIN `players` AS `p` ON `b`.`id`=`p`.`id` ORDER BY `id` DESC LIMIT 25");
 
It is a bit more tricky than that, because bans.id is not equal to players.id.

-ev4CCM.png


if bans.type is 1 then bans.value is a long representation of player IP
if bans.type is 2 then bans.value is players.id
if bans.type is 3 then bans.value is accounts.id
if bans.type is 4 then bans.value is accounts.id
 
I am with the same problem when trying to transform the id value to the player's name and try in a thousand ways and it doesn't work for me since the system only integrates the id but not the player's name


someone solved it if so please put the solution here thanks
 
Back
Top