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

Donations?

elipse

New Member
Joined
Oct 11, 2012
Messages
62
Reaction score
0
How Can i make it that when a donation is purchased, they get a whole set, instead of just 1 item?
 
That depends on what kind of AAC you're using.. but I'd say that you can manage that by going to your phpMyAdmin and change it there.

If that doesn't work out, what AAC are you using?
 
I don't think the lua script you are using for delivering the items is made to support item sets.
So posting the script might help.
 
Place this in your config.php:
PHP:
1 => array(
            'type' => 4, // 1 = item id offers, 2 = premium days [itemid ignored], 3 = sex change[itemid & count ignored], 4+ = custom.
            'itemid' => array(
                    2160 => 100,
                    2392 => 2,
                    2400 => 1,
            ), 
            'count' => 1, //if type is 2, this represents premium days
            'describtion' => "100 Crystal coins and 1 Firesword and 1 itemid 2400.", // Describtion shown on website
            'points' => 100, // How many points this offer costs
),

item.png

Replace this with the old stuff in shop.php:

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

// Import from config:
$shop = $config['shop'];
$shop_list = $config['shop_offers'];

if (!empty($_POST['buy'])) {
    $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;
            $buykey = $key;
        }
    }
    if ($buy === false) die("Error: Shop offer ID mismatch.");
    
    // Verify that user can afford this offer.
    if ($player_points >= $buy['points']) {
        $old_points = mysql_result(mysql_query("SELECT `points` FROM `znote_accounts` WHERE `account_id`='$cid';"), 0, '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_query("UPDATE `znote_accounts` SET `points`='$new_points' WHERE `account_id`='$cid'");
        
        $verify = mysql_result(mysql_query("SELECT `points` FROM `znote_accounts` WHERE `account_id`='$cid';"), 0, '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));
        
        // Do the magic (insert into db, or change sex etc)
        // If type is 2 or 3 or 4
        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 sex
            mysql_query("INSERT INTO `znote_shop_orders` (`account_id`, `type`, `itemid`, `count`, `time`) VALUES ('$cid', '". $buy['type'] ."', '". $buy['itemid'] ."', '". $buy['count'] ."', '$time')") or die(mysql_error());
            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>';
        } if ($buy['type'] == 4) {
            mysql_query("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')") or die(mysql_error());
            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>';
            foreach ($shop_list[$buykey]["itemid"] as $key => $itmid) {
                mysql_query("INSERT INTO `znote_shop_orders` (`account_id`, `type`, `itemid`, `count`, `time`) VALUES ('$cid', '". $buy['type'] ."', '". $key ."', '". $itmid ."', '$time')") or die(mysql_error());
            }
        } else {
            mysql_query("INSERT INTO `znote_shop_orders` (`account_id`, `type`, `itemid`, `count`, `time`) VALUES ('$cid', '". $buy['type'] ."', '". $buy['itemid'] ."', '". $buy['count'] ."', '$time')") or die(mysql_error());
            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>';
        }
        
        if($buy['type'] != 4){
            // No matter which type, we will always log it.
            mysql_query("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')") or die(mysql_error());
        }
        
    } 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']) {
?>

<h1>Shop Offers</h1>
<?php
if (!empty($_POST['buy'])) {
    if ($user_znote_data['points'] >= $buy['points']) {
        ?><td>You have <?php echo (int)($user_znote_data['points'] - $buy['points']); ?> points. (<a href="buypoints.php">Buy points</a>).</td><?php
    } else {
        ?><td>You have <?php echo $user_znote_data['points']; ?> points. (<a href="buypoints.php">Buy points</a>).</td><?php
    }
} else {
    ?><td>You have <?php echo $user_znote_data['points']; ?> points. (<a href="buypoints.php">Buy points</a>).</td><?php
}
?>
<table>
    <tr class="yellow">
        <td>Description:</td>
        <td>Count/duration:</td>
        <td>Points:</td>
        <td>Action:</td>
    </tr>
        <?php
        foreach ($shop_list as $key => $offers) {
        echo '<tr class="special">';
        echo '<td>'. $offers['describtion'] .'</td>';
        if ($offers['type'] == 2) echo '<td>'. $offers['count'] .' Days</td>';
        else if ($offers['type'] == 3 && $offers['count'] == 0) echo '<td>Unlimited</td>';
        else echo '<td>'. $offers['count'] .'x</td>';
        echo '<td>'. $offers['points'] .'</td>';
        echo '<td>';
        ?>
        <form action="" method="POST">
            <input type="hidden" name="buy" value="<?php echo (int)$key; ?>">
            <input type="submit" value="  PURCHASE  ">
        </form>
        <?php
        echo '</td>';
        echo '</tr>';
        }
        ?>
</table>
<?php
} else echo '<h1>Buy Points system disabled.</h1><p>Sorry, this functionality is disabled.</p>';
include 'layout/overall/footer.php'; ?>


Haven't tested it but should work fine. I know the code is a bit messy I'll work on a somewhat more improved version. But for now this will do.
 
Last edited:
You can add custom packages

Create an offer with a unique type, this type will represent this package:
PHP:
6 => array(
			'type' => 5, // CUstom type 5, package
			'itemid' => 0, // Ignore
			'count' => 1, // package count
			'describtion' => "1 firesword + 1 demon shield.", // desc presented in shop
			'points' => 20, // how muh shall package cost?
		),

in the shopsystem.lua in data/talkactions/scripts/
Lua:
if q_type == 5 then -- make sure this type is same as type written in config.php i znote aac
	-- Get wheight
	local playerCap = getPlayerFreeCap(cid)
	local itemweight = getItemWeight(ITEMID1, 1)
	itemweight += getItemWeight(ITEMID2, 1)
	
		if playerCap >= itemweight then
			db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
			doPlayerAddItem(cid, ITEMID1, 1)
			doPlayerAddItem(cid, ITEMID2, 1)
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have recieved item package PACKAGENAME!")
		else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Need more CAP!")
		end
end
 
so will both of these work? doesnt matter which?

- - - Updated - - -

i dont have shopsystem.lua in my talkaction scripts.
 
You need to use Znote AAC shop system for Znote AAC. enter www/lua/TFS_0x to find the lua scripts and you can add it.
 
Back
Top