• 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 Direct premium purchase through site goes free account upon login

rdz92

Member
Joined
Apr 19, 2022
Messages
26
Reaction score
7
Hello,
So I'm getting this issue where whenever I buy premium directly from the website something goes wrong ingame.
So Premium does add to account if you check both my account page and database it's there however as soon as you enter your login info in client and character selection loads the account becomes free account imidiatly (even in website and database)
I'm not sure what script I should post here.
Anyone got a clue? I appriciate any help I can get :)!
 
Solution
Created new account. Before buying premium: premdays (0) lastday (0)

after buying premium: premdays (30) lastday (1657003954) <--- is this the issue? is lastday supposed to record your start of premium or lastday of premium?
Upon entering character list both columns resets to 0

EDIT:
Ok I think I know where the issue is.
When I buy premium on website, it registers lastday as when premium comes to an END (eg. 5 july)
When I use a premium scroll ingame it registers lastday as when premium STARTS (eg. 5 june)

How do I alter this?
Weird, cause lastday means lastday and no firstday hehehe.

But, you can change in the website function to add only the time now and not time now + days.

Go in your web...
It's likely to be a login script that is effecting something.

check all your login scripts in data/creaturescripts and if you have any revscripts with login in data/scripts

You'd be looking for something that gives/alters premium time or status

--
Edit

Or the website is giving premium time in an invalid format, maybe?
And then it resets to 0 when logging in?

Fairly unlikely tho.
I'd check for the login scripts first.
 
I just remembered that I forgot to mention: if I buy a premium scroll through the website and use it ingame it works flawlessly. I'm not sure if this information is of any value.

I will check those scripts as soon as I get home. Thanks @Xikini


EDIT:
I checked everything in data/creaturescripts & inside data/scripts and found no login scripts that is altering. Even tried removing login scripts and testing and it still has the same symptoms.
So basically you don't even have to log into the game with a character, as soon as you enter account and password number and char list is being loaded it resets account to free.

Anyone got a clue?
 
Last edited:
Hello,
So I'm getting this issue where whenever I buy premium directly from the website something goes wrong ingame.
So Premium does add to account if you check both my account page and database it's there however as soon as you enter your login info in client and character selection loads the account becomes free account imidiatly (even in website and database)
I'm not sure what script I should post here.
Anyone got a clue? I appriciate any help I can get :)!
When you bought premium direct from znote shop, the premium days is automatic credited into your account. so, make sure you use the web version according to your server version. And you dont need any lua to make works, only relog maybe(acc relog).

TFS 1.5 uses premium_ends_at in DB as os.time()(days * 86400 seconds = 1 day) and some otx uses days(1 = 1 day) for exemple. So, you need to make sure that youre using the correct znote version and put correct in config.php.

For servers 1.5x(1.4x too?) uses znote 2.0+
For 1.3x or lower uses znote 1.6
For 1.0x lower 1.5 is fine

Idk if is that, just go repository and see.
 
When you bought premium direct from znote shop, the premium days is automatic credited into your account. so, make sure you use the web version according to your server version. And you dont need any lua to make works, only relog maybe(acc relog).

TFS 1.5 uses premium_ends_at in DB as os.time()(days * 86400 seconds = 1 day) and some otx uses days(1 = 1 day) for exemple. So, you need to make sure that youre using the correct znote version and put correct in config.php.

For servers 1.5x(1.4x too?) uses znote 2.0+
For 1.3x or lower uses znote 1.6
For 1.0x lower 1.5 is fine

Idk if is that, just go repository and see.
I am using znote 1.6 with tfs 1.2.
Anyway like I said it does actually put the premium days in to the database so there is no issue there I guess.
It's only after I type in account and password and on that moment I press enter it removes all premium days...
It's really odd.
 
I am using znote 1.6 with tfs 1.2.
Anyway like I said it does actually put the premium days in to the database so there is no issue there I guess.
It's only after I type in account and password and on that moment I press enter it removes all premium days...
It's really odd.
Look at creaturescripts if is there something related to premium.

With scroll you have no problem?
 
Look at creaturescripts if is there something related to premium.

With scroll you have no problem?
I have no problems with scrolls! Only when purchased directly to account on website.

Here is my login.lua It's the only script that even mentions anything with premium.
I have already tried removing login.lua and it still does the same thing unfortunatly.

I might be wrong but doesnt login scripts activate at the exact moment a character logs in?
Not when character list is loaded?

Lua:
function Player.sendTibiaTime(self, hours, minutes)
    local msg = NetworkMessage()
    msg:addByte(0xEF)
    msg:addByte(hours)
    msg:addByte(minutes)
    msg:sendToPlayer(self)
    msg:delete()
    return true
end

local function onMovementRemoveProtection(cid, oldPosition, time)
    local player = Player(cid)
    if not player then
        return true
    end

    local playerPosition = player:getPosition()
    if (playerPosition.x ~= oldPosition.x or playerPosition.y ~= oldPosition.y or playerPosition.z ~= oldPosition.z) or player:getTarget() then
        player:setStorageValue(Storage.combatProtectionStorage, 0)
        return true
    end

    addEvent(onMovementRemoveProtection, 1000, cid, oldPosition, time - 1)
end

function onLogin(player)
    local loginStr = 'Welcome to ' .. configManager.getString(configKeys.SERVER_NAME) .. '!'
    if player:getLastLoginSaved() <= 0 then
        loginStr = loginStr .. ' Please choose your outfit.'
        player:sendOutfitWindow()
    else
        if loginStr ~= "" then
            player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
        end

        loginStr = string.format('Your last visit was on %s.', os.date('%a %b %d %X %Y', player:getLastLoginSaved()))
    end

    player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)

    local playerId = player:getId()
  
    -- Stamina
    nextUseStaminaTime[player.uid] = 0
  


    if (player:getGroup():getId() >= 4) then
        --player:setGhostMode(true)
    end

  
    if (player:getAccountType() == ACCOUNT_TYPE_TUTOR) then
        local msg = [[:: Tutor Rules
1 *> 3 Warnings you lose the job.
2 *> Without parallel conversations with players in Help, if the player starts offending, you simply mute it.
3 *> Be educated with the players in Help and especially in the Private, try to help as much as possible.
4 *> Always be on time, if you do not have a justification you will be removed from the staff.
5 *> Help is only allowed to ask questions related to tibia.
6 *> It is not allowed to divulge time up or to help in quest.
7 *> You are not allowed to sell items in the Help.
8 *> If the player encounters a bug, ask to go to the website to send a ticket and explain in detail.
9 *> Always keep the Tutors Chat open. (required).
10 *> You have finished your schedule, you have no tutor online, you communicate with some CM in-game or ts and stay in the help until someone logs in, if you can.
11 *> Always keep a good Portuguese in the Help, we want tutors who support, not that they speak a satanic ritual.
12 *> If you see a tutor doing something that violates the rules, take a print and send it to your superiors. "
- Commands -
Mute Player: / mute nick, 90. (90 seconds)
Unmute Player: / unmute nick.
- Commands -]]
        player:popupFYI(msg)
    end

  
    -- Premium system
    local rookTownId = 6
    local thaisTownId = 2

    if player:isPremium() and player:getStorageValue(43434) ~= 1 then
        player:setStorageValue(43434, 1)
    elseif not player:isPremium() and player:getStorageValue(43434) == 1 then
        if player:getVocation():getId() == 0 then
            player:setTown(Town(rookTownId))
        else
            player:setTown(Town(thaisTownId))
        end
        player:sendTextMessage(22, "Your premium time has ended. Please renew to enjoy premium features.")
        player:setStorageValue(43434, -1)     
        player:teleportTo(player:getTown():getTemplePosition())
    end
  
    -- Outfits
    if not player:isPremium() then
        if player:getSex() == PLAYERSEX_FEMALE then
            local outfit = player:getOutfit()
            if outfit.lookType > 136 then
                player:setOutfit({lookType = 136, lookHead = 78, lookBody = 106, lookLegs = 58, lookFeet = 95})
            end
        else
            local outfit = player:getOutfit()
            if outfit.lookType > 128 then
                player:setOutfit({lookType = 128, lookHead = 78, lookBody = 106, lookLegs = 58, lookFeet = 95})
            end
        end
    end
  
    -- Promotion
    if player:isPremium() then
        if player:getVocation():getId() ~= 0 and player:getVocation():getId() < 5 and player:getStorageValue(30018) == 1 then
            player:setVocation(player:getVocation():getId() + 4)
        end
    else
        if player:getVocation():getId() ~= 0 and player:getVocation():getId() > 4 then
            player:setVocation(player:getVocation():getId() - 4)
        end
    end
  
     -- OPEN CHANNELS
    if table.contains({"Rookgaard", "Dawnport"}, player:getTown():getName())then
        player:openChannel(3) -- world chat
        player:openChannel(6) -- advertsing rook main
    else
        player:openChannel(3) -- world chat
        player:openChannel(5) -- advertsing main
    end

  
     if player:getStorageValue(Storage.combatProtectionStorage) < 1 then
        player:setStorageValue(Storage.combatProtectionStorage, 1)
        onMovementRemoveProtection(playerId, player:getPosition(), 10)
    end

  
    return true
end
 
I have no problems with scrolls! Only when purchased directly to account on website.

Here is my login.lua It's the only script that even mentions anything with premium.
I have already tried removing login.lua and it still does the same thing unfortunatly.

I might be wrong but doesnt login scripts activate at the exact moment a character logs in?
Not when character list is loaded?

Lua:
function Player.sendTibiaTime(self, hours, minutes)
    local msg = NetworkMessage()
    msg:addByte(0xEF)
    msg:addByte(hours)
    msg:addByte(minutes)
    msg:sendToPlayer(self)
    msg:delete()
    return true
end

local function onMovementRemoveProtection(cid, oldPosition, time)
    local player = Player(cid)
    if not player then
        return true
    end

    local playerPosition = player:getPosition()
    if (playerPosition.x ~= oldPosition.x or playerPosition.y ~= oldPosition.y or playerPosition.z ~= oldPosition.z) or player:getTarget() then
        player:setStorageValue(Storage.combatProtectionStorage, 0)
        return true
    end

    addEvent(onMovementRemoveProtection, 1000, cid, oldPosition, time - 1)
end

function onLogin(player)
    local loginStr = 'Welcome to ' .. configManager.getString(configKeys.SERVER_NAME) .. '!'
    if player:getLastLoginSaved() <= 0 then
        loginStr = loginStr .. ' Please choose your outfit.'
        player:sendOutfitWindow()
    else
        if loginStr ~= "" then
            player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
        end

        loginStr = string.format('Your last visit was on %s.', os.date('%a %b %d %X %Y', player:getLastLoginSaved()))
    end

    player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)

    local playerId = player:getId()
 
    -- Stamina
    nextUseStaminaTime[player.uid] = 0
 


    if (player:getGroup():getId() >= 4) then
        --player:setGhostMode(true)
    end

 
    if (player:getAccountType() == ACCOUNT_TYPE_TUTOR) then
        local msg = [[:: Tutor Rules
1 *> 3 Warnings you lose the job.
2 *> Without parallel conversations with players in Help, if the player starts offending, you simply mute it.
3 *> Be educated with the players in Help and especially in the Private, try to help as much as possible.
4 *> Always be on time, if you do not have a justification you will be removed from the staff.
5 *> Help is only allowed to ask questions related to tibia.
6 *> It is not allowed to divulge time up or to help in quest.
7 *> You are not allowed to sell items in the Help.
8 *> If the player encounters a bug, ask to go to the website to send a ticket and explain in detail.
9 *> Always keep the Tutors Chat open. (required).
10 *> You have finished your schedule, you have no tutor online, you communicate with some CM in-game or ts and stay in the help until someone logs in, if you can.
11 *> Always keep a good Portuguese in the Help, we want tutors who support, not that they speak a satanic ritual.
12 *> If you see a tutor doing something that violates the rules, take a print and send it to your superiors. "
- Commands -
Mute Player: / mute nick, 90. (90 seconds)
Unmute Player: / unmute nick.
- Commands -]]
        player:popupFYI(msg)
    end

 
    -- Premium system
    local rookTownId = 6
    local thaisTownId = 2

    if player:isPremium() and player:getStorageValue(43434) ~= 1 then
        player:setStorageValue(43434, 1)
    elseif not player:isPremium() and player:getStorageValue(43434) == 1 then
        if player:getVocation():getId() == 0 then
            player:setTown(Town(rookTownId))
        else
            player:setTown(Town(thaisTownId))
        end
        player:sendTextMessage(22, "Your premium time has ended. Please renew to enjoy premium features.")
        player:setStorageValue(43434, -1)   
        player:teleportTo(player:getTown():getTemplePosition())
    end
 
    -- Outfits
    if not player:isPremium() then
        if player:getSex() == PLAYERSEX_FEMALE then
            local outfit = player:getOutfit()
            if outfit.lookType > 136 then
                player:setOutfit({lookType = 136, lookHead = 78, lookBody = 106, lookLegs = 58, lookFeet = 95})
            end
        else
            local outfit = player:getOutfit()
            if outfit.lookType > 128 then
                player:setOutfit({lookType = 128, lookHead = 78, lookBody = 106, lookLegs = 58, lookFeet = 95})
            end
        end
    end
 
    -- Promotion
    if player:isPremium() then
        if player:getVocation():getId() ~= 0 and player:getVocation():getId() < 5 and player:getStorageValue(30018) == 1 then
            player:setVocation(player:getVocation():getId() + 4)
        end
    else
        if player:getVocation():getId() ~= 0 and player:getVocation():getId() > 4 then
            player:setVocation(player:getVocation():getId() - 4)
        end
    end
 
     -- OPEN CHANNELS
    if table.contains({"Rookgaard", "Dawnport"}, player:getTown():getName())then
        player:openChannel(3) -- world chat
        player:openChannel(6) -- advertsing rook main
    else
        player:openChannel(3) -- world chat
        player:openChannel(5) -- advertsing main
    end

 
     if player:getStorageValue(Storage.combatProtectionStorage) < 1 then
        player:setStorageValue(Storage.combatProtectionStorage, 1)
        onMovementRemoveProtection(playerId, player:getPosition(), 10)
    end

 
    return true
end
You're not wrong.

Idk whats going on, but for sure the problem need to be the premium add function from the website - not that it is spelled wrong, but that maybe it is not being compatible in some way with your server.

PHP:
// Add additional premium days to account id
function user_account_add_premdays($accid, $days) {
    global $tfs_10_hasPremDays; // Initialized in engine/init.php
    $accid = (int)$accid;
    $days = (int)$days;

    if (config('ServerEngine') !== 'OTHIRE') {
        if ($tfs_10_hasPremDays) {
            if (mysql_select_single("SHOW COLUMNS from `accounts` WHERE `Field` = 'lastday'") === false) {
                mysql_update("UPDATE `accounts` SET `premdays` = `premdays`+{$days} WHERE `id`='{$accid}'");
            } else {
                mysql_update("    UPDATE `accounts`
                                SET `premdays` = `premdays`+{$days}
                                ,`lastday` = GREATEST(`lastday`,UNIX_TIMESTAMP(CURDATE())) + ({$days} * 86400)
                                WHERE `id`='{$accid}'
                ");
            }
        } else {
            mysql_update("    UPDATE `accounts`
                            SET `premium_ends_at` = GREATEST(`premium_ends_at`, UNIX_TIMESTAMP(CURDATE())) + ({$days} * 86400)
                            WHERE `id`='{$accid}';
            ");
        }
    } else {
        $data = mysql_select_single("SELECT `premend` FROM `accounts` WHERE `id`='$accid';");
        $tmp = $data['premend'];
        if($tmp == 0)
            $tmp = time() + ($days * 24 * 60 * 60);
        else
            $tmp = $tmp + ($days * 24 * 60 * 60);
        mysql_update("UPDATE `accounts` SET `premend`='$tmp' WHERE `id`='$accid'");
    }
}

Make sure you set the correct version in config.php according to your server engine.

PHP:
// Available options: TFS_02, TFS_03, OTHIRE, TFS_10
    // OTHire = OTHIRE
    // TFS 0.2 = TFS_02
    // TFS 0.3 = TFS_03 (If you are using 0.3.6, set $config['salt'] to false)!
    // TFS 0.4 = TFS_03
    // TFS 1.x = TFS_10 (Current under development version)
    $config['ServerEngine'] = 'TFS_10';
    // As far as I know, OTX is based on TFS_03, so make sure TFS version is configured TFS_03
    $config['CustomVersion'] = false;

In your DB->accounts how premium is spelled?
 
You're not wrong.

Idk whats going on, but for sure the problem need to be the premium add function from the website - not that it is spelled wrong, but that maybe it is not being compatible in some way with your server.

PHP:
// Add additional premium days to account id
function user_account_add_premdays($accid, $days) {
    global $tfs_10_hasPremDays; // Initialized in engine/init.php
    $accid = (int)$accid;
    $days = (int)$days;

    if (config('ServerEngine') !== 'OTHIRE') {
        if ($tfs_10_hasPremDays) {
            if (mysql_select_single("SHOW COLUMNS from `accounts` WHERE `Field` = 'lastday'") === false) {
                mysql_update("UPDATE `accounts` SET `premdays` = `premdays`+{$days} WHERE `id`='{$accid}'");
            } else {
                mysql_update("    UPDATE `accounts`
                                SET `premdays` = `premdays`+{$days}
                                ,`lastday` = GREATEST(`lastday`,UNIX_TIMESTAMP(CURDATE())) + ({$days} * 86400)
                                WHERE `id`='{$accid}'
                ");
            }
        } else {
            mysql_update("    UPDATE `accounts`
                            SET `premium_ends_at` = GREATEST(`premium_ends_at`, UNIX_TIMESTAMP(CURDATE())) + ({$days} * 86400)
                            WHERE `id`='{$accid}';
            ");
        }
    } else {
        $data = mysql_select_single("SELECT `premend` FROM `accounts` WHERE `id`='$accid';");
        $tmp = $data['premend'];
        if($tmp == 0)
            $tmp = time() + ($days * 24 * 60 * 60);
        else
            $tmp = $tmp + ($days * 24 * 60 * 60);
        mysql_update("UPDATE `accounts` SET `premend`='$tmp' WHERE `id`='$accid'");
    }
}
I have this exact code in htdocs\engine\function\user.php

Yes, I have put the right server engine.
In db > accounts premium is spelled premdays.

This is my shop.php
PHP:
<?php require_once 'engine/init.php';
include 'layout/overall/header.php';

if (isset($_GET['callback']) && $_GET['callback'] === 'processing') {
    echo '<script>alert("Seu pagamento está sendo processado pelo PagSeguro...");</script>';
}

// Import from config:
$shop = $config['shop'];
if ($shop['loginToView'] === true) protect_page();
$loggedin = user_logged_in();

$shop_list = $config['shop_offers'];

if ($loggedin === true) {
    if (!empty($_POST['buy']) && $_SESSION['shop_session'] == $_POST['session']) {
        $time = time();
        $player_points = (int)$user_znote_data['points'];
        $cid = (int)$user_data['id'];
        // Sanitizing post, setting default buy value
        $buy = false;
        $post = (int)$_POST['buy'];

        foreach ($shop_list as $key => $value) {
            if ($key === $post) {
                $buy = $value;
            }
        }
        if ($buy === false) die("Error: Shop offer ID mismatch.");

        // Verify that user can afford this offer.
        if ($player_points >= $buy['points']) {
            $data = mysql_select_single("SELECT `points` FROM `znote_accounts` WHERE `account_id`='$cid';");
            if (!$data) die("0: Account is not converted to work with Znote AAC");
            $old_points = $data['points'];
            if ((int)$old_points != (int)$player_points) die("1: Failed to equalize your points.");
            // Remove points if they can afford
            // Give points to user
            $expense_points = $buy['points'];
            $new_points = $old_points - $expense_points;
            $update_account = mysql_update("UPDATE `znote_accounts` SET `points`='$new_points' WHERE `account_id`='$cid'");

            $data = mysql_select_single("SELECT `points` FROM `znote_accounts` WHERE `account_id`='$cid';");
            $verify = $data['points'];
            if ((int)$old_points == (int)$verify) die("2: Failed to equalize your points.". var_dump((int)$old_points, (int)$verify, $new_points, $expense_points));

            // If this is an outfit offer, convert array into an integer.
            if ($buy['type'] == 5) {
                if (is_array($buy['itemid'])) {
                    if (COUNT($buy['itemid']) == 2) $buy['itemid'] = ($buy['itemid'][0] * 1000) + $buy['itemid'][1];
                    else $buy['itemid'] = $buy['itemid'][0];
                }
            }

            // Do the magic (insert into db, or change sex etc)
            // If type is 2 or 3
            if ($buy['type'] == 2) {
                // Add premium days to account
                user_account_add_premdays($cid, $buy['count']);
                echo '<font color="green" size="4">You now have '.$buy['count'].' additional days of premium membership.</font>';
            } else if ($buy['type'] == 3) {
                // Character Gender
                mysql_insert("INSERT INTO `znote_shop_orders` (`account_id`, `type`, `itemid`, `count`, `time`) VALUES ('$cid', '". $buy['type'] ."', '". $buy['itemid'] ."', '". $buy['count'] ."', '$time')");
                echo '<font color="green" size="4">You now have access to change character gender on your characters. Visit <a href="myaccount.php">My Account</a> to select character and change the gender.</font>';
            } else if ($buy['type'] == 4) {
                // Character Name
                mysql_insert("INSERT INTO `znote_shop_orders` (`account_id`, `type`, `itemid`, `count`, `time`) VALUES ('$cid', '". $buy['type'] ."', '". $buy['itemid'] ."', '". $buy['count'] ."', '$time')");
                echo '<font color="green" size="4">You now have access to change character name on your characters. Visit <a href="myaccount.php">My Account</a> to select character and change the name.</font>';
            } else {
                mysql_insert("INSERT INTO `znote_shop_orders` (`account_id`, `type`, `itemid`, `count`, `time`) VALUES ('$cid', '". $buy['type'] ."', '". $buy['itemid'] ."', '". $buy['count'] ."', '$time')");
                echo '<font color="green" size="4">Your order is ready to be delivered. Write this command in-game to get it: [!shop].<br>Make sure you are in depot and can carry it before executing the command!</font>';
            }

            // No matter which type, we will always log it.
            mysql_insert("INSERT INTO `znote_shop_logs` (`account_id`, `player_id`, `type`, `itemid`, `count`, `points`, `time`) VALUES ('$cid', '0', '". $buy['type'] ."', '". $buy['itemid'] ."', '". $buy['count'] ."', '". $buy['points'] ."', '$time')");

        } else echo '<font color="red" size="4">You need more points, this offer cost '.$buy['points'].' points.</font>';
        //var_dump($buy);
        //echo '<font color="red" size="4">'. $_POST['buy'] .'</font>';
    }
}

if ($shop['enabled']) {
?>
<div class="Panel bordered" style="background-image:url('imgs/background1.jpg');background-repeat: repeat;">
        <center>&emsp; &emsp;
<h1>Shop Offers</h1>
<?php
if ($loggedin === true) {
    if (!empty($_POST['buy']) && $_SESSION['shop_session'] == $_POST['session']) {
        if ($user_znote_data['points'] >= $buy['points']) {
            ?><td>You have <font color="lime"><?php echo (int)($user_znote_data['points'] - $buy['points']); ?> </font>points. (<a href="buypoints.php" style="color:lime">Buy points</a>).</td><?php
        } else {
            ?><td>You have <font color="lime"><?php echo $user_znote_data['points']; ?></font> points. (<a href="buypoints.php" style="color:lime">Buy points</a>).</td><?php
        }
    } else {
        ?><td>You have <font color="lime"><?php echo $user_znote_data['points']; ?></font> points. (<a href="buypoints.php" style="color:lime">Buy points</a>).</td><?php
    }
    if ($config['shop_auction']['characterAuction']) {
        ?>
        <p>Interested in buying characters? View the <a href="auctionChar.php">character auction page!</a></p>
        <?php
    }
} else {
    ?><p>You need to be logged in to use the shop.</p><?php
}

$outfitsIds = array(136,137,138,139,140,141,142,147,148,149,150,155,156,157,158,252,269,270,279,288,324,336,366,431,433,464,466,471,513,514,542,128,129,130,131,132,133,134,143,144,145,146,151,152,153,154,251,268,273,278,289,325,335,367,430,432,463,465,472,512,516,541);
$category_items = array();
$category_premium = array();
$category_outfits = array();
$category_mounts = array();
$category_misc = array();
foreach ($shop_list as $key => $offer) {

    switch ($offer['type']) {
        case 1:
            $category_items[$key] = $offer;
        break;
        case 2:
            $category_premium[$key] = $offer;
        break;
        case 3:
            $category_misc[$key] = $offer;
        break;
        case 4:
            $category_misc[$key] = $offer;
        break;
        case 5:
            $category_outfits[$key] = $offer;
        break;
        case 6:
            $category_mounts[$key] = $offer;
        break;
        default:
            $category_misc[$key] = $offer;
        break;
    }
}

// Render a bunch of tables (one for each category)
?></center></div>
<div class="Panel bordered" style="background-image:url('imgs/background1.jpg');background-repeat: repeat;">
        <center>&emsp; &emsp;
<div id="categoryNavigator">
    <a class="nav_link" href="#all" style="font-family: martel;font-size: 18px;color:orange">ALL&emsp; </a>
    <?php if (!empty($category_items)): ?><a class="nav_link" href="#cat_itemids" style="font-family: martel;font-size: 18px;color:orange">ITEMS&emsp; </a><?php endif; ?>
    <?php if (!empty($category_premium)): ?><a class="nav_link" href="#cat_premium" style="font-family: martel;font-size: 18px;color:orange">PREMIUM&emsp; </a><?php endif; ?>
    <?php if (!empty($category_outfits)): ?><a class="nav_link" href="#cat_outfits" style="font-family: martel;font-size: 18px;color:orange">OUTFITS&emsp; </a><?php endif; ?>
    <?php if (!empty($category_mounts)): ?><a class="nav_link" href="#cat_mounts" style="font-family: martel;font-size: 18px;color:orange">MOUNTS&emsp; </a><?php endif; ?>
    <?php if (!empty($category_misc)): ?><a class="nav_link" href="#cat_misc" style="font-family: martel;font-size: 18px;color:orange">MISC&emsp; </a><?php endif; ?>
</div></center>&emsp;&emsp;</div>
<script type="text/javascript">
    function domReady () {
        var links = document.getElementsByClassName("nav_link");
        for (var i=0; i < links.length; i++) {
            links[i].addEventListener('click', function(e){
                e.preventDefault();
                // Hide all tables
                for (var x=0; x < links.length; x++) {
                    var hash = links[x].hash.substr(1);
                    if (hash != 'all') {
                        var table = document.getElementById(hash);
                        if (table.classList.contains("show")) {
                            table.classList.remove("show");
                            table.classList.add("hide");
                        }
                    }
                }
                // Display only the one we selected
                var hash = this.hash.substr(1);
                if (hash != 'all') {
                    var target = document.getElementById(hash);
                    if (target.classList.contains('hide')) {
                        target.classList.remove("hide");
                        target.classList.add("show");
                    }
                } else { // We clicked to show all tables
                    // Show all tables
                    for (var x=0; x < links.length; x++) {
                        var hash = links[x].hash.substr(1);
                        if (hash != 'all') {
                            var table = document.getElementById(hash);
                            if (table.classList.contains("hide")) {
                                table.classList.remove("hide");
                                table.classList.add("show");
                            }
                        }
                    }
                }
            });
        }
    }
    // Mozilla, Opera, Webkit
    if ( document.addEventListener ) {
        document.addEventListener( "DOMContentLoaded", function(){
        document.removeEventListener( "DOMContentLoaded", arguments.callee, false);
        domReady();
      }, false );
    // If IE event model is used
    } else if ( document.attachEvent ) {
        // ensure firing before onload
        document.attachEvent("onreadystatechange", function(){
        if ( document.readyState === "complete" ) {
            document.detachEvent( "onreadystatechange", arguments.callee );
            domReady();
        }
        });
    }
</script>

<?php if (!empty($category_items)): ?>
    <!-- ITEMIDS -->
    <div class="Panel bordered" style="background-image:url('imgs/background1.jpg');background-repeat: repeat;">
        <center>&emsp; &emsp;
    <table class="show" id="cat_itemids">
        <tr class="yellow">
            <td>Item:&emsp; </td>
            <?php if ($config['shop']['showImage']) { ?><td>Image:</td><?php } ?>
            <td>&emsp; Count:</td>
            <td>&emsp; Points:</td>
            <?php if ($loggedin === true): ?><td>&emsp; &emsp; Action:</td><?php endif; ?>
        </tr>
        <?php foreach ($category_items as $key => $offers): ?>
            <tr class="special">
                <td><?php echo $offers['description']; ?></td>
                <?php if ($config['shop']['showImage']):?>
                    <td>&emsp; <img src="http://<?php echo $config['shop']['imageServer']; ?>/<?php echo $offers['itemid']; ?>.<?php echo $config['shop']['imageType']; ?>" alt="img"></td>
                <?php endif; ?>
                <td>&emsp;&emsp;  <?php echo $offers['count']; ?>x</td>
                <td>&emsp;&emsp;  <?php echo $offers['points']; ?></td>
                <?php if ($loggedin === true): ?>
                <td>
                    <form action="" method="POST">
                         <input type="hidden" name="buy" value="<?php echo (int)$key; ?>">
                         <input type="hidden" name="session" value="<?php echo time(); ?>">
                        &emsp; <input type="submit" value="  PURCHASE  " style="color:black" class="needconfirmation" data-item-name="<?php echo $offers['description']; ?>" data-item-cost="<?php echo $offers['points']; ?>">
                    </form>
                </td>
                <?php endif; ?>
            </tr>
        <?php endforeach; ?>
    </table>
<?php endif; ?>
<?php if (!empty($category_premium)): ?>
<!-- PREMIUM DURATION -->

<table class="show" id="cat_premium">
    <tr class="yellow">
        <td>Description:</td>
        <?php if ($config['shop']['showImage']) { ?><td>&emsp;Image:</td><?php } ?>
        <td>&emsp;Duration:</td>
        <td>&emsp;Points:</td>
        <?php if ($loggedin === true): ?><td>&emsp;&emsp;Action:</td><?php endif; ?>
    </tr>
    <?php foreach ($category_premium as $key => $offers): ?>
        <tr class="special">
            <td><?php echo $offers['description']; ?></td>
            <?php if ($config['shop']['showImage']):?>
                <td>&emsp;<img src="http://<?php echo $config['shop']['imageServer']; ?>/<?php echo $offers['itemid']; ?>.<?php echo $config['shop']['imageType']; ?>" alt="img"></td>
            <?php endif; ?>
            <td>&emsp;<?php echo $offers['count']; ?> Days</td>
            <td>&emsp;<?php echo $offers['points']; ?></td>
            <?php if ($loggedin === true): ?>
            <td>
                <form action="" method="POST">
                    <input type="hidden" name="buy" value="<?php echo (int)$key; ?>">
                    <input type="hidden" name="session" value="<?php echo time(); ?>">
                    &emsp;<input type="submit" value="  PURCHASE  " style="color:black" class="needconfirmation" data-item-name="<?php echo $offers['description']; ?>" data-item-cost="<?php echo $offers['points']; ?>">
                </form>
            </td>
            <?php endif; ?>
        </tr>
    <?php endforeach; ?>
</table>
<?php endif; ?>
<?php if (!empty($category_outfits)): ?>
<!-- OUTFITS -->

<table class="show" id="cat_outfits">
    <tr class="yellow">
        <td>Description:</td>
        <?php if ($config['shop']['showImage']) { ?><td>&emsp;Image:</td><?php } ?>
        <td>Points:</td>
        <?php if ($loggedin === true): ?><td>&emsp;&emsp;Action:</td><?php endif; ?>
    </tr>
    <?php foreach ($category_outfits as $key => $offers):
        if (!is_array($offers['itemid'])) $offers['itemid'] = [$offers['itemid']];
        if (COUNT($offers['itemid']) > 2): ?>
            <tr class="special">
                <td colspan="2">
                    <p><strong>Error:</strong> Outfit offer don't support more than 2 outfits. <?php echo COUNT($offers['itemid']); ?> configured.
                        <br>[<?php echo implode(',', $offers['itemid']); ?>]</p>
                </td>
            </tr>
        <?php endif; ?>
        <tr class="special">
            <td><?php echo $offers['description']; ?></td>
            <?php if ($config['show_outfits']['shop']):?>
                <td><?php foreach($offers['itemid'] as $outfitId): ?>
                    <img src="<?php echo $config['show_outfits']['imageServer']; ?>?id=<?php echo $outfitId; ?>&addons=<?php echo $offers['count']; ?>&head=<?php echo rand(1, 132); ?>&body=<?php echo rand(1, 132); ?>&legs=<?php echo rand(1, 132); ?>&feet=<?php echo rand(1, 132); ?>" alt="img">
                <?php endforeach; ?></td>
            <?php endif; ?>
            <td>&emsp;<?php echo $offers['points']; ?></td>
            <?php if ($loggedin === true): ?>
            <td>
                <form action="" method="POST">
                    <input type="hidden" name="buy" value="<?php echo (int)$key; ?>">
                    <input type="hidden" name="session" value="<?php echo time(); ?>">
                    &emsp;<input type="submit" style="color: black" value="  PURCHASE  "  class="needconfirmation" data-item-name="<?php echo $offers['description']; ?>" data-item-cost="<?php echo $offers['points']; ?>">
                </form>
            </td>
            <?php endif; ?>
        </tr>
    <?php endforeach; ?>
</table>
<?php endif; ?>
<?php if (!empty($category_mounts)): ?>
<!-- MOUNTS -->

<table class="show" id="cat_mounts">
    <tr class="yellow">
        <td>Description:</td>
        <?php if ($config['show_outfits']['shop']) { ?><td>Image:</td><?php } ?>
        <td>Points:</td>
        <?php if ($loggedin === true): ?><td>&emsp;&emsp;Action:</td><?php endif; ?>
    </tr>
    <?php foreach ($category_mounts as $key => $offers): ?>
        <tr class="special">
            <td><?php echo $offers['description']; ?></td>
            <?php if ($config['shop']['showImage']):?>
                <td><img src="<?php echo $config['show_outfits']['imageServer']; ?>?id=<?php echo $outfitsIds[rand(0,count($outfitsIds)-1)]; ?>&addons=<?php echo rand(1, 3); ?>&head=<?php echo rand(1, 132); ?>&body=<?php echo rand(1, 132); ?>&legs=<?php echo rand(1, 132); ?>&feet=<?php echo rand(1, 132); ?>&mount=<?php echo $offers['itemid']; ?>&direction=2" alt="img"></td>
            <?php endif; ?>
            <td>&emsp;<?php echo $offers['points']; ?></td>
            <?php if ($loggedin === true): ?>
            <td>
                <form action="" method="POST">
                    <input type="hidden" name="buy" value="<?php echo (int)$key; ?>">
                    <input type="hidden" name="session" value="<?php echo time(); ?>">
                    &emsp;<input type="submit" style="color:black;" value="  PURCHASE  "  class="needconfirmation" data-item-name="<?php echo $offers['description']; ?>" data-item-cost="<?php echo $offers['points']; ?>">
                </form>
            </td>
            <?php endif; ?>
        </tr>
    <?php endforeach; ?>
</table>
<?php endif; ?>
<?php if (!empty($category_misc)): ?>
<!-- MISCELLANEOUS -->

<table class="show" id="cat_misc">
    <tr class="yellow">
        <td>Description:</td>
        <?php if ($config['shop']['showImage']) { ?><td>Image:</td><?php } ?>
        <td>&emsp;Count:</td>
        <td>&emsp;Points:</td>
        <?php if ($loggedin === true): ?><td>&emsp;&emsp;Action:</td><?php endif; ?>
    </tr>
    <?php foreach ($category_misc as $key => $offers): ?>
        <tr class="special">
            <td><?php echo $offers['description']; ?></td>
            <?php if ($config['shop']['showImage']):?>
                <td><img src="http://<?php echo $config['shop']['imageServer']; ?>/<?php echo $offers['itemid']; ?>.<?php echo $config['shop']['imageType']; ?>" alt="img"></td>
            <?php endif;
            if ($offers['count'] === 0): ?>
                <td>Unlimited</td>
            <?php else: ?>
                <td>&emsp;<?php echo $offers['count']; ?>x</td>
            <?php endif; ?>
            <td>&emsp;<?php echo $offers['points']; ?></td>
            <?php if ($loggedin === true): ?>
            <td>
                <form action="" method="POST">
                    <input type="hidden" name="buy" value="<?php echo (int)$key; ?>">
                    <input type="hidden" name="session" value="<?php echo time(); ?>">
                    &emsp;<input type="submit" style="color: black" value="  PURCHASE  "  class="needconfirmation" data-item-name="<?php echo $offers['description']; ?>" data-item-cost="<?php echo $offers['points']; ?>">
                </form>
            </td>
            <?php endif; ?>
        </tr>
    <?php endforeach; ?>
</table></center>&emsp;&emsp;</div>
<?php endif; ?>

<?php if ($shop['enableShopConfirmation']) { ?>
<script src="https://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script>
    $(document).ready(function(){
        $(".needconfirmation").each(function(e){
            $(this).click(function(e){
                var itemname = $(this).attr("data-item-name");
                var itemcost = $(this).attr("data-item-cost");
                var r = confirm("Do you really want to purchase "+itemname+" for "+itemcost+" points?")
                if(r == false){
                    e.preventDefault();
                }
            });
        });
    });
</script>
<?php }

    // Store current timestamp to prevent page-reload from processing old purchase
    $_SESSION['shop_session'] = time();

} else echo '<h1>Buy Points system disabled.</h1><p>Sorry, this functionality is disabled.</p>';
include 'layout/overall/footer.php'; ?>

Config.php:
Config
Thank you for trying to help me, I do appriciate it :)
 
Last edited:
I have this exact code in htdocs\engine\function\user.php

Yes, I have put the right server engine.
In db > accounts premium is spelled premdays.

This is my shop.php
PHP:
<?php require_once 'engine/init.php';
include 'layout/overall/header.php';

if (isset($_GET['callback']) && $_GET['callback'] === 'processing') {
    echo '<script>alert("Seu pagamento está sendo processado pelo PagSeguro...");</script>';
}

// Import from config:
$shop = $config['shop'];
if ($shop['loginToView'] === true) protect_page();
$loggedin = user_logged_in();

$shop_list = $config['shop_offers'];

if ($loggedin === true) {
    if (!empty($_POST['buy']) && $_SESSION['shop_session'] == $_POST['session']) {
        $time = time();
        $player_points = (int)$user_znote_data['points'];
        $cid = (int)$user_data['id'];
        // Sanitizing post, setting default buy value
        $buy = false;
        $post = (int)$_POST['buy'];

        foreach ($shop_list as $key => $value) {
            if ($key === $post) {
                $buy = $value;
            }
        }
        if ($buy === false) die("Error: Shop offer ID mismatch.");

        // Verify that user can afford this offer.
        if ($player_points >= $buy['points']) {
            $data = mysql_select_single("SELECT `points` FROM `znote_accounts` WHERE `account_id`='$cid';");
            if (!$data) die("0: Account is not converted to work with Znote AAC");
            $old_points = $data['points'];
            if ((int)$old_points != (int)$player_points) die("1: Failed to equalize your points.");
            // Remove points if they can afford
            // Give points to user
            $expense_points = $buy['points'];
            $new_points = $old_points - $expense_points;
            $update_account = mysql_update("UPDATE `znote_accounts` SET `points`='$new_points' WHERE `account_id`='$cid'");

            $data = mysql_select_single("SELECT `points` FROM `znote_accounts` WHERE `account_id`='$cid';");
            $verify = $data['points'];
            if ((int)$old_points == (int)$verify) die("2: Failed to equalize your points.". var_dump((int)$old_points, (int)$verify, $new_points, $expense_points));

            // If this is an outfit offer, convert array into an integer.
            if ($buy['type'] == 5) {
                if (is_array($buy['itemid'])) {
                    if (COUNT($buy['itemid']) == 2) $buy['itemid'] = ($buy['itemid'][0] * 1000) + $buy['itemid'][1];
                    else $buy['itemid'] = $buy['itemid'][0];
                }
            }

            // Do the magic (insert into db, or change sex etc)
            // If type is 2 or 3
            if ($buy['type'] == 2) {
                // Add premium days to account
                user_account_add_premdays($cid, $buy['count']);
                echo '<font color="green" size="4">You now have '.$buy['count'].' additional days of premium membership.</font>';
            } else if ($buy['type'] == 3) {
                // Character Gender
                mysql_insert("INSERT INTO `znote_shop_orders` (`account_id`, `type`, `itemid`, `count`, `time`) VALUES ('$cid', '". $buy['type'] ."', '". $buy['itemid'] ."', '". $buy['count'] ."', '$time')");
                echo '<font color="green" size="4">You now have access to change character gender on your characters. Visit <a href="myaccount.php">My Account</a> to select character and change the gender.</font>';
            } else if ($buy['type'] == 4) {
                // Character Name
                mysql_insert("INSERT INTO `znote_shop_orders` (`account_id`, `type`, `itemid`, `count`, `time`) VALUES ('$cid', '". $buy['type'] ."', '". $buy['itemid'] ."', '". $buy['count'] ."', '$time')");
                echo '<font color="green" size="4">You now have access to change character name on your characters. Visit <a href="myaccount.php">My Account</a> to select character and change the name.</font>';
            } else {
                mysql_insert("INSERT INTO `znote_shop_orders` (`account_id`, `type`, `itemid`, `count`, `time`) VALUES ('$cid', '". $buy['type'] ."', '". $buy['itemid'] ."', '". $buy['count'] ."', '$time')");
                echo '<font color="green" size="4">Your order is ready to be delivered. Write this command in-game to get it: [!shop].<br>Make sure you are in depot and can carry it before executing the command!</font>';
            }

            // No matter which type, we will always log it.
            mysql_insert("INSERT INTO `znote_shop_logs` (`account_id`, `player_id`, `type`, `itemid`, `count`, `points`, `time`) VALUES ('$cid', '0', '". $buy['type'] ."', '". $buy['itemid'] ."', '". $buy['count'] ."', '". $buy['points'] ."', '$time')");

        } else echo '<font color="red" size="4">You need more points, this offer cost '.$buy['points'].' points.</font>';
        //var_dump($buy);
        //echo '<font color="red" size="4">'. $_POST['buy'] .'</font>';
    }
}

if ($shop['enabled']) {
?>
<div class="Panel bordered" style="background-image:url('imgs/background1.jpg');background-repeat: repeat;">
        <center>&emsp; &emsp;
<h1>Shop Offers</h1>
<?php
if ($loggedin === true) {
    if (!empty($_POST['buy']) && $_SESSION['shop_session'] == $_POST['session']) {
        if ($user_znote_data['points'] >= $buy['points']) {
            ?><td>You have <font color="lime"><?php echo (int)($user_znote_data['points'] - $buy['points']); ?> </font>points. (<a href="buypoints.php" style="color:lime">Buy points</a>).</td><?php
        } else {
            ?><td>You have <font color="lime"><?php echo $user_znote_data['points']; ?></font> points. (<a href="buypoints.php" style="color:lime">Buy points</a>).</td><?php
        }
    } else {
        ?><td>You have <font color="lime"><?php echo $user_znote_data['points']; ?></font> points. (<a href="buypoints.php" style="color:lime">Buy points</a>).</td><?php
    }
    if ($config['shop_auction']['characterAuction']) {
        ?>
        <p>Interested in buying characters? View the <a href="auctionChar.php">character auction page!</a></p>
        <?php
    }
} else {
    ?><p>You need to be logged in to use the shop.</p><?php
}

$outfitsIds = array(136,137,138,139,140,141,142,147,148,149,150,155,156,157,158,252,269,270,279,288,324,336,366,431,433,464,466,471,513,514,542,128,129,130,131,132,133,134,143,144,145,146,151,152,153,154,251,268,273,278,289,325,335,367,430,432,463,465,472,512,516,541);
$category_items = array();
$category_premium = array();
$category_outfits = array();
$category_mounts = array();
$category_misc = array();
foreach ($shop_list as $key => $offer) {

    switch ($offer['type']) {
        case 1:
            $category_items[$key] = $offer;
        break;
        case 2:
            $category_premium[$key] = $offer;
        break;
        case 3:
            $category_misc[$key] = $offer;
        break;
        case 4:
            $category_misc[$key] = $offer;
        break;
        case 5:
            $category_outfits[$key] = $offer;
        break;
        case 6:
            $category_mounts[$key] = $offer;
        break;
        default:
            $category_misc[$key] = $offer;
        break;
    }
}

// Render a bunch of tables (one for each category)
?></center></div>
<div class="Panel bordered" style="background-image:url('imgs/background1.jpg');background-repeat: repeat;">
        <center>&emsp; &emsp;
<div id="categoryNavigator">
    <a class="nav_link" href="#all" style="font-family: martel;font-size: 18px;color:orange">ALL&emsp; </a>
    <?php if (!empty($category_items)): ?><a class="nav_link" href="#cat_itemids" style="font-family: martel;font-size: 18px;color:orange">ITEMS&emsp; </a><?php endif; ?>
    <?php if (!empty($category_premium)): ?><a class="nav_link" href="#cat_premium" style="font-family: martel;font-size: 18px;color:orange">PREMIUM&emsp; </a><?php endif; ?>
    <?php if (!empty($category_outfits)): ?><a class="nav_link" href="#cat_outfits" style="font-family: martel;font-size: 18px;color:orange">OUTFITS&emsp; </a><?php endif; ?>
    <?php if (!empty($category_mounts)): ?><a class="nav_link" href="#cat_mounts" style="font-family: martel;font-size: 18px;color:orange">MOUNTS&emsp; </a><?php endif; ?>
    <?php if (!empty($category_misc)): ?><a class="nav_link" href="#cat_misc" style="font-family: martel;font-size: 18px;color:orange">MISC&emsp; </a><?php endif; ?>
</div></center>&emsp;&emsp;</div>
<script type="text/javascript">
    function domReady () {
        var links = document.getElementsByClassName("nav_link");
        for (var i=0; i < links.length; i++) {
            links[i].addEventListener('click', function(e){
                e.preventDefault();
                // Hide all tables
                for (var x=0; x < links.length; x++) {
                    var hash = links[x].hash.substr(1);
                    if (hash != 'all') {
                        var table = document.getElementById(hash);
                        if (table.classList.contains("show")) {
                            table.classList.remove("show");
                            table.classList.add("hide");
                        }
                    }
                }
                // Display only the one we selected
                var hash = this.hash.substr(1);
                if (hash != 'all') {
                    var target = document.getElementById(hash);
                    if (target.classList.contains('hide')) {
                        target.classList.remove("hide");
                        target.classList.add("show");
                    }
                } else { // We clicked to show all tables
                    // Show all tables
                    for (var x=0; x < links.length; x++) {
                        var hash = links[x].hash.substr(1);
                        if (hash != 'all') {
                            var table = document.getElementById(hash);
                            if (table.classList.contains("hide")) {
                                table.classList.remove("hide");
                                table.classList.add("show");
                            }
                        }
                    }
                }
            });
        }
    }
    // Mozilla, Opera, Webkit
    if ( document.addEventListener ) {
        document.addEventListener( "DOMContentLoaded", function(){
        document.removeEventListener( "DOMContentLoaded", arguments.callee, false);
        domReady();
      }, false );
    // If IE event model is used
    } else if ( document.attachEvent ) {
        // ensure firing before onload
        document.attachEvent("onreadystatechange", function(){
        if ( document.readyState === "complete" ) {
            document.detachEvent( "onreadystatechange", arguments.callee );
            domReady();
        }
        });
    }
</script>

<?php if (!empty($category_items)): ?>
    <!-- ITEMIDS -->
    <div class="Panel bordered" style="background-image:url('imgs/background1.jpg');background-repeat: repeat;">
        <center>&emsp; &emsp;
    <table class="show" id="cat_itemids">
        <tr class="yellow">
            <td>Item:&emsp; </td>
            <?php if ($config['shop']['showImage']) { ?><td>Image:</td><?php } ?>
            <td>&emsp; Count:</td>
            <td>&emsp; Points:</td>
            <?php if ($loggedin === true): ?><td>&emsp; &emsp; Action:</td><?php endif; ?>
        </tr>
        <?php foreach ($category_items as $key => $offers): ?>
            <tr class="special">
                <td><?php echo $offers['description']; ?></td>
                <?php if ($config['shop']['showImage']):?>
                    <td>&emsp; <img src="http://<?php echo $config['shop']['imageServer']; ?>/<?php echo $offers['itemid']; ?>.<?php echo $config['shop']['imageType']; ?>" alt="img"></td>
                <?php endif; ?>
                <td>&emsp;&emsp;  <?php echo $offers['count']; ?>x</td>
                <td>&emsp;&emsp;  <?php echo $offers['points']; ?></td>
                <?php if ($loggedin === true): ?>
                <td>
                    <form action="" method="POST">
                         <input type="hidden" name="buy" value="<?php echo (int)$key; ?>">
                         <input type="hidden" name="session" value="<?php echo time(); ?>">
                        &emsp; <input type="submit" value="  PURCHASE  " style="color:black" class="needconfirmation" data-item-name="<?php echo $offers['description']; ?>" data-item-cost="<?php echo $offers['points']; ?>">
                    </form>
                </td>
                <?php endif; ?>
            </tr>
        <?php endforeach; ?>
    </table>
<?php endif; ?>
<?php if (!empty($category_premium)): ?>
<!-- PREMIUM DURATION -->

<table class="show" id="cat_premium">
    <tr class="yellow">
        <td>Description:</td>
        <?php if ($config['shop']['showImage']) { ?><td>&emsp;Image:</td><?php } ?>
        <td>&emsp;Duration:</td>
        <td>&emsp;Points:</td>
        <?php if ($loggedin === true): ?><td>&emsp;&emsp;Action:</td><?php endif; ?>
    </tr>
    <?php foreach ($category_premium as $key => $offers): ?>
        <tr class="special">
            <td><?php echo $offers['description']; ?></td>
            <?php if ($config['shop']['showImage']):?>
                <td>&emsp;<img src="http://<?php echo $config['shop']['imageServer']; ?>/<?php echo $offers['itemid']; ?>.<?php echo $config['shop']['imageType']; ?>" alt="img"></td>
            <?php endif; ?>
            <td>&emsp;<?php echo $offers['count']; ?> Days</td>
            <td>&emsp;<?php echo $offers['points']; ?></td>
            <?php if ($loggedin === true): ?>
            <td>
                <form action="" method="POST">
                    <input type="hidden" name="buy" value="<?php echo (int)$key; ?>">
                    <input type="hidden" name="session" value="<?php echo time(); ?>">
                    &emsp;<input type="submit" value="  PURCHASE  " style="color:black" class="needconfirmation" data-item-name="<?php echo $offers['description']; ?>" data-item-cost="<?php echo $offers['points']; ?>">
                </form>
            </td>
            <?php endif; ?>
        </tr>
    <?php endforeach; ?>
</table>
<?php endif; ?>
<?php if (!empty($category_outfits)): ?>
<!-- OUTFITS -->

<table class="show" id="cat_outfits">
    <tr class="yellow">
        <td>Description:</td>
        <?php if ($config['shop']['showImage']) { ?><td>&emsp;Image:</td><?php } ?>
        <td>Points:</td>
        <?php if ($loggedin === true): ?><td>&emsp;&emsp;Action:</td><?php endif; ?>
    </tr>
    <?php foreach ($category_outfits as $key => $offers):
        if (!is_array($offers['itemid'])) $offers['itemid'] = [$offers['itemid']];
        if (COUNT($offers['itemid']) > 2): ?>
            <tr class="special">
                <td colspan="2">
                    <p><strong>Error:</strong> Outfit offer don't support more than 2 outfits. <?php echo COUNT($offers['itemid']); ?> configured.
                        <br>[<?php echo implode(',', $offers['itemid']); ?>]</p>
                </td>
            </tr>
        <?php endif; ?>
        <tr class="special">
            <td><?php echo $offers['description']; ?></td>
            <?php if ($config['show_outfits']['shop']):?>
                <td><?php foreach($offers['itemid'] as $outfitId): ?>
                    <img src="<?php echo $config['show_outfits']['imageServer']; ?>?id=<?php echo $outfitId; ?>&addons=<?php echo $offers['count']; ?>&head=<?php echo rand(1, 132); ?>&body=<?php echo rand(1, 132); ?>&legs=<?php echo rand(1, 132); ?>&feet=<?php echo rand(1, 132); ?>" alt="img">
                <?php endforeach; ?></td>
            <?php endif; ?>
            <td>&emsp;<?php echo $offers['points']; ?></td>
            <?php if ($loggedin === true): ?>
            <td>
                <form action="" method="POST">
                    <input type="hidden" name="buy" value="<?php echo (int)$key; ?>">
                    <input type="hidden" name="session" value="<?php echo time(); ?>">
                    &emsp;<input type="submit" style="color: black" value="  PURCHASE  "  class="needconfirmation" data-item-name="<?php echo $offers['description']; ?>" data-item-cost="<?php echo $offers['points']; ?>">
                </form>
            </td>
            <?php endif; ?>
        </tr>
    <?php endforeach; ?>
</table>
<?php endif; ?>
<?php if (!empty($category_mounts)): ?>
<!-- MOUNTS -->

<table class="show" id="cat_mounts">
    <tr class="yellow">
        <td>Description:</td>
        <?php if ($config['show_outfits']['shop']) { ?><td>Image:</td><?php } ?>
        <td>Points:</td>
        <?php if ($loggedin === true): ?><td>&emsp;&emsp;Action:</td><?php endif; ?>
    </tr>
    <?php foreach ($category_mounts as $key => $offers): ?>
        <tr class="special">
            <td><?php echo $offers['description']; ?></td>
            <?php if ($config['shop']['showImage']):?>
                <td><img src="<?php echo $config['show_outfits']['imageServer']; ?>?id=<?php echo $outfitsIds[rand(0,count($outfitsIds)-1)]; ?>&addons=<?php echo rand(1, 3); ?>&head=<?php echo rand(1, 132); ?>&body=<?php echo rand(1, 132); ?>&legs=<?php echo rand(1, 132); ?>&feet=<?php echo rand(1, 132); ?>&mount=<?php echo $offers['itemid']; ?>&direction=2" alt="img"></td>
            <?php endif; ?>
            <td>&emsp;<?php echo $offers['points']; ?></td>
            <?php if ($loggedin === true): ?>
            <td>
                <form action="" method="POST">
                    <input type="hidden" name="buy" value="<?php echo (int)$key; ?>">
                    <input type="hidden" name="session" value="<?php echo time(); ?>">
                    &emsp;<input type="submit" style="color:black;" value="  PURCHASE  "  class="needconfirmation" data-item-name="<?php echo $offers['description']; ?>" data-item-cost="<?php echo $offers['points']; ?>">
                </form>
            </td>
            <?php endif; ?>
        </tr>
    <?php endforeach; ?>
</table>
<?php endif; ?>
<?php if (!empty($category_misc)): ?>
<!-- MISCELLANEOUS -->

<table class="show" id="cat_misc">
    <tr class="yellow">
        <td>Description:</td>
        <?php if ($config['shop']['showImage']) { ?><td>Image:</td><?php } ?>
        <td>&emsp;Count:</td>
        <td>&emsp;Points:</td>
        <?php if ($loggedin === true): ?><td>&emsp;&emsp;Action:</td><?php endif; ?>
    </tr>
    <?php foreach ($category_misc as $key => $offers): ?>
        <tr class="special">
            <td><?php echo $offers['description']; ?></td>
            <?php if ($config['shop']['showImage']):?>
                <td><img src="http://<?php echo $config['shop']['imageServer']; ?>/<?php echo $offers['itemid']; ?>.<?php echo $config['shop']['imageType']; ?>" alt="img"></td>
            <?php endif;
            if ($offers['count'] === 0): ?>
                <td>Unlimited</td>
            <?php else: ?>
                <td>&emsp;<?php echo $offers['count']; ?>x</td>
            <?php endif; ?>
            <td>&emsp;<?php echo $offers['points']; ?></td>
            <?php if ($loggedin === true): ?>
            <td>
                <form action="" method="POST">
                    <input type="hidden" name="buy" value="<?php echo (int)$key; ?>">
                    <input type="hidden" name="session" value="<?php echo time(); ?>">
                    &emsp;<input type="submit" style="color: black" value="  PURCHASE  "  class="needconfirmation" data-item-name="<?php echo $offers['description']; ?>" data-item-cost="<?php echo $offers['points']; ?>">
                </form>
            </td>
            <?php endif; ?>
        </tr>
    <?php endforeach; ?>
</table></center>&emsp;&emsp;</div>
<?php endif; ?>

<?php if ($shop['enableShopConfirmation']) { ?>
<script src="https://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script>
    $(document).ready(function(){
        $(".needconfirmation").each(function(e){
            $(this).click(function(e){
                var itemname = $(this).attr("data-item-name");
                var itemcost = $(this).attr("data-item-cost");
                var r = confirm("Do you really want to purchase "+itemname+" for "+itemcost+" points?")
                if(r == false){
                    e.preventDefault();
                }
            });
        });
    });
</script>
<?php }

    // Store current timestamp to prevent page-reload from processing old purchase
    $_SESSION['shop_session'] = time();

} else echo '<h1>Buy Points system disabled.</h1><p>Sorry, this functionality is disabled.</p>';
include 'layout/overall/footer.php'; ?>

Config.php:
Config
Thank you for trying to help me, I do appriciate it :)
In your DB accounts, how premium is spelled? Can you attach an img?
 
In your DB accounts, how premium is spelled? Can you attach an img?
Sure I'll attach img! It's spelled premdays.

I have tried a whole different distro/server and even a different schema & even a plain clean install of znote and I still get this issue lol.
I'm honestly super confused.
Could it be an issue cause I'm on localhost, some kind of time sync issue?
 

Attachments

Sure I'll attach img! It's spelled premdays.

I have tried a whole different distro/server and even a different schema & even a plain clean install of znote and I still get this issue lol.
I'm honestly super confused.
Could it be an issue cause I'm on localhost, some kind of time sync issue?

1. Never hear about. Is your watch on time?

2. Just look at your website, if the player creation date is on time(date close to or equal to current date).

3. Is your premium sale on the site the correct type? Type 2 if i remember.
 
1. Never hear about. Is your watch on time?

2. Just look at your website, if the player creation date is on time(date close to or equal to current date).

3. Is your premium sale on the site the correct type? Type 2 if i remember.
1. Yes, time is right. Ingame and even on last login its correct.

2. However seems that player creation date seems to be 2 hours ahead of my time. How do I fix that?
Could this be it?
EDIT: Found and fixed time but it still removes premium xD I'm losing it haha

3. Yes type 2 and itemid 12466
 
Last edited:
1. Yes, time is right. Ingame and even on last login its correct.

2. However seems that player creation date seems to be 2 hours ahead of my time. How do I fix that?
Could this be it?
EDIT: Found and fixed time but it still removes premium xD I'm losing it haha

3. Yes type 2 and itemid 12466
Just do this: make a new account or even use one that is free account, go in your DB->accounts and save the numbers in PREMDAYS(must be 0) and LASTDAYS.

Buy a premium in website and then look again at the numbers in DB. Send me the numbers if they change.

Only need to do this with one account, just to test how the system Credit the acc
 
Just do this: make a new account or even use one that is free account, go in your DB->accounts and save the numbers in PREMDAYS(must be 0) and LASTDAYS.

Buy a premium in website and then look again at the numbers in DB. Send me the numbers if they change.

Only need to do this with one account, just to test how the system Credit the acc
Created new account. Before buying premium: premdays (0) lastday (0)

after buying premium: premdays (30) lastday (1657003954) <--- is this the issue? is lastday supposed to record your start of premium or lastday of premium?
Upon entering character list both columns resets to 0

EDIT:
Ok I think I know where the issue is.
When I buy premium on website, it registers lastday as when premium comes to an END (eg. 5 july)
When I use a premium scroll ingame it registers lastday as when premium STARTS (eg. 5 june)

How do I alter this?
 
Last edited:
Created new account. Before buying premium: premdays (0) lastday (0)

after buying premium: premdays (30) lastday (1657003954) <--- is this the issue? is lastday supposed to record your start of premium or lastday of premium?
Upon entering character list both columns resets to 0

EDIT:
Ok I think I know where the issue is.
When I buy premium on website, it registers lastday as when premium comes to an END (eg. 5 july)
When I use a premium scroll ingame it registers lastday as when premium STARTS (eg. 5 june)

How do I alter this?
Weird, cause lastday means lastday and no firstday hehehe.

But, you can change in the website function to add only the time now and not time now + days.

Go in your web files->engine->function->users.php

Search for:
PHP:
,`lastday` = GREATEST(`lastday`,UNIX_TIMESTAMP(CURDATE())) + ({$days} * 86400)

Change for:
PHP:
,`lastday` = GREATEST(`lastday`,UNIX_TIMESTAMP(CURDATE()))

And test again with clean account(just edit premdays and lastday to 0)
 
Solution
Weird, cause lastday means lastday and no firstday hehehe.

But, you can change in the website function to add only the time now and not time now + days.

Go in your web files->engine->function->users.php

Search for:
PHP:
,`lastday` = GREATEST(`lastday`,UNIX_TIMESTAMP(CURDATE())) + ({$days} * 86400)

Change for:
PHP:
,`lastday` = GREATEST(`lastday`,UNIX_TIMESTAMP(CURDATE()))

And test again with clean account(just edit premdays and lastday to 0)
Yes! This fixed it!!!!
It's super weird lmao I've been losing my shit for a few days now xD
Is this perhaps an issue with my server/distro? Cause I even noticed now when server save is happening att 09:55 (gmt+2)
It starts with saying 09:55 Server is saving game in 3306 minute(s). Please logout.
lol

Anyway thank you for all your help and time I appreciate it alot!!!!
 
Yes! This fixed it!!!!
It's super weird lmao I've been losing my shit for a few days now xD
Is this perhaps an issue with my server/distro? Cause I even noticed now when server save is happening att 09:55 (gmt+2)
It starts with saying 09:55 Server is saving game in 3306 minute(s). Please logout.
lol

Anyway thank you for all your help and time I appreciate it alot!!!!
Go to your globalevents and look at serversave script and globalevent.xml that set the start hour of ss

Take a look too at config.lua where servesave is configured

Maybe you figure out how to fix or whats happ
 
Back
Top