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

Windows Znote Acc reset system

juansanchez

Intermediate OT User
Joined
Apr 2, 2015
Messages
217
Reaction score
130
Hey otland guys, i recently downloaded Znote acc for my 10.90 server, however my server requires a reset system, and my old one doesn't work (it was in game, not on site), does anyone knows/have a reset system?

I'm using Tfs 1.2
 
Solution
With reset column in players table:

PHP:
<?php require_once 'engine/init.php'; protect_page(); include 'layout/overall/header.php';

// Get player List from logged in account, with extra data to see resets, if they can reset, level requirement for their reset.
function getSpecialPlayerList($account_id, $player_id = 0) {
    $player_id = (int)$player_id;
    $where_player = ($player_id > 0) ? "AND `p`.`id`={$player_id}" : "";
    return mysql_select_multi("
        SELECT
            `p`.`id`,
            `p`.`name`,
            `p`.`level`,
            `p`.`reset`,

            CASE WHEN `o`.`player_id` IS NULL...
What do you mean with reset system?

If you mean recover system, ZnoteAAC got one built in the AAC already.
Check more here:
https://github.com/Znote/ZnoteAAC/blob/master/config.php#L527

You need to download PHPMailer in order to get the recovery system to work:
https://github.com/Znote/ZnoteAAC/blob/master/config.php#L521

Reset system like, the palyer get to a certain level, let's say 300, then he can reset if he wishes, he doesn't lose his items/cap/skills/hp/mana, only his level goes back to 8, then he keeps on reseting to get more hp/mana. But after a few resets, the leve which the player resets, get's higher and higher.
 
With reset column in players table:

PHP:
<?php require_once 'engine/init.php'; protect_page(); include 'layout/overall/header.php';

// Get player List from logged in account, with extra data to see resets, if they can reset, level requirement for their reset.
function getSpecialPlayerList($account_id, $player_id = 0) {
    $player_id = (int)$player_id;
    $where_player = ($player_id > 0) ? "AND `p`.`id`={$player_id}" : "";
    return mysql_select_multi("
        SELECT
            `p`.`id`,
            `p`.`name`,
            `p`.`level`,
            `p`.`reset`,

            CASE WHEN `o`.`player_id` IS NULL
                THEN 0
                ELSE 1
            END AS `online`,

            CASE WHEN `a`.`premdays` > 0 THEN
                CASE
                    WHEN `p`.`reset` >= 15 THEN 360
                    WHEN (`p`.`reset` BETWEEN 10 and 14) THEN 355
                    WHEN (`p`.`reset` BETWEEN 5 and 9) THEN 340
                    WHEN (`p`.`reset` BETWEEN 0 and 4) THEN 330
                    ELSE 330
                END
            ELSE
                CASE
                    WHEN `p`.`reset` >= 10 THEN 360
                    WHEN (`p`.`reset` BETWEEN 5 and 9) THEN 355
                    WHEN (`p`.`reset` BETWEEN 0 and 4) THEN 350
                    ELSE 350
                END
            END AS `requirement`,

            CASE WHEN `a`.`premdays` > 0 THEN
                CASE
                    WHEN `p`.`reset` >= 15 AND `p`.`level` >= 360 THEN 1
                    WHEN (`p`.`reset` BETWEEN 10 and 14) AND `p`.`level` >= 355 THEN 1
                    WHEN (`p`.`reset` BETWEEN 5 and 9) AND `p`.`level` >= 340 THEN 1
                    WHEN (`p`.`reset` BETWEEN 0 and 4) AND `p`.`level` >= 330 THEN 1
                    ELSE 0
                END
            ELSE
                CASE
                    WHEN `p`.`reset` >= 10 AND `p`.`level` >= 360 THEN 1
                    WHEN (`p`.`reset` BETWEEN 5 and 9) AND `p`.`level` >= 355 THEN 1
                    WHEN (`p`.`reset` BETWEEN 0 and 4) AND `p`.`level` >= 350 THEN 1
                    ELSE 0
                END
            END AS `can_reset`

        FROM `players` AS `p`
        INNER JOIN `accounts` AS `a`
            ON `p`.`account_id` = `a`.`id`
        LEFT JOIN `players_online` AS `o`
            ON `p`.`id` = `o`.`player_id`
        WHERE `p`.`account_id` = {$account_id}
        {$where_player}
    ");
}

// Get account_id of logged in player
$account_id = (int)$session_user_id;

// Handle reset action
$player_id = (isset($_POST['player_id'])) ? (int)getValue($_POST['player_id']) : false;
if ($player_id !== false) {
    $player = getSpecialPlayerList($account_id, $player_id);
    if ($player !== false && !empty($player)) {
        $player = $player[0];
        if ($player['can_reset'] == 1) {
            if ($player['online'] == 0) {
                mysql_update("
                    UPDATE `players` SET
                        `reset` = (`reset`+1),
                        `level` = 8,
                        `experience` = 4200
                    WHERE `id`={$player_id}
                ");
                ?><p><strong>Success:</strong> Player has been reset!</p><?php
            } else {
                ?><p><strong>Error:</strong> player must be offline.</p><?php
            }
        } else {
            ?><p><strong>Error:</strong> You cannot reset this player.</p><?php
        }
    }
}

$playerList = getSpecialPlayerList($account_id);
?>

<h1>Player Reset System</h1>

<!-- If account don't have any players -->
<?php if (empty($playerList) || $playerList === false):
    ?>
    <p>You don't have any players yet.</p>
    <?php include 'layout/overall/footer.php'; exit();
endif; ?>

<!-- Player Reset Table -->
<table class="tbl_reset_player">
    <thead>
        <tr>
            <th>Name</th>
            <th>Resets</th>
            <th>Level</th>
            <th>Requirement</th>
            <th>Reset</th>
        </tr>
    </thead>
    <tbody>
        <?php foreach($playerList as $player): ?>
            <tr>
                <td><?php echo $player['name']; ?></td>
                <td><?php echo $player['reset']; ?></td>
                <td><?php echo $player['level']; ?></td>
                <td><?php echo $player['requirement']; ?></td>
                <td>
                    <?php if ($player['can_reset'] == 1): ?>
                        <form action="" method="post">
                            <input type="hidden" name="player_id" value="<?php echo $player['id']; ?>">
                            <input type="submit" value="Reset">
                        </form>
                    <?php endif; ?>
                </td>
            </tr>
        <?php endforeach; ?>
    </tbody>
</table>

<!-- Table CSS style -->
<style type="text/css">
    .tbl_reset_player th {
        padding: 5px;
        line-height: 2.5;
    }
    .tbl_reset_player td {
        text-align: center;
    }
</style>
<?php include 'layout/overall/footer.php'; ?>

With player storagevalue:
Diff history:
PHP:
<?php require_once 'engine/init.php'; protect_page(); include 'layout/overall/header.php';

// Player storagevalue that keeps track of the resets
$playerStorage_reset = 378378; 

// Get player List from logged in account, with extra data to see resets, if they can reset, level requirement for their reset.
function getSpecialPlayerList($account_id, $playerStorage_reset, $player_id = 0) {
    $account_id = (int)$account_id;
    $playerStorage_reset = (int)$playerStorage_reset;
    $player_id = (int)$player_id;
    
    $where_player = ($player_id > 0) ? "AND `p`.`id`={$player_id}" : "";
    return mysql_select_multi("
        SELECT
            `p`.`id`,
            `p`.`name`,
            `p`.`level`,
            IFNULL(`s`.`value`, 0) AS `reset`,

            CASE WHEN `o`.`player_id` IS NULL
                THEN 0
                ELSE 1
            END AS `online`,

            CASE WHEN `a`.`premdays` > 0 THEN
                CASE
                    WHEN IFNULL(`s`.`value`, 0) >= 15 THEN 360
                    WHEN (IFNULL(`s`.`value`, 0) BETWEEN 10 and 14) THEN 355
                    WHEN (IFNULL(`s`.`value`, 0) BETWEEN 5 and 9) THEN 340
                    WHEN (IFNULL(`s`.`value`, 0) BETWEEN 0 and 4) THEN 330
                    ELSE 330
                END
            ELSE
                CASE
                    WHEN IFNULL(`s`.`value`, 0) >= 10 THEN 360
                    WHEN (IFNULL(`s`.`value`, 0) BETWEEN 5 and 9) THEN 355
                    WHEN (IFNULL(`s`.`value`, 0) BETWEEN 0 and 4) THEN 350
                    ELSE 350
                END
            END AS `requirement`,

            CASE WHEN `a`.`premdays` > 0 THEN
                CASE
                    WHEN IFNULL(`s`.`value`, 0) >= 15 AND `p`.`level` >= 360 THEN 1
                    WHEN (IFNULL(`s`.`value`, 0) BETWEEN 10 and 14) AND `p`.`level` >= 355 THEN 1
                    WHEN (IFNULL(`s`.`value`, 0) BETWEEN 5 and 9) AND `p`.`level` >= 340 THEN 1
                    WHEN (IFNULL(`s`.`value`, 0) BETWEEN 0 and 4) AND `p`.`level` >= 330 THEN 1
                    ELSE 0
                END
            ELSE
                CASE
                    WHEN IFNULL(`s`.`value`, 0) >= 10 AND `p`.`level` >= 360 THEN 1
                    WHEN (IFNULL(`s`.`value`, 0) BETWEEN 5 and 9) AND `p`.`level` >= 355 THEN 1
                    WHEN (IFNULL(`s`.`value`, 0) BETWEEN 0 and 4) AND `p`.`level` >= 350 THEN 1
                    ELSE 0
                END
            END AS `can_reset`

        FROM `players` AS `p`
        INNER JOIN `accounts` AS `a`
            ON `p`.`account_id` = `a`.`id`
        LEFT JOIN `players_online` AS `o`
            ON `p`.`id` = `o`.`player_id`
        LEFT JOIN `player_storage` AS `s`
            ON `p`.`id` = `s`.`player_id`
            AND `s`.`key` = {$playerStorage_reset}
        WHERE `p`.`account_id` = {$account_id}
        {$where_player}
    ");
}

// Get account_id of logged in player
$account_id = (int)$session_user_id;

// Handle reset action
$player_id = (isset($_POST['player_id'])) ? (int)getValue($_POST['player_id']) : false;
if ($player_id !== false) {
    $player = getSpecialPlayerList($account_id, $playerStorage_reset, $player_id);
    if ($player !== false && !empty($player)) {
        $player = $player[0];
        if ($player['can_reset'] == 1) {
            if ($player['online'] == 0) {
                mysql_update("
                    UPDATE `players` SET
                        `level` = 8,
                        `experience` = 4200
                    WHERE `id`={$player_id}
                ");
                $playerStorage_reset = (int)$playerStorage_reset;
                setPlayerStorage($player_id, $playerStorage_reset, (int)$player['reset'] + 1)
                ?><p><strong>Success:</strong> Player has been reset!</p><?php
            } else {
                ?><p><strong>Error:</strong> player must be offline.</p><?php
            }
        } else {
            ?><p><strong>Error:</strong> You cannot reset this player.</p><?php
        }
    }
}

$playerList = getSpecialPlayerList($account_id, $playerStorage_reset);
?>

<h1>Player Reset System</h1>

<!-- If account don't have any players -->
<?php if (empty($playerList) || $playerList === false):
    ?>
    <p>You don't have any players yet.</p>
    <?php include 'layout/overall/footer.php'; exit();
endif; ?>

<!-- Player Reset Table -->
<table class="tbl_reset_player">
    <thead>
        <tr>
            <th>Name</th>
            <th>Resets</th>
            <th>Level</th>
            <th>Requirement</th>
            <th>Reset</th>
        </tr>
    </thead>
    <tbody>
        <?php foreach($playerList as $player): ?>
            <tr>
                <td><?php echo $player['name']; ?></td>
                <td><?php echo $player['reset']; ?></td>
                <td><?php echo $player['level']; ?></td>
                <td><?php echo $player['requirement']; ?></td>
                <td>
                    <?php if ($player['can_reset'] == 1): ?>
                        <form action="" method="post">
                            <input type="hidden" name="player_id" value="<?php echo $player['id']; ?>">
                            <input type="submit" value="Reset">
                        </form>
                    <?php endif; ?>
                </td>
            </tr>
        <?php endforeach; ?>
    </tbody>
</table>

<!-- Table CSS style -->
<style type="text/css">
    .tbl_reset_player th {
        padding: 5px;
        line-height: 2.5;
    }
    .tbl_reset_player td {
        text-align: center;
    }
</style>
<?php include 'layout/overall/footer.php'; ?>
 
Last edited:
Solution
I'd really love one of these but I use the storage 378378 from player_storage (that has player_id/key/value) instead of a column for my resets.. could you hand me some help?
 
I'd really love one of these but I use the storage 378378 from player_storage (that has player_id/key/value) instead of a column for my resets.. could you hand me some help?

Done, updated my answer and added another version using player storagevalue 378378.
 
was getting an " Table 'forgottenserver.players_online' doesn't exist " when trying to access the page, here's the query if anyone needs it too
SQL:
CREATE TABLE IF NOT EXISTS `players_online` (
  `player_id` int(11) NOT NULL,
  PRIMARY KEY (`player_id`)
) ENGINE=MEMORY;
and thank you znote
 
Last edited:
was getting an " Table 'forgottenserver.players_online' doesn't exist " when trying to access the page, here's the query if anyone needs it too
SQL:
CREATE TABLE IF NOT EXISTS `players_online` (
  `player_id` int(11) NOT NULL,
  PRIMARY KEY (`player_id`)
) ENGINE=MEMORY;
and thank you znote

Thats a bad idea!
Adding this table wont stop players from using reset when their player is online, and then when they logout they will not get the reset.

For TFS 0.3/4
In the SQL query, change:
SQL:
CASE WHEN `o`.`player_id` IS NULL
    THEN 0
    ELSE 1
END AS `online`,

With:
SQL:
`p`.`online`

And lower down in the query, remove:
SQL:
LEFT JOIN `players_online` AS `o`
    ON `p`.`id` = `o`.`player_id`

And it should work properly.
 
Back
Top